BitArray

This struct represents an array of boolean values, each of which occupy one bit of memory for storage. Thus an array of 32 bits would occupy the same space as one integer value. The typical array operations--such as indexing and sorting--are supported, as well as bitwise operations such as and, or, xor, and complement.

Members

Functions

dim
size_t dim()

Gets the length of a uint array large enough to hold all stored bits.

dup
BitArray dup()

Duplicates this array, much like the dup property for built-in arrays.

init
void init(void[] target, size_t numbits)

Map BitArray onto target, with numbits being the number of bits in the array. Does not copy the data. This is the inverse of opCast.

length
size_t length()

Get the number of bits in this array.

length
void length(size_t newlen)

Resizes this array to newlen bits. If newlen is larger than the current length, the new bits will be initialized to zero.

opAnd
BitArray opAnd(BitArray rhs)

Generates a new array which is the result of a bitwise and operation between this array and the supplied array.

opAndAssign
BitArray opAndAssign(BitArray rhs)

Updates the contents of this array with the result of a bitwise and operation between this array and the supplied array.

opApply
int opApply(int delegate(ref bool) dg)
int opApply(int delegate(ref size_t, ref bool) dg)

Operates on all bits in this array.

opAssign
void opAssign(bool[] bits)

Resets the length of this array to bits.length and then initializes this

opCast
void[] opCast()

Convert this array to a void array.

opCat
BitArray opCat(bool rhs)
BitArray opCat(BitArray rhs)

Generates a new array which is the result of this array concatenated with the supplied array.

opCatAssign
BitArray opCatAssign(bool b)
BitArray opCatAssign(BitArray rhs)

Updates the contents of this array with the result of this array concatenated with the supplied array.

opCat_r
BitArray opCat_r(bool lhs)

Generates a new array which is the result of this array concatenated with the supplied array.

opCmp
int opCmp(BitArray rhs)

Performs a lexicographical comparison of this array to the supplied array.

opCom
BitArray opCom()

Generates a copy of this array with the unary complement operation applied.

opEquals
int opEquals(BitArray rhs)

Compares this array to another for equality. Two bit arrays are equal if they are the same size and contain the same series of bits.

opIndex
bool opIndex(size_t pos)

Support for index operations, much like the behavior of built-in arrays.

opIndexAssign
bool opIndexAssign(bool b, size_t pos)

Support for index operations, much like the behavior of built-in arrays.

opOr
BitArray opOr(BitArray rhs)

Generates a new array which is the result of a bitwise or operation between this array and the supplied array.

opOrAssign
BitArray opOrAssign(BitArray rhs)

Updates the contents of this array with the result of a bitwise or operation between this array and the supplied array.

opSliceAssign
BitArray opSliceAssign(BitArray rhs)

Copy the bits from one array into this array. This is not a shallow copy.

opSub
BitArray opSub(BitArray rhs)

Generates a new array which is the result of this array minus the supplied array. a - b for BitArrays means the same thing as a & ~b.

opSubAssign
BitArray opSubAssign(BitArray rhs)

Updates the contents of this array with the result of this array minus the supplied array. a - b for BitArrays means the same thing as a & ~b.

opXor
BitArray opXor(BitArray rhs)

Generates a new array which is the result of a bitwise xor operation between this array and the supplied array.

opXorAssign
BitArray opXorAssign(BitArray rhs)

Updates the contents of this array with the result of a bitwise xor operation between this array and the supplied array.

reverse
BitArray reverse()

Reverses the contents of this array in place, much like the reverse property for built-in arrays.

sort
BitArray sort()

Sorts this array in place, with zero entries sorting before one. This is equivalent to the sort property for built-in arrays.

Static functions

opCall
BitArray opCall(bool[] bits)

This initializes a BitArray of bits.length bits, where each bit value matches the corresponding boolean value in bits.

Variables

len
size_t len;
Undocumented in source.
ptr
uint* ptr;
Undocumented in source.

Meta