Efficient, value‐semantic contiguous array of boolean (bit) values.

Synopsis

Declared in <bdlc_bitarray.h>

class BitArray;

Description

This class implements an efficient, value‐semantic array of boolean (a.k.a. bit, i.e., binary digit) values stored in contiguous memory. The physical capacity of this array may grow, but never shrinks. Capacity may be reserved initially via a constructor, or at any time thereafter by using the reserveCapacity method; otherwise, capacity will be increased automatically as needed. Note that capacity is not a salient attribute of this object, and, as such, does not contribute to overall value. Also note that this class provides an implicit no‐throw guarantee for all methods (including manipulators) that do not attempt to alter capacity.

Enums

Name

Description

Unnamed enum

Constants describing the storage representation of a BitArray.

Member Functions

Name

Description

BitArray [constructor]

Constructors

~BitArray [destructor]

Destroy this object.

operator=

Assign to this array the value of the specified rhs array, and return a non‐`const` reference to this array.

allocator

Return the allocator used by this object to supply memory.

andEqual

andEqual overloads

append

append overloads

assign

assign overloads

assign0

assign0 overloads

assign1

assign1 overloads

assignAll

Set all bits in this array to the specified value.

assignAll0

Set to 0 the value of every bit in this array.

assignAll1

Set to 1 the value of every bit in this array.

assignBits

Assign low‐order bits from srcBits into this array at index.

bdexStreamIn

Assign to this object the value read from the specified input stream.

bdexStreamOut

Write this object to the specified output stream using version.

bits

Return numBits bits beginning at index as low‐order return bits.

find0AtMaxIndex

Return the highest index of a 0 bit in the optional range.

find0AtMinIndex

Return the lowest index of a 0 bit in the optional range.

find1AtMaxIndex

Return the highest index of a 1 bit in the optional range.

find1AtMinIndex

Return the lowest index of a 1 bit in the optional range.

insert

insert overloads

isAny0

Return true if the value of any bit in this array is 0, and false otherwise.

isAny1

Return true if the value of any bit in this array is 1, and false otherwise.

isEmpty

Return true if the length of this bit array is 0, and false otherwise.

length

Return the number of bits in this array.

minusEqual

minusEqual overloads

num0

Return the number of 0 bits in the optionally specified range.

num1

Return the number of 1 bits in the optionally specified range.

operator&=

Bitwise AND rhs into this array and return a reference to this object.

operator‐=

Bitwise MINUS rhs from this array and return a reference to this object.

operator<<=

Left‐shift this bit array by numBits positions.

operator>>=

Right‐shift this bit array by numBits positions.

operator[]

Return the value of the bit at the specified index in this array. The behavior is undefined unless index < length().

operatorˆ=

Bitwise XOR rhs into this array and return a reference to this object.

operator|=

Bitwise OR rhs into this array and return a reference to this object.

orEqual

orEqual overloads

print

Format this object to the specified output stream.

remove

remove overloads

removeAll

Remove all of the bits in this array, leaving the length 0, but having no effect on capacity.

reserveCapacity

Reserve capacity for at least numBits without reallocation.

rotateLeft

Rotate the bits in this array left by numBits positions.

rotateRight

Rotate the bits in this array right by numBits positions.

setLength

Set the number of bits in this array to newLength.

swap

Efficiently exchange the value of this object with that of other.

swapBits

Exchange the bit values at index1 and index2.

toggle

toggle overloads

toggleAll

Complement the value of every bit in this array. Note that the behavior is analogous to applying the ~ operator to an object of fundamental type unsigned int.

xorEqual

xorEqual overloads

Static Member Functions

Name

Description

maxSupportedBdexVersion

maxSupportedBdexVersion overloads

Static Data Members

Name

Description

k_INVALID_INDEX

Sentinel index value indicating an invalid bit position.

Friends

Name

Description

BloombergLP::bdlc::operator==

Return true if lhs and rhs have the same value, else false.

Non-Member Functions

Name

Description

operator!=

Return true if lhs and rhs do not have the same value, else false.

operator&

Return the bitwise AND of the specified lhs and rhs arrays.

operator‐

Return the bitwise MINUS of the specified lhs and rhs arrays.

operator<<

Return array left‐shifted by numBits, filling low bits with zeros.

operator>>

Return array right‐shifted by numBits, filling high bits with zeros.

operatorˆ

Return the bitwise XOR of the specified lhs and rhs arrays.

operator|

Return the bitwise OR of the specified lhs and rhs arrays.

operator~

Return the bitwise complement ("toggle") of the specified array.

swap

Exchange the values of the specified a and b objects.

Created with MrDocs