[#BloombergLP-bdlc-BitArray]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlc.adoc[bdlc]::BitArray
:relfileprefix: ../../
:mrdocs:

Efficient, value&hyphen;semantic contiguous array of boolean (bit) values&period;

== Synopsis

Declared in `&lt;bdlc&lowbar;bitarray&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class BitArray;
----

== Description

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

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/BitArray/_04enum.adoc[`Unnamed enum`] 
| Constants describing the storage representation of a `BitArray`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/BitArray/2constructor-011.adoc[`BitArray`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlc/BitArray/2destructor.adoc[`&#126;BitArray`] [.small]#[destructor]#
| Destroy this object&period;
| xref:BloombergLP/bdlc/BitArray/operator_assign.adoc[`operator&equals;`] 
| Assign to this array the value of the specified `rhs` array, and return a non&hyphen;`const` reference to this array&period;
| xref:BloombergLP/bdlc/BitArray/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/bdlc/BitArray/andEqual-04.adoc[`andEqual`] 
| `andEqual` overloads
| xref:BloombergLP/bdlc/BitArray/append-0b.adoc[`append`] 
| `append` overloads
| xref:BloombergLP/bdlc/BitArray/assign-01.adoc[`assign`] 
| `assign` overloads
| xref:BloombergLP/bdlc/BitArray/assign0-00.adoc[`assign0`] 
| `assign0` overloads
| xref:BloombergLP/bdlc/BitArray/assign1-0d.adoc[`assign1`] 
| `assign1` overloads
| xref:BloombergLP/bdlc/BitArray/assignAll.adoc[`assignAll`] 
| Set all bits in this array to the specified `value`&period;
| xref:BloombergLP/bdlc/BitArray/assignAll0.adoc[`assignAll0`] 
| Set to 0 the value of every bit in this array&period;
| xref:BloombergLP/bdlc/BitArray/assignAll1.adoc[`assignAll1`] 
| Set to 1 the value of every bit in this array&period;
| xref:BloombergLP/bdlc/BitArray/assignBits.adoc[`assignBits`] 
| Assign low&hyphen;order bits from `srcBits` into this array at `index`&period;
| xref:BloombergLP/bdlc/BitArray/bdexStreamIn.adoc[`bdexStreamIn`] 
| Assign to this object the value read from the specified input stream&period;
| xref:BloombergLP/bdlc/BitArray/bdexStreamOut.adoc[`bdexStreamOut`] 
| Write this object to the specified output stream using `version`&period;
| xref:BloombergLP/bdlc/BitArray/bits.adoc[`bits`] 
| Return `numBits` bits beginning at `index` as low&hyphen;order return bits&period;
| xref:BloombergLP/bdlc/BitArray/find0AtMaxIndex.adoc[`find0AtMaxIndex`] 
| Return the highest index of a 0 bit in the optional range&period;
| xref:BloombergLP/bdlc/BitArray/find0AtMinIndex.adoc[`find0AtMinIndex`] 
| Return the lowest index of a 0 bit in the optional range&period;
| xref:BloombergLP/bdlc/BitArray/find1AtMaxIndex.adoc[`find1AtMaxIndex`] 
| Return the highest index of a 1 bit in the optional range&period;
| xref:BloombergLP/bdlc/BitArray/find1AtMinIndex.adoc[`find1AtMinIndex`] 
| Return the lowest index of a 1 bit in the optional range&period;
| xref:BloombergLP/bdlc/BitArray/insert-08.adoc[`insert`] 
| `insert` overloads
| xref:BloombergLP/bdlc/BitArray/isAny0.adoc[`isAny0`] 
| Return `true` if the value of any bit in this array is 0, and `false` otherwise&period;
| xref:BloombergLP/bdlc/BitArray/isAny1.adoc[`isAny1`] 
| Return `true` if the value of any bit in this array is 1, and `false` otherwise&period;
| xref:BloombergLP/bdlc/BitArray/isEmpty.adoc[`isEmpty`] 
| Return `true` if the length of this bit array is 0, and `false` otherwise&period;
| xref:BloombergLP/bdlc/BitArray/length.adoc[`length`] 
| Return the number of bits in this array&period;
| xref:BloombergLP/bdlc/BitArray/minusEqual-0c.adoc[`minusEqual`] 
| `minusEqual` overloads
| xref:BloombergLP/bdlc/BitArray/num0.adoc[`num0`] 
| Return the number of 0 bits in the optionally specified range&period;
| xref:BloombergLP/bdlc/BitArray/num1.adoc[`num1`] 
| Return the number of 1 bits in the optionally specified range&period;
| xref:BloombergLP/bdlc/BitArray/operator_and_eq.adoc[`operator&amp;&equals;`] 
| Bitwise AND `rhs` into this array and return a reference to this object&period;
| xref:BloombergLP/bdlc/BitArray/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Bitwise MINUS `rhs` from this array and return a reference to this object&period;
| xref:BloombergLP/bdlc/BitArray/operator_lshift_eq.adoc[`operator&lt;&lt;&equals;`] 
| Left&hyphen;shift this bit array by `numBits` positions&period;
| xref:BloombergLP/bdlc/BitArray/operator_rshift_eq.adoc[`operator&gt;&gt;&equals;`] 
| Right&hyphen;shift this bit array by `numBits` positions&period;
| xref:BloombergLP/bdlc/BitArray/operator_subs.adoc[`operator&lsqb;&rsqb;`] 
| Return the value of the bit at the specified `index` in this array&period; The behavior is undefined unless `index &lt; length()`&period;
| xref:BloombergLP/bdlc/BitArray/operator_xor_eq.adoc[`operator&circ;&equals;`] 
| Bitwise XOR `rhs` into this array and return a reference to this object&period;
| xref:BloombergLP/bdlc/BitArray/operator_or_eq.adoc[`operator&verbar;&equals;`] 
| Bitwise OR `rhs` into this array and return a reference to this object&period;
| xref:BloombergLP/bdlc/BitArray/orEqual-076.adoc[`orEqual`] 
| `orEqual` overloads
| xref:BloombergLP/bdlc/BitArray/print.adoc[`print`] 
| Format this object to the specified output stream&period;
| xref:BloombergLP/bdlc/BitArray/remove-09.adoc[`remove`] 
| `remove` overloads
| xref:BloombergLP/bdlc/BitArray/removeAll.adoc[`removeAll`] 
| Remove all of the bits in this array, leaving the length 0, but having no effect on capacity&period;
| xref:BloombergLP/bdlc/BitArray/reserveCapacity.adoc[`reserveCapacity`] 
| Reserve capacity for at least `numBits` without reallocation&period;
| xref:BloombergLP/bdlc/BitArray/rotateLeft.adoc[`rotateLeft`] 
| Rotate the bits in this array left by `numBits` positions&period;
| xref:BloombergLP/bdlc/BitArray/rotateRight.adoc[`rotateRight`] 
| Rotate the bits in this array right by `numBits` positions&period;
| xref:BloombergLP/bdlc/BitArray/setLength.adoc[`setLength`] 
| Set the number of bits in this array to `newLength`&period;
| xref:BloombergLP/bdlc/BitArray/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with that of `other`&period;
| xref:BloombergLP/bdlc/BitArray/swapBits.adoc[`swapBits`] 
| Exchange the bit values at `index1` and `index2`&period;
| xref:BloombergLP/bdlc/BitArray/toggle-0d1.adoc[`toggle`] 
| `toggle` overloads
| xref:BloombergLP/bdlc/BitArray/toggleAll.adoc[`toggleAll`] 
| Complement the value of every bit in this array&period; Note that the behavior is analogous to applying the `&#126;` operator to an object of fundamental type `unsigned int`&period;
| xref:BloombergLP/bdlc/BitArray/xorEqual-0e.adoc[`xorEqual`] 
| `xorEqual` overloads
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/BitArray/maxSupportedBdexVersion-07.adoc[`maxSupportedBdexVersion`] 
| `maxSupportedBdexVersion` overloads
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/BitArray/k_INVALID_INDEX.adoc[`k&lowbar;INVALID&lowbar;INDEX`] 
| Sentinel index value indicating an invalid bit position&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlc/operator_eq-04d.adoc[BloombergLP::bdlc::operator&equals;&equals;]`
| Return `true` if `lhs` and `rhs` have the same value, else `false`&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlc/operator_not_eq-008.adoc[`operator!&equals;`]
| Return `true` if `lhs` and `rhs` do not have the same value, else `false`&period;
| xref:BloombergLP/bdlc/operator_bitand.adoc[`operator&amp;`]
| Return the bitwise AND of the specified `lhs` and `rhs` arrays&period;
| xref:BloombergLP/bdlc/operator_minus-0a9.adoc[`operator&hyphen;`]
| Return the bitwise MINUS of the specified `lhs` and `rhs` arrays&period;
| xref:BloombergLP/bdlc/operator_lshift-0688.adoc[`operator&lt;&lt;`]
| Return `array` left&hyphen;shifted by `numBits`, filling low bits with zeros&period;
| xref:BloombergLP/bdlc/operator_rshift.adoc[`operator&gt;&gt;`]
| Return `array` right&hyphen;shifted by `numBits`, filling high bits with zeros&period;
| xref:BloombergLP/bdlc/operator_xor.adoc[`operator&circ;`]
| Return the bitwise XOR of the specified `lhs` and `rhs` arrays&period;
| xref:BloombergLP/bdlc/operator_bitor.adoc[`operator&verbar;`]
| Return the bitwise OR of the specified `lhs` and `rhs` arrays&period;
| xref:BloombergLP/bdlc/operator_bitnot.adoc[`operator&#126;`]
| Return the bitwise complement (&quot;toggle&quot;) of the specified `array`&period;
| xref:BloombergLP/bdlc/swap-00b.adoc[`swap`]
| Exchange the values of the specified `a` and `b` objects&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
