[#BloombergLP-bdlb-BitStringUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlb.adoc[bdlb]::BitStringUtil
:relfileprefix: ../../
:mrdocs:

This `struct` provides a namespace for a suite of static functions to manipulate and access sequences of bits stored in an array of `uint64&lowbar;t` (also known as a &quot;bit string&quot;&semi; see &lcub;The &quot;Bit String&quot; Pseudo&hyphen;Type&rcub;)&period;

== Synopsis

Declared in `&lt;bdlb&lowbar;bitstringutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct BitStringUtil;
----

== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlb/BitStringUtil/_04enum.adoc[`Unnamed enum`] 
| Bit&hyphen;string utility constants&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlb/BitStringUtil/andEqual.adoc[`andEqual`] 
| Bitwise AND the specified `numBits` of the specified `dstBitString` starting at the specified `dstIndex` with the `numBits` of the specified `srcBitString` starting at the specified `srcIndex`, and write the result over the bits that were read from `dstBitString`&period; The behavior is undefined unless `dstBitString` has a length of at least `dstIndex &plus; numBits` and `srcBitString` has a length of at least `srcIndex &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/areEqual-0a.adoc[`areEqual`] 
| `areEqual` overloads
| xref:BloombergLP/bdlb/BitStringUtil/assign-01.adoc[`assign`] 
| `assign` overloads
| xref:BloombergLP/bdlb/BitStringUtil/assign0-04.adoc[`assign0`] 
| `assign0` overloads
| xref:BloombergLP/bdlb/BitStringUtil/assign1-07.adoc[`assign1`] 
| `assign1` overloads
| xref:BloombergLP/bdlb/BitStringUtil/assignBits.adoc[`assignBits`] 
| Assign the low&hyphen;order specified `numBits` from the specified `srcValue` to the `numBits` starting at the specified `index` in the specified `bitString`&period; The behavior is undefined unless `numBits &lt;&equals; k&lowbar;BITS&lowbar;PER&lowbar;UINT64` and `bitString` has a capacity of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/bit.adoc[`bit`] 
| Return the bit value at the specified `index` in the specified `bitString`&period; The behavior is undefined unless `index` is less than the length of `bitString`&period;
| xref:BloombergLP/bdlb/BitStringUtil/bits.adoc[`bits`] 
| Return the specified `numBits` beginning at the specified `index` in the specified `bitString` as the low&hyphen;order bits of the returned value&period; The behavior is undefined unless `numBits &lt;&equals; k&lowbar;BITS&lowbar;PER&lowbar;UINT64` and `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/copy.adoc[`copy`] 
| Copy to the specified `dstBitString`, beginning at the specified `dstIndex`, the specified `numBits` beginning at the specified `srcIndex` in the specified `srcBitString`&period; This function works correctly regardless of whether the source and destination ranges overlap&period; The behavior is undefined unless `dstBitString` has a capacity of at least `dstIndex &plus; numBits` and `srcBitString` has a length of at least `srcIndex &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/copyRaw.adoc[`copyRaw`] 
| Copy to the specified `dstBitString`, beginning at the specified `dstIndex`, the specified `numBits` beginning at the specified `srcIndex` in the specified `srcBitString`&period; The behavior is undefined unless `dstBitString` has a capacity of at least `dstIndex &plus; numBits`, `srcBitString` has a length of at least `srcIndex &plus; numBits`, and the source and destination ranges either do not overlap, or the destination range is equal to the source range, or the start of the destination range is below the start of the source range&period;
| xref:BloombergLP/bdlb/BitStringUtil/find0AtMaxIndex-03.adoc[`find0AtMaxIndex`] 
| `find0AtMaxIndex` overloads
| xref:BloombergLP/bdlb/BitStringUtil/find0AtMinIndex-05.adoc[`find0AtMinIndex`] 
| `find0AtMinIndex` overloads
| xref:BloombergLP/bdlb/BitStringUtil/find1AtMaxIndex-09.adoc[`find1AtMaxIndex`] 
| `find1AtMaxIndex` overloads
| xref:BloombergLP/bdlb/BitStringUtil/find1AtMinIndex-05.adoc[`find1AtMinIndex`] 
| `find1AtMinIndex` overloads
| xref:BloombergLP/bdlb/BitStringUtil/insert.adoc[`insert`] 
| Insert the specified `numBits`, each having the specified `value`, into the specified `bitString` having the specified `initialLength`, beginning at the specified `dstIndex`&period; Bits at or above `dstIndex` are shifted up by `numBits` index positions and the length of `bitString` is increased by `numBits`&period; The behavior is undefined unless `dstIndex &lt;&equals; initialLength` and `bitString` has a capacity of at least `initialLength &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/insert0.adoc[`insert0`] 
| Insert the specified `numBits` 0 bits into the specified `bitString` having the specified `initialLength` beginning at the specified `dstIndex`&period; Bits at or above `dstIndex` are shifted up by `numBits` index positions and the length of `bitString` is increased by `numBits`&period; The behavior is undefined unless `dstIndex &lt;&equals; initialLength` and `bitString` has a capacity of at least `initialLength &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/insert1.adoc[`insert1`] 
| Insert the specified `numBits` 1 bits into the specified `bitString` having the specified `initialLength` beginning at the specified `dstIndex`&period; Bits at or above `dstIndex` are shifted up by `numBits` index positions and the length of `bitString` is increased by `numBits`&period; The behavior is undefined unless `dstIndex &lt;&equals; initialLength` and `bitString` has a capacity of at least `initialLength &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/insertRaw.adoc[`insertRaw`] 
| Insert the specified `numBits` into the specified `bitString` having the specified `initialLength` beginning at the specified `dstIndex`&period; Bits at or above `dstIndex` are shifted up by `numBits` index positions and the length of `bitString` is increased by `numBits`&period; The values of the inserted bits are undefined&period; The behavior is undefined unless `dstIndex &lt;&equals; initialLength` and `bitString` has a capacity of at least `initialLength &plus; numBits`&period; Note that the inserted bits are not assigned any value&period;
| xref:BloombergLP/bdlb/BitStringUtil/isAny0.adoc[`isAny0`] 
| Return `true` if any of the specified `numBits` beginning at the specified `index` in the specified `bitString` are 0, and `false` otherwise&period; The behavior is undefined unless `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/isAny1.adoc[`isAny1`] 
| Return `true` if any of the specified `numBits` beginning at the specified `index` in the specified `bitString` are 1, and `false` otherwise&period; The behavior is undefined unless `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/minusEqual.adoc[`minusEqual`] 
| Bitwise MINUS the specified `numBits` of the specified `srcBitString` starting at the specified `srcIndex` from the `numBits` of the specified `dstBitString` starting at the specified `dstIndex`, and write the result over the bits that were read from `dstBitString`&period; The behavior is undefined unless `dstBitString` has a length of at least `dstIndex &plus; numBits` and `srcBitString` has a length of at least `srcIndex &plus; numBits`&period; Note that the logical difference `A &hyphen; B` is defined to be `A &amp; !B`&period;
| xref:BloombergLP/bdlb/BitStringUtil/num0.adoc[`num0`] 
| Return the number of 0 bits in the specified `numBits` beginning at the specified `index` in the specified `bitString`&period; The behavior is undefined unless `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/num1.adoc[`num1`] 
| Return the number of 1 bits in the specified `numBits` beginning at the specified `index` in the specified `bitString`&period; The behavior is undefined unless `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/orEqual.adoc[`orEqual`] 
| Bitwise OR the specified `numBits` of the specified `dstBitString` starting at the specified `dstIndex` with the `numBits` of the specified `srcBitString` starting at the specified `srcIndex`, and write the result over the bits that were read from `dstBitString`&period; The behavior is undefined unless `dstBitString` has a length of at least `dstIndex &plus; numBits` and `srcBitString` has a length of at least `srcIndex &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/print.adoc[`print`] 
| Format to the specified output `stream` the specified low&hyphen;order `numBits` in the specified `bitString` in hexadecimal, and return a reference to `stream`&period; The highest order bits are printed first, in groups of 16 nibbles, 64 nibbles per line (in the case of multi&hyphen;line output)&period; Optionally specify `level`, the indentation level for each line output&period; Optionally specify `spacesPerLevel`, the number of spaces per indentation level&period; Each line is indented by the absolute value of `level &ast; spacesPerLevel`&period; If `spacesPerLevel` is negative, suppress line breaks and format the entire output on one line&period; If `stream` is initially invalid, this operation has no effect&period; Note that a trailing newline is provided in multiline mode only&period;
| xref:BloombergLP/bdlb/BitStringUtil/remove.adoc[`remove`] 
| Remove the specified `numBits` from the specified `bitString` of the specified `length` beginning at the specified `index`&period; Bits above `index &plus; numBits` are shifted down by `numBits` index positions and the length of `bitString` is reduced by `numBits`&period; The values of the vacated high&hyphen;order bits are not modified&period; The behavior is undefined unless `index &plus; numBits &lt;&equals; length`&period;
| xref:BloombergLP/bdlb/BitStringUtil/removeAndFill0.adoc[`removeAndFill0`] 
| Remove the specified `numBits` from the specified `bitString` having the specified `length` beginning at the specified `index`&period; Bits above `index &plus; numBits` are shifted down by `numBits` index positions and the last `numBits` of `bitString` are set to 0&period; The length of `bitString` is not changed&period; The behavior is undefined unless `index &plus; numBits &lt;&equals; length`&period;
| xref:BloombergLP/bdlb/BitStringUtil/removeAndFill1.adoc[`removeAndFill1`] 
| Remove the specified `numBits` from the specified `bitString` having the specified `length` beginning at the specified `index`&period; Bits above `index &plus; numBits` are shifted down by `numBits` index positions and the last `numBits` of `bitString` are set to 1&period; The length of `bitString` is not changed&period; The behavior is undefined unless `index &plus; numBits &lt;&equals; length`&period;
| xref:BloombergLP/bdlb/BitStringUtil/swapRaw.adoc[`swapRaw`] 
| Exchange the specified `numBits` beginning at the specified `index1` in the specified `bitString1` with the `numBits` beginning at the specified `index2` in the specified `bitString2`&period; The behavior is undefined unless `bitString1` has a length of at least `index1 &plus; numBits`, `bitString2` has a length of at least `index2 &plus; numBits`, and there is _no_ overlap between the swapped ranges of bits&period;
| xref:BloombergLP/bdlb/BitStringUtil/toggle.adoc[`toggle`] 
| Invert the values of the specified `numBits` in the specified `bitString` beginning at the specified `index`&period; The behavior is undefined unless `bitString` has a length of at least `index &plus; numBits`&period;
| xref:BloombergLP/bdlb/BitStringUtil/xorEqual.adoc[`xorEqual`] 
| Bitwise XOR the specified `numBits` of the specified `dstBitString` starting at the specified `dstIndex` with the `numBits` of the specified `srcBitString` starting at the specified `srcIndex`, and write the result over the bits that were read from `dstBitString`&period; The behavior is undefined unless `dstBitString` has a length of at least `dstIndex &plus; numBits` and `srcBitString` has a length of at least `srcIndex &plus; numBits`&period;
|===


== Static Data Members

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



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