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.

Constructors

this
this(size_t _len, size_t* _ptr)

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

this
this(bool[] bits)
Undocumented in source.

Postblit

this(this)
this(this)

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

Members

Functions

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.

opAnd
BitArray opAnd(const(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(const(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)
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
void[] opCast()

Convert this array to a void array.

opCat
BitArray opCat(bool rhs)
BitArray opCat(const(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(const(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(const(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
bool opEquals(const(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(const(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(const(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(const(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(const(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(const(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(const(BitArray) rhs)

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

Manifest constants

bits_in_size
enum bits_in_size;
Undocumented in source.

Properties

dim
size_t dim [@property getter]

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

dup
BitArray dup [@property getter]

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

length
size_t length [@property getter]

Get the number of bits in this array.

length
size_t length [@property setter]

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

reverse
BitArray reverse [@property getter]

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

sort
BitArray sort [@property getter]

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

Variables

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

Meta