Class BitVector
Represents an array of bits for which the concrete may be known or unknown, and can be reinterpreted as different value types, and operated on using the different semantics of these types.
public class BitVector : ICloneable
- Inheritance
-
BitVector
- Implements
- Inherited Members
Constructors
BitVector(BitVectorSpan)
Copies a span into a new bit vector.
public BitVector(BitVectorSpan span)
Parameters
spanBitVectorSpanThe span to copy.
BitVector(byte)
Creates a new fully known 8-wide bit vector.
public BitVector(byte value)
Parameters
valuebyteThe bits.
BitVector(byte, byte)
Creates a new partially known 8-wide bit vector.
public BitVector(byte bits, byte knownMask)
Parameters
BitVector(byte[])
Wraps a byte array into a fully known bit vector.
public BitVector(byte[] bits)
Parameters
bitsbyte[]The raw bits to wrap.
BitVector(byte[], byte[])
Wraps a pair of byte arrays into a partially known bit vector.
public BitVector(byte[] bits, byte[] knownMask)
Parameters
bitsbyte[]The raw bits to wrap.
knownMaskbyte[]The bitmask indicating which bits in
bitsare known.
BitVector(double)
Creates a new fully known 64-wide bit vector based on a floating point number.
public BitVector(double value)
Parameters
valuedoubleThe bits.
BitVector(short)
Creates a new fully known 16-wide bit vector.
public BitVector(short value)
Parameters
valueshortThe bits.
BitVector(short, ushort)
Creates a new partially known 16-wide bit vector.
public BitVector(short bits, ushort knownMask)
Parameters
BitVector(int)
Creates a new fully known 32-wide bit vector.
public BitVector(int value)
Parameters
valueintThe bits.
BitVector(int, bool)
Creates a new bit vector of the provided size.
public BitVector(int count, bool initialize)
Parameters
countintThe number of bits in the vector.
initializeboolIndicates the bitvector should be initialized with zeroes.
Exceptions
- ArgumentOutOfRangeException
Occurs when
countis not a multiple of 8.
BitVector(int, uint)
Creates a new partially known 32-wide bit vector.
public BitVector(int bits, uint knownMask)
Parameters
BitVector(long)
Creates a new fully known 64-wide bit vector.
public BitVector(long value)
Parameters
valuelongThe bits.
BitVector(long, ulong)
Creates a new partially known 64-wide bit vector.
public BitVector(long bits, ulong knownMask)
Parameters
BitVector(sbyte)
Creates a new fully known 8-wide bit vector.
public BitVector(sbyte value)
Parameters
valuesbyteThe bits.
BitVector(sbyte, byte)
Creates a new partially known 8-wide bit vector.
public BitVector(sbyte bits, byte knownMask)
Parameters
BitVector(float)
Creates a new fully known 32-wide bit vector based on a floating point number.
public BitVector(float value)
Parameters
valuefloatThe bits.
BitVector(ushort)
Creates a new fully known 16-wide bit vector.
public BitVector(ushort value)
Parameters
valueushortThe bits.
BitVector(ushort, ushort)
Creates a new partially known 16-wide bit vector.
public BitVector(ushort bits, ushort knownMask)
Parameters
BitVector(uint)
Creates a new fully known 32-wide bit vector.
public BitVector(uint value)
Parameters
valueuintThe bits.
BitVector(uint, uint)
Creates a new partially known 32-wide bit vector.
public BitVector(uint bits, uint knownMask)
Parameters
BitVector(ulong)
Creates a new fully known 64-wide bit vector.
public BitVector(ulong value)
Parameters
valueulongThe bits.
BitVector(ulong, ulong)
Creates a new partially known 64-wide bit vector.
public BitVector(ulong bits, ulong knownMask)
Parameters
Properties
Bits
Gets the raw bits stored in this bit vector.
public byte[] Bits { get; }
Property Value
- byte[]
ByteCount
Gets the number of bytes stored in the bit vector.
public int ByteCount { get; }
Property Value
Count
Gets the number of bits stored in the bit vector.
public int Count { get; }
Property Value
IsFullyKnown
Gets a value indicating whether all bits in the vector are known.
public bool IsFullyKnown { get; }
Property Value
KnownMask
Gets a bit mask indicating which bits in Bits are known.
public byte[] KnownMask { get; }
Property Value
- byte[]
Methods
AsSpan()
Creates a new span of the entire bit vector.
public BitVectorSpan AsSpan()
Returns
- BitVectorSpan
The constructed span.
AsSpan(int)
Creates a new span of a portion of the bit vector that starts at a provided bit index.
public BitVectorSpan AsSpan(int bitIndex)
Parameters
bitIndexintThe index to start the span at.
Returns
- BitVectorSpan
The constructed span.
AsSpan(int, int)
Creates a new span of a portion of the bit vector that starts at a provided bit index and has a provided length.
public BitVectorSpan AsSpan(int bitIndex, int length)
Parameters
Returns
- BitVectorSpan
The constructed span.
Clone()
Deep copies the bit vector.
public BitVector Clone()
Returns
- BitVector
The copied bit vector.
Clone(BitVectorPool)
Deep copies the bit vector.
public BitVector Clone(BitVectorPool pool)
Parameters
poolBitVectorPoolThe pool to rent the cloned bitvector from.
Returns
- BitVector
The copied bit vector.
ParseBinary(string)
Parses a binary string, where the least significant bit is at the end of the string, into a bit vector.
public static BitVector ParseBinary(string binaryString)
Parameters
binaryStringstringThe binary string to parse. This string may contain unknown bits (
?).
Returns
- BitVector
The parsed bit vector.
Resize(int, bool)
Allocates a new bit vector that contains the same data, but is extended or truncated to a new size.
public BitVector Resize(int newSize, bool signExtend)
Parameters
newSizeintThe new size.
signExtendboolWhen
newSizeis larger than the original size, a value indicating whether the vector should be sign extended or not.
Returns
- BitVector
The new vector.
Resize(int, bool, BitVectorPool)
Rents a bit vector from a pool that contains the same data, but is extended or truncated to a new size.
public BitVector Resize(int newSize, bool signExtend, BitVectorPool pool)
Parameters
newSizeintThe new size.
signExtendboolWhen
newSizeis larger than the original size, a value indicating whether the vector should be sign extended or not.poolBitVectorPoolThe pool to rent the new vector from.
Returns
- BitVector
The new vector.
ToString()
public override string ToString()
Returns
Operators
implicit operator BitVector(byte)
Creates a new fully known 8-wide bit vector.
public static implicit operator BitVector(byte value)
Parameters
valuebyteThe bits.
Returns
implicit operator BitVector(double)
Creates a new fully known 64-wide bit vector.
public static implicit operator BitVector(double value)
Parameters
valuedoubleThe bits.
Returns
implicit operator BitVector(short)
Creates a new fully known 16-wide bit vector.
public static implicit operator BitVector(short value)
Parameters
valueshortThe bits.
Returns
implicit operator BitVector(int)
Creates a new fully known 32-wide bit vector.
public static implicit operator BitVector(int value)
Parameters
valueintThe bits.
Returns
implicit operator BitVector(long)
Creates a new fully known 64-wide bit vector.
public static implicit operator BitVector(long value)
Parameters
valuelongThe bits.
Returns
implicit operator BitVector(sbyte)
Creates a new fully known 8-wide bit vector.
public static implicit operator BitVector(sbyte value)
Parameters
valuesbyteThe bits.
Returns
implicit operator BitVector(float)
Creates a new fully known 32-wide bit vector.
public static implicit operator BitVector(float value)
Parameters
valuefloatThe bits.
Returns
implicit operator BitVector(ushort)
Creates a new fully known 16-wide bit vector.
public static implicit operator BitVector(ushort value)
Parameters
valueushortThe bits.
Returns
implicit operator BitVector(uint)
Creates a new fully known 32-wide bit vector.
public static implicit operator BitVector(uint value)
Parameters
valueuintThe bits.
Returns
implicit operator BitVector(ulong)
Creates a new fully known 64-wide bit vector.
public static implicit operator BitVector(ulong value)
Parameters
valueulongThe bits.