BDE 4.14.0 Production release
|
#include <bdlb_bitstringutil.h>
Public Types | |
enum | { k_BITS_PER_UINT64 = 64 } |
Static Public Member Functions | |
static void | assign (bsl::uint64_t *bitString, bsl::size_t index, bool value) |
static void | assign (bsl::uint64_t *bitString, bsl::size_t index, bool value, bsl::size_t numBits) |
static void | assign0 (bsl::uint64_t *bitString, bsl::size_t index) |
static void | assign0 (bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static void | assign1 (bsl::uint64_t *bitString, bsl::size_t index) |
static void | assign1 (bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static void | assignBits (bsl::uint64_t *bitString, bsl::size_t index, bsl::uint64_t srcValue, bsl::size_t numBits) |
static void | andEqual (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | minusEqual (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | orEqual (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | xorEqual (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | copy (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | copyRaw (bsl::uint64_t *dstBitString, bsl::size_t dstIndex, const bsl::uint64_t *srcBitString, bsl::size_t srcIndex, bsl::size_t numBits) |
static void | insert (bsl::uint64_t *bitString, bsl::size_t initialLength, bsl::size_t dstIndex, bool value, bsl::size_t numBits) |
static void | insert0 (bsl::uint64_t *bitString, bsl::size_t initialLength, bsl::size_t dstIndex, bsl::size_t numBits) |
static void | insert1 (bsl::uint64_t *bitString, bsl::size_t initialLength, bsl::size_t dstIndex, bsl::size_t numBits) |
static void | insertRaw (bsl::uint64_t *bitString, bsl::size_t initialLength, bsl::size_t dstIndex, bsl::size_t numBits) |
static void | remove (bsl::uint64_t *bitString, bsl::size_t length, bsl::size_t index, bsl::size_t numBits) |
static void | removeAndFill0 (bsl::uint64_t *bitString, bsl::size_t length, bsl::size_t index, bsl::size_t numBits) |
static void | removeAndFill1 (bsl::uint64_t *bitString, bsl::size_t length, bsl::size_t index, bsl::size_t numBits) |
static void | swapRaw (bsl::uint64_t *bitString1, bsl::size_t index1, bsl::uint64_t *bitString2, bsl::size_t index2, bsl::size_t numBits) |
static void | toggle (bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bool | areEqual (const bsl::uint64_t *bitString1, const bsl::uint64_t *bitString2, bsl::size_t numBits) |
static bool | areEqual (const bsl::uint64_t *bitString1, bsl::size_t index1, const bsl::uint64_t *bitString2, bsl::size_t index2, bsl::size_t numBits) |
static bool | bit (const bsl::uint64_t *bitString, bsl::size_t index) |
static bsl::uint64_t | bits (const bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bsl::size_t | find0AtMaxIndex (const bsl::uint64_t *bitString, bsl::size_t length) |
static bsl::size_t | find0AtMaxIndex (const bsl::uint64_t *bitString, bsl::size_t begin, bsl::size_t end) |
static bsl::size_t | find0AtMinIndex (const bsl::uint64_t *bitString, bsl::size_t length) |
static bsl::size_t | find0AtMinIndex (const bsl::uint64_t *bitString, bsl::size_t begin, bsl::size_t end) |
static bsl::size_t | find1AtMaxIndex (const bsl::uint64_t *bitString, bsl::size_t length) |
static bsl::size_t | find1AtMaxIndex (const bsl::uint64_t *bitString, bsl::size_t begin, bsl::size_t end) |
static bsl::size_t | find1AtMinIndex (const bsl::uint64_t *bitString, bsl::size_t length) |
static bsl::size_t | find1AtMinIndex (const bsl::uint64_t *bitString, bsl::size_t begin, bsl::size_t end) |
static bool | isAny0 (const bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bool | isAny1 (const bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bsl::size_t | num0 (const bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bsl::size_t | num1 (const bsl::uint64_t *bitString, bsl::size_t index, bsl::size_t numBits) |
static bsl::ostream & | print (bsl::ostream &stream, const bsl::uint64_t *bitString, bsl::size_t numBits, int level=1, int spacesPerLevel=4) |
Static Public Attributes | |
static const bsl::size_t | k_INVALID_INDEX = ~static_cast<bsl::size_t>(0) |
This struct
provides a namespace for a suite of static functions to manipulate and access sequences of bits stored in an array of uint64_t
(also known as a "bit string"; see {The "Bit String" Pseudo-Type}).
|
static |
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
. The behavior is undefined unless dstBitString
has a length of at least dstIndex + numBits
and srcBitString
has a length of at least srcIndex + numBits
.
|
static |
Return true
if the specified numBits
beginning at the specified index1
in the specified bitString1
are bitwise equal to the numBits
beginning at the specified index2
in the specified bitString2
, and false
otherwise. The behavior is undefined unless bitString1
has a length of at least index1 + numBits
and bitString2
has a length of at least index2 + numBits
.
|
static |
Return true
if the specified low-order numBits
in the specified bitString1
are bitwise equal to the corresponding bits in the specified bitString2
, and false
otherwise. The behavior is undefined unless both bitString1
and bitString2
have a length of at least numBits
.
|
inlinestatic |
Set the bit at the specified index
in the specified bitString
to the specified value
. The behavior is undefined unless index
is less than the capacity of bitString
.
|
static |
Set the specified numBits
beginning at the specified index
in the specified bitString
to the specified value
. The behavior is undefined unless bitString
has a capacity of at least index + numBits
.
|
inlinestatic |
Set the bit at the specified index
in the specified bitString
to false
. The behavior is undefined unless index
is less than the capacity of bitString
.
|
static |
Set the specified numBits
beginning at the specified index
in the specified bitString
to false
. The behavior is undefined unless bitString
has a capacity of at least index + numBits
.
|
inlinestatic |
Set the bit at the specified index
in the specified bitString
to true
. The behavior is undefined unless index
is less than the capacity of bitString
.
|
static |
Set the specified numBits
beginning at the specified index
in the specified bitString
to true
. The behavior is undefined unless bitString
has a capacity of at least index + numBits
.
|
static |
Assign the low-order specified numBits
from the specified srcValue
to the numBits
starting at the specified index
in the specified bitString
. The behavior is undefined unless numBits <= k_BITS_PER_UINT64
and bitString
has a capacity of at least index + numBits
.
|
inlinestatic |
Return the bit value at the specified index
in the specified bitString
. The behavior is undefined unless index
is less than the length of bitString
.
|
static |
Return the specified numBits
beginning at the specified index
in the specified bitString
as the low-order bits of the returned value. The behavior is undefined unless numBits <= k_BITS_PER_UINT64
and bitString
has a length of at least index + numBits
.
|
static |
Copy to the specified dstBitString
, beginning at the specified dstIndex
, the specified numBits
beginning at the specified srcIndex
in the specified srcBitString
. This function works correctly regardless of whether the source and destination ranges overlap. The behavior is undefined unless dstBitString
has a capacity of at least dstIndex + numBits
and srcBitString
has a length of at least srcIndex + numBits
.
|
static |
Copy to the specified dstBitString
, beginning at the specified dstIndex
, the specified numBits
beginning at the specified srcIndex
in the specified srcBitString
. The behavior is undefined unless dstBitString
has a capacity of at least dstIndex + numBits
, srcBitString
has a length of at least srcIndex + 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.
|
static |
Return the index of the most-significant 0 bit in the specified bitString
in the specified range [begin .. end)
, if such a bit exists, and k_INVALID_INDEX
otherwise. The behavior is undefined unless begin <= end
and end
is less than or equal to the length of bitString
.
|
static |
Return the index of the most-significant 0 bit in the specified bitString
having the specified length
, if such a bit exists, and k_INVALID_INDEX
otherwise.
|
static |
Return the index of the least-significant 0 bit in the specified bitString
in the specified range [begin .. end)
, if such a bit exists, and k_INVALID_INDEX
otherwise. The behavior is undefined unless begin <= end
and end
is less than or equal to the length of bitString
.
|
static |
Return the index of the least-significant 0 bit in the specified bitString
having the specified length
, if such a bit exists, and k_INVALID_INDEX
otherwise.
|
static |
Return the index of the most-significant 1 bit in the specified bitString
in the specified range [begin .. end)
, if such a bit exists, and k_INVALID_INDEX
otherwise. The behavior is undefined unless begin <= end
and end
is less than or equal to the length of bitString
.
|
static |
Return the index of the most-significant 1 bit in the specified bitString
having the specified length
, if such a bit exists, and k_INVALID_INDEX
otherwise.
|
static |
Return the index of the least-significant 1 bit in the specified bitString
in the specified range [begin .. end)
, if such a bit exists, and k_INVALID_INDEX
otherwise. The behavior is undefined unless begin <= end
and end
is less than or equal to the length of bitString
.
|
static |
Return the index of the least-significant 1 bit in the specified bitString
having the specified length
, if such a bit exists, and k_INVALID_INDEX
otherwise.
|
inlinestatic |
Insert the specified numBits
, each having the specified value
, into the specified bitString
having the specified initialLength
, beginning at the specified dstIndex
. Bits at or above dstIndex
are shifted up by numBits
index positions and the length of bitString
is increased by numBits
. The behavior is undefined unless dstIndex <= initialLength
and bitString
has a capacity of at least initialLength + numBits
.
|
inlinestatic |
Insert the specified numBits
0 bits into the specified bitString
having the specified initialLength
beginning at the specified dstIndex
. Bits at or above dstIndex
are shifted up by numBits
index positions and the length of bitString
is increased by numBits
. The behavior is undefined unless dstIndex <= initialLength
and bitString
has a capacity of at least initialLength + numBits
.
|
inlinestatic |
Insert the specified numBits
1 bits into the specified bitString
having the specified initialLength
beginning at the specified dstIndex
. Bits at or above dstIndex
are shifted up by numBits
index positions and the length of bitString
is increased by numBits
. The behavior is undefined unless dstIndex <= initialLength
and bitString
has a capacity of at least initialLength + numBits
.
|
static |
Insert the specified numBits
into the specified bitString
having the specified initialLength
beginning at the specified dstIndex
. Bits at or above dstIndex
are shifted up by numBits
index positions and the length of bitString
is increased by numBits
. The values of the inserted bits are undefined. The behavior is undefined unless dstIndex <= initialLength
and bitString
has a capacity of at least initialLength + numBits
. Note that the inserted bits are not assigned any value.
|
static |
Return true
if any of the specified numBits
beginning at the specified index
in the specified bitString
are 0, and false
otherwise. The behavior is undefined unless bitString
has a length of at least index + numBits
.
|
static |
Return true
if any of the specified numBits
beginning at the specified index
in the specified bitString
are 1, and false
otherwise. The behavior is undefined unless bitString
has a length of at least index + numBits
.
|
static |
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
. The behavior is undefined unless dstBitString
has a length of at least dstIndex + numBits
and srcBitString
has a length of at least srcIndex + numBits
. Note that the logical difference A - B
is defined to be A & !B
.
|
inlinestatic |
Return the number of 0 bits in the specified numBits
beginning at the specified index
in the specified bitString
. The behavior is undefined unless bitString
has a length of at least index + numBits
.
|
static |
Return the number of 1 bits in the specified numBits
beginning at the specified index
in the specified bitString
. The behavior is undefined unless bitString
has a length of at least index + numBits
.
|
static |
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
. The behavior is undefined unless dstBitString
has a length of at least dstIndex + numBits
and srcBitString
has a length of at least srcIndex + numBits
.
|
static |
Format to the specified output stream
the specified low-order numBits
in the specified bitString
in hexadecimal, and return a reference to stream
. The highest order bits are printed first, in groups of 16 nibbles, 64 nibbles per line (in the case of multi-line output). Optionally specify level
, the indentation level for each line output. Optionally specify spacesPerLevel
, the number of spaces per indentation level. Each line is indented by the absolute value of level * spacesPerLevel
. If spacesPerLevel
is negative, suppress line breaks and format the entire output on one line. If stream
is initially invalid, this operation has no effect. Note that a trailing newline is provided in multiline mode only.
|
static |
Remove the specified numBits
from the specified bitString
of the specified length
beginning at the specified index
. Bits above index + numBits
are shifted down by numBits
index positions and the length of bitString
is reduced by numBits
. The values of the vacated high-order bits are not modified. The behavior is undefined unless index + numBits <= length
.
|
inlinestatic |
Remove the specified numBits
from the specified bitString
having the specified length
beginning at the specified index
. Bits above index + numBits
are shifted down by numBits
index positions and the last numBits
of bitString
are set to 0. The length of bitString
is not changed. The behavior is undefined unless index + numBits <= length
.
|
inlinestatic |
Remove the specified numBits
from the specified bitString
having the specified length
beginning at the specified index
. Bits above index + numBits
are shifted down by numBits
index positions and the last numBits
of bitString
are set to 1. The length of bitString
is not changed. The behavior is undefined unless index + numBits <= length
.
|
static |
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
. The behavior is undefined unless bitString1
has a length of at least index1 + numBits
, bitString2
has a length of at least index2 + numBits
, and there is no overlap between the swapped ranges of bits.
|
static |
Invert the values of the specified numBits
in the specified bitString
beginning at the specified index
. The behavior is undefined unless bitString
has a length of at least index + numBits
.
|
static |
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
. The behavior is undefined unless dstBitString
has a length of at least dstIndex + numBits
and srcBitString
has a length of at least srcIndex + numBits
.
|
static |