BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlc::BitArray Class Reference

#include <bdlc_bitarray.h>

Public Types

enum  { k_BITS_PER_UINT64 = 64 }
 

Public Member Functions

 BitArray (bslma::Allocator *basicAllocator=0)
 
 BitArray (bsl::size_t initialLength, bslma::Allocator *basicAllocator=0)
 
 BitArray (bsl::size_t initialLength, bool value, bslma::Allocator *basicAllocator=0)
 
 BitArray (const BitArray &original, bslma::Allocator *basicAllocator=0)
 
 ~BitArray ()
 Destroy this object.
 
BitArrayoperator= (const BitArray &rhs)
 
BitArrayoperator&= (const BitArray &rhs)
 
BitArrayoperator-= (const BitArray &rhs)
 
BitArrayoperator|= (const BitArray &rhs)
 
BitArrayoperator^= (const BitArray &rhs)
 
BitArrayoperator<<= (bsl::size_t numBits)
 
BitArrayoperator>>= (bsl::size_t numBits)
 
void andEqual (bsl::size_t index, bool value)
 
void andEqual (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void append (bool value)
 
void append (bool value, bsl::size_t numBits)
 
void append (const BitArray &srcArray)
 
void append (const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void assign (bsl::size_t index, bool value)
 
void assign (bsl::size_t index, bool value, bsl::size_t numBits)
 
void assign (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void assign0 (bsl::size_t index)
 
void assign0 (bsl::size_t index, bsl::size_t numBits)
 
void assign1 (bsl::size_t index)
 
void assign1 (bsl::size_t index, bsl::size_t numBits)
 
void assignAll (bool value)
 Set all bits in this array to the specified value.
 
void assignAll0 ()
 Set to 0 the value of every bit in this array.
 
void assignAll1 ()
 Set to 1 the value of every bit in this array.
 
void assignBits (bsl::size_t index, bsl::uint64_t srcBits, bsl::size_t numBits)
 
void insert (bsl::size_t dstIndex, bool value)
 
void insert (bsl::size_t dstIndex, bool value, bsl::size_t numBits)
 
void insert (bsl::size_t dstIndex, const BitArray &srcArray)
 
void insert (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void minusEqual (bsl::size_t index, bool value)
 
void minusEqual (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void orEqual (bsl::size_t index, bool value)
 
void orEqual (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
void remove (bsl::size_t index)
 
void remove (bsl::size_t index, bsl::size_t numBits)
 
void removeAll ()
 
void reserveCapacity (bsl::size_t numBits)
 
void rotateLeft (bsl::size_t numBits)
 
void rotateRight (bsl::size_t numBits)
 
void setLength (bsl::size_t newLength, bool value=false)
 
void swapBits (bsl::size_t index1, bsl::size_t index2)
 
void toggle (bsl::size_t index)
 
void toggle (bsl::size_t index, bsl::size_t numBits)
 
void toggleAll ()
 
void xorEqual (bsl::size_t index, bool value)
 
void xorEqual (bsl::size_t dstIndex, const BitArray &srcArray, bsl::size_t srcIndex, bsl::size_t numBits)
 
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
 
void swap (BitArray &other)
 
bool operator[] (bsl::size_t index) const
 
bsl::uint64_t bits (bsl::size_t index, bsl::size_t numBits) const
 
bsl::size_t find0AtMaxIndex (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bsl::size_t find0AtMinIndex (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bsl::size_t find1AtMaxIndex (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bsl::size_t find1AtMinIndex (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bool isAny0 () const
 
bool isAny1 () const
 
bool isEmpty () const
 
bsl::size_t length () const
 Return the number of bits in this array.
 
bsl::size_t num0 (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bsl::size_t num1 (bsl::size_t begin=0, bsl::size_t end=k_INVALID_INDEX) const
 
bslma::Allocatorallocator () const
 Return the allocator used by this object to supply memory.
 
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Static Public Member Functions

static int maxSupportedBdexVersion (int versionSelector)
 
static int maxSupportedBdexVersion ()
 

Static Public Attributes

static const bsl::size_t k_INVALID_INDEX
 

Friends

bool operator== (const BitArray &, const BitArray &)
 

Detailed 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.

See bdlc_bitarray

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
k_BITS_PER_UINT64 

Constructor & Destructor Documentation

◆ BitArray() [1/4]

bdlc::BitArray::BitArray ( bslma::Allocator basicAllocator = 0)
explicit

◆ BitArray() [2/4]

bdlc::BitArray::BitArray ( bsl::size_t  initialLength,
bslma::Allocator basicAllocator = 0 
)
explicit

◆ BitArray() [3/4]

bdlc::BitArray::BitArray ( bsl::size_t  initialLength,
bool  value,
bslma::Allocator basicAllocator = 0 
)

Create an array of binary digits (bits). By default, the array is empty and has a capacity of 0 bits. Optionally specify the initialLength (in bits) of the array. If initialLength is not specified, the default length is 0. If initialLength is specified, optionally specify the value for each bit in the initialLength. If value is not specified, the default value for each bit is false (0). Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ BitArray() [4/4]

bdlc::BitArray::BitArray ( const BitArray original,
bslma::Allocator basicAllocator = 0 
)

Create an array of binary digits (bits) having the same value as the specified original array. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~BitArray()

bdlc::BitArray::~BitArray ( )

Member Function Documentation

◆ allocator()

bslma::Allocator * bdlc::BitArray::allocator ( ) const
inline

◆ andEqual() [1/2]

void bdlc::BitArray::andEqual ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Bitwise AND the specified numBits in this array, beginning at the specified dstIndex, with values from the specified srcArray, beginning at the specified srcIndex (retaining the results). The behavior is undefined unless dstIndex + numBits <= length() and srcIndex + numBits <= srcArray.length().

◆ andEqual() [2/2]

void bdlc::BitArray::andEqual ( bsl::size_t  index,
bool  value 
)
inline

AND the bit at the specified index in this array with the specified value (retaining the result). The behavior is undefined unless index < length().

◆ append() [1/4]

void bdlc::BitArray::append ( bool  value)
inline

Append to this array the specified value. Note that this method has the same behavior as:

insert(length(), value);
void insert(bsl::size_t dstIndex, bool value)
Definition bdlc_bitarray.h:1487
bsl::size_t length() const
Return the number of bits in this array.
Definition bdlc_bitarray.h:1815

◆ append() [2/4]

void bdlc::BitArray::append ( bool  value,
bsl::size_t  numBits 
)
inline

Append to this array the specified numBits having the specified value. Note that this method has the same behavior as:

insert(length(), value, numBits);

◆ append() [3/4]

void bdlc::BitArray::append ( const BitArray srcArray)
inline

Append to this array the values from the specified srcArray. Note that this method has the same behavior as:

insert(length(), srcArray);

◆ append() [4/4]

void bdlc::BitArray::append ( const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Append to this array the specified numBits from the specified srcArray, beginning at the specified srcIndex. The behavior is undefined unless srcIndex + numBits <= srcArray.length(). Note that this method has the same behavior as:

insert(length(), srcArray, srcIndex, numBits);

◆ assign() [1/3]

void bdlc::BitArray::assign ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Replace the specified numBits in this array, beginning at the specified dstIndex, with values from the specified srcArray beginning at the specified srcIndex. The behavior is undefined unless dstIndex + numBits <= length() and srcIndex + numBits <= srcArray.length(). Note that, absent aliasing, this method has the same behavior as, but is more efficient than:

remove(dstIndex, numBits);
insert(dstIndex, srcArray, srcIndex, numBits);
void remove(bsl::size_t index)
Definition bdlc_bitarray.h:1561

◆ assign() [2/3]

void bdlc::BitArray::assign ( bsl::size_t  index,
bool  value 
)
inline

Set the value at the specified index in this array to the specified value. The behavior is undefined unless index < length().

◆ assign() [3/3]

void bdlc::BitArray::assign ( bsl::size_t  index,
bool  value,
bsl::size_t  numBits 
)
inline

Set the value of the specified numBits bits starting at the specified index in this array to the specified value. The behavior is undefined unless index + numBits < length().

◆ assign0() [1/2]

void bdlc::BitArray::assign0 ( bsl::size_t  index)
inline

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

◆ assign0() [2/2]

void bdlc::BitArray::assign0 ( bsl::size_t  index,
bsl::size_t  numBits 
)
inline

Set to 0 the specified numBits values in this array, beginning at the specified index. The behavior is undefined unless index + numBits <= length().

◆ assign1() [1/2]

void bdlc::BitArray::assign1 ( bsl::size_t  index)
inline

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

◆ assign1() [2/2]

void bdlc::BitArray::assign1 ( bsl::size_t  index,
bsl::size_t  numBits 
)
inline

Set to 1 the specified numBits values in this array, beginning at the specified index. The behavior is undefined unless index + numBits <= length().

◆ assignAll()

void bdlc::BitArray::assignAll ( bool  value)
inline

◆ assignAll0()

void bdlc::BitArray::assignAll0 ( )
inline

◆ assignAll1()

void bdlc::BitArray::assignAll1 ( )
inline

◆ assignBits()

void bdlc::BitArray::assignBits ( bsl::size_t  index,
bsl::uint64_t  srcBits,
bsl::size_t  numBits 
)
inline

Assign the low-order specified numBits from the specified srcBits to this object, starting at the specified index. The behavior is undefined unless numBits <= k_BITS_PER_UINT64 and index + numBits <= length().

◆ bdexStreamIn()

template<class STREAM >
STREAM & bdlc::BitArray::bdexStreamIn ( STREAM &  stream,
int  version 
)

Assign to this object the value read from the specified input stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, this object is unaltered and stream is invalidated, but otherwise unmodified. If version is supported but stream becomes invalid during this operation, this object has an undefined, but valid, state. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ bdexStreamOut()

template<class STREAM >
STREAM & bdlc::BitArray::bdexStreamOut ( STREAM &  stream,
int  version 
) const

Write the value of this object, using the specified version format, to the specified output stream, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, stream is invalidated, but otherwise unmodified. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ bits()

bsl::uint64_t bdlc::BitArray::bits ( bsl::size_t  index,
bsl::size_t  numBits 
) const
inline

Return the specified numBits beginning at the specified index in this array as the low-order bits of the returned value. The behavior is undefined unless numBits <= sizeof(uint64_t) * CHAR_BIT and index + numBits <= length().

◆ find0AtMaxIndex()

bsl::size_t bdlc::BitArray::find0AtMaxIndex ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the index of the most-significant 0 bit in this array in the range optionally specified by begin and end, and k_INVALID_INDEX otherwise. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ find0AtMinIndex()

bsl::size_t bdlc::BitArray::find0AtMinIndex ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the index of the least-significant 0 bit in this array in the range optionally specified by begin and end, and k_INVALID_INDEX otherwise. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ find1AtMaxIndex()

bsl::size_t bdlc::BitArray::find1AtMaxIndex ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the index of the most-significant 1 bit in this array in the range optionally specified by begin and end, and k_INVALID_INDEX otherwise. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ find1AtMinIndex()

bsl::size_t bdlc::BitArray::find1AtMinIndex ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the index of the least-significant 1 bit in this array in the range optionally specified by begin and end, and k_INVALID_INDEX otherwise. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ insert() [1/4]

void bdlc::BitArray::insert ( bsl::size_t  dstIndex,
bool  value 
)
inline

Insert into this array at the specified dstIndex the specified value. All values with indices at or above dstIndex in this array are shifted up by one bit position. The behavior is undefined unless dstIndex <= length().

◆ insert() [2/4]

void bdlc::BitArray::insert ( bsl::size_t  dstIndex,
bool  value,
bsl::size_t  numBits 
)
inline

Insert into this array at the specified dstIndex the specified numBits having the specified value. All values with indices at or above dstIndex in this array are shifted up by numBits bit positions. The behavior is undefined unless dstIndex <= length().

◆ insert() [3/4]

void bdlc::BitArray::insert ( bsl::size_t  dstIndex,
const BitArray srcArray 
)
inline

Insert into this array, beginning at the specified dstIndex, the values from the specified srcArray. All values with indices at or above dstIndex in this array are shifted up by srcArray.length() bit positions. The behavior is undefined unless dstIndex <= length().

◆ insert() [4/4]

void bdlc::BitArray::insert ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)

Insert into this array, beginning at the specified dstIndex, the specified numBits from the specified srcArray beginning at the specified srcIndex. All values with initial indices at or above dstIndex are shifted up by numBits positions. The behavior is undefined unless dstIndex <= length() and srcIndex + numBits <= srcArray.length().

◆ isAny0()

bool bdlc::BitArray::isAny0 ( ) const
inline

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

◆ isAny1()

bool bdlc::BitArray::isAny1 ( ) const
inline

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

◆ isEmpty()

bool bdlc::BitArray::isEmpty ( ) const
inline

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

◆ length()

bsl::size_t bdlc::BitArray::length ( ) const
inline

◆ maxSupportedBdexVersion() [1/2]

int bdlc::BitArray::maxSupportedBdexVersion ( )
inlinestatic
Deprecated:
Use maxSupportedBdexVersion(int) instead.

Return the most current BDEX streaming version number supported by this class.

◆ maxSupportedBdexVersion() [2/2]

int bdlc::BitArray::maxSupportedBdexVersion ( int  versionSelector)
inlinestatic

Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that it is highly recommended that versionSelector be formatted as "YYYYMMDD", a date representation. Also note that versionSelector should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ minusEqual() [1/2]

void bdlc::BitArray::minusEqual ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Bitwise MINUS (subtract) from the specified numBits in this array, beginning at the specified dstIndex, values from the specified srcArray beginning at the specified srcIndex (retaining the results). The behavior is undefined unless dstIndex + numBits <= length() and srcIndex + numBits <= srcArray.length(). Note that the logical difference A - B is defined to be A & !B.

◆ minusEqual() [2/2]

void bdlc::BitArray::minusEqual ( bsl::size_t  index,
bool  value 
)
inline

MINUS (subtract) from the bit at the specified index in this array the specified value (retaining the result). The behavior is undefined unless index < length(). Note that the logical difference A - B is defined to be A & !B.

◆ num0()

bsl::size_t bdlc::BitArray::num0 ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the number of bits in the range optionally specified by begin and end having a value of 0. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ num1()

bsl::size_t bdlc::BitArray::num1 ( bsl::size_t  begin = 0,
bsl::size_t  end = k_INVALID_INDEX 
) const
inline

Return the number of bits in the range optionally specified by begin and end having a value of 1. The range is [begin .. effectiveEnd), where effectiveEnd == length() if end is not specified and effectiveEnd == end otherwise. The behavior is undefined unless begin <= effectiveEnd <= length().

◆ operator&=()

BitArray & bdlc::BitArray::operator&= ( const BitArray rhs)
inline

Bitwise AND the value of the specified rhs array with the value of this array (retaining the results), and return a non-const reference to this object. The length of the result will be the maximum of the lengths of this object and rhs, where any most-significant bits that are represented in one of the two but not the other will be set to 0. Note that a &= b; will result in the same value of a as a = a & b;.

◆ operator-=()

BitArray & bdlc::BitArray::operator-= ( const BitArray rhs)
inline

Bitwise MINUS the value of the specified rhs array from the value of this array (retaining the results), and return a non-const reference to this object. The length of the result will be the maximum of the lengths of this object and rhs. If length() > rhs.length(), the unmatched most-significant bits in this array are left unchanged; otherwise, any high-order bits of the result that were not present in this object prior to the operation will be set to 0. Note that a -= b; will result in the same value of a as a = a - b; and if a and b are the same length, a -= b; will result in the same value of a as a &= ~b; or a = a & ~b;.

◆ operator<<=()

BitArray & bdlc::BitArray::operator<<= ( bsl::size_t  numBits)
inline

Shift the bits in this array LEFT by the specified numBits, filling lower-order bits with zeros (retaining the results), and return a non-const reference to this object. The behavior is undefined unless numBits <= length(). Note that the length of this array is unchanged and the highest-order numBits are discarded.

◆ operator=()

BitArray & bdlc::BitArray::operator= ( const BitArray rhs)
inline

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

◆ operator>>=()

BitArray & bdlc::BitArray::operator>>= ( bsl::size_t  numBits)
inline

Shift the bits in this array RIGHT by the specified numBits, filling higher-order bits with zeros and discarding low-order bits, and return a non-const reference to this object. The behavior is undefined unless numBits <= length(). Note that the length of this array is unchanged.

◆ operator[]()

bool bdlc::BitArray::operator[] ( bsl::size_t  index) const
inline

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

◆ operator^=()

BitArray & bdlc::BitArray::operator^= ( const BitArray rhs)
inline

Bitwise XOR the value of the specified rhs array with the value of this array (retaining the results), and return a non-const reference to this object. If length() > rhs.length(), the unmatched most-significant bits in this array are left unchanged; otherwise, any unmatched most-significant bits in rhs are propagated to the result without modification. Note that a ^= b; will result in the same value of a as a = a ^ b;.

◆ operator|=()

BitArray & bdlc::BitArray::operator|= ( const BitArray rhs)
inline

Bitwise OR the value of the specified rhs array with the value of this array (retaining the results), and return a non-const reference to this object. If length() > rhs.length(), the unmatched most-significant bits in this array are left unchanged; otherwise, any unmatched most-significant bits in rhs are propagated to the result without modification. Note that a |= b; will result in the same value of a as a = a | b;.

◆ orEqual() [1/2]

void bdlc::BitArray::orEqual ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Bitwise OR the specified numBits in this array, beginning at the specified dstIndex, with values from the specified srcArray beginning at the specified srcIndex (retaining the results). The behavior is undefined unless dstIndex + numBits <= length() and srcIndex + numBits <= srcArray.length().

◆ orEqual() [2/2]

void bdlc::BitArray::orEqual ( bsl::size_t  index,
bool  value 
)
inline

OR the bit at the specified index in this array with the specified value (retaining the result). The behavior is undefined unless index < length().

◆ print()

bsl::ostream & bdlc::BitArray::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this object to the specified output stream at the optionally specified indentation level and return a non-const reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. Each line is indented by the absolute value of level * spacesPerLevel. If level is negative, suppress indentation of the first line. 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.

◆ remove() [1/2]

void bdlc::BitArray::remove ( bsl::size_t  index)
inline

Remove from this array the bit at the specified index. All values at indices above index in this array are shifted down by one bit position. The length of this array is reduced by 1. The behavior is undefined unless index < length().

◆ remove() [2/2]

void bdlc::BitArray::remove ( bsl::size_t  index,
bsl::size_t  numBits 
)
inline

Remove from this array the specified numBits, beginning at the specified index. All values at indices above index in this array are shifted down by numBits positions. The length of this array is reduced by numBits. The behavior is undefined unless index + numBits <= length().

◆ removeAll()

void bdlc::BitArray::removeAll ( )
inline

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

◆ reserveCapacity()

void bdlc::BitArray::reserveCapacity ( bsl::size_t  numBits)
inline

Reserve sufficient internal capacity to accommodate a length of at least the specified numBits without reallocation. If an exception is thrown during this reallocation attempt (i.e., by the memory allocator indicated at construction) the value of this array is guaranteed to be unchanged.

◆ rotateLeft()

void bdlc::BitArray::rotateLeft ( bsl::size_t  numBits)

Shift the values in this array to the left by the specified numBits positions, with the high-order values "rotating" into the low-order bits. The behavior is undefined unless numBits <= length(). Note that the length of this array remains unchanged.

◆ rotateRight()

void bdlc::BitArray::rotateRight ( bsl::size_t  numBits)

Shift the values in this array to the right by the specified numBits positions, with the low-order values "rotating" into the high-order bits. The behavior is undefined unless numBits <= length(). Note that the length of this array remains unchanged.

◆ setLength()

void bdlc::BitArray::setLength ( bsl::size_t  newLength,
bool  value = false 
)

Set the number of bits in this array to the specified newLength. If newLength < length(), bits at index positions at or above newLength are removed; otherwise, any new bits (at or above the current length) are initialized to the optionally specified value, or to 0 if value is not specified.

◆ swap()

void bdlc::BitArray::swap ( BitArray other)
inline

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee. The behavior is undefined unless this object was created with the same allocator as other.

◆ swapBits()

void bdlc::BitArray::swapBits ( bsl::size_t  index1,
bsl::size_t  index2 
)
inline

Efficiently exchange the values of the bits at the specified index1 and index2 indices. The behavior is undefined unless index1 < length() and index2 < length().

◆ toggle() [1/2]

void bdlc::BitArray::toggle ( bsl::size_t  index)
inline

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

◆ toggle() [2/2]

void bdlc::BitArray::toggle ( bsl::size_t  index,
bsl::size_t  numBits 
)
inline

Complement the values of each of the specified numBits in this array, beginning at the specified index. The behavior is undefined unless index + numBits <= length().

◆ toggleAll()

void bdlc::BitArray::toggleAll ( )
inline

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() [1/2]

void bdlc::BitArray::xorEqual ( bsl::size_t  dstIndex,
const BitArray srcArray,
bsl::size_t  srcIndex,
bsl::size_t  numBits 
)
inline

Bitwise XOR the specified numBits in this array, beginning at the specified dstIndex, with values from the specified srcArray beginning at the specified srcIndex (retaining the results). The behavior is undefined unless dstIndex + numBits <= length() and srcIndex + numBits <= srcArray.length().

◆ xorEqual() [2/2]

void bdlc::BitArray::xorEqual ( bsl::size_t  index,
bool  value 
)
inline

XOR the bit at the specified index in this array with the specified value (retaining the result). The behavior is undefined unless index < length().

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( const BitArray ,
const BitArray  
)
friend

Return true if the specified lhs and rhs arrays have the same value, and false otherwise. Two arrays have the same value if they have the same length, and corresponding bits at each bit position have the same value.

Member Data Documentation

◆ k_INVALID_INDEX

const bsl::size_t bdlc::BitArray::k_INVALID_INDEX
static
Initial value:
=
static const bsl::size_t k_INVALID_INDEX
Definition bdlb_bitstringutil.h:420

The documentation for this class was generated from the following file: