Set of bits collection.
More...
#include <base/collection/BitSet.h>
Inherits Collection.
Set of bits collection.
An ordered sequence of boolean values (bits). The is offen used to represent a set of flags. This class does not take up as much memory as Array<bool>.
- Version
- 1.0
- Examples
- testsuite/BitSet.cpp.
◆ BitSet() [1/3]
Initializes an empty bit set.
◆ BitSet() [2/3]
BitSet::BitSet |
( |
unsigned int |
size, |
|
|
bool |
value |
|
) |
| |
Initializes array with the specified number of elements.
- Parameters
-
size | The initial number of bits. |
value | The initial state of the bits. |
◆ BitSet() [3/3]
BitSet::BitSet |
( |
const BitSet & |
copy | ) |
|
|
inlinenoexcept |
Initializes bit set from other bit set.
◆ flip() [1/2]
◆ flip() [2/2]
BitSet& BitSet::flip |
( |
MemorySize |
index | ) |
|
Inverts the state at the specified index. Raises OutOfRange if the index is invalid.
◆ getAt()
bool BitSet::getAt |
( |
MemorySize |
index | ) |
const |
Returns the bit state at the specified index. Raises OutOfRange if the index is invalid.
- Parameters
-
index | The index of the element. |
◆ getBitMask()
static unsigned long BitSet::getBitMask |
( |
unsigned int |
index | ) |
|
|
inlinestaticprotectednoexcept |
Returns the bit mask for the specified index.
◆ getElementIndex()
static unsigned int BitSet::getElementIndex |
( |
unsigned int |
index | ) |
|
|
inlinestaticprotectednoexcept |
Returns the index of the internal element holding the bit at the specified index.
◆ getElements() [1/2]
unsigned long* BitSet::getElements |
( |
| ) |
|
|
inlineprotected |
Returns the elements of the internal array for modifying access.
◆ getElements() [2/2]
const unsigned long* BitSet::getElements |
( |
| ) |
const |
|
inlineprotectednoexcept |
Returns the elements of the internal array for non-modifying access.
◆ getEnumerator()
Returns a modifying enumerator of the bit set. The elements are enumerated from most significant to the least significant.
- Examples
- testsuite/BitSet.cpp.
◆ getNumberOfElements()
static MemorySize BitSet::getNumberOfElements |
( |
MemorySize |
size | ) |
|
|
inlinestaticprotectednoexcept |
Returns the number of required elements to hold the specified number of bits.
◆ getReadEnumerator()
Returns a non-modifying enumerator of the bit set. The elements are enumerated from most significant to the least significant.
- Examples
- testsuite/BitSet.cpp.
◆ getSize()
MemorySize BitSet::getSize |
( |
| ) |
const |
|
inlinenoexcept |
◆ isEmpty()
bool BitSet::isEmpty |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the bit set is empty.
◆ operator bool()
BitSet::operator bool |
( |
| ) |
|
|
inlinenoexcept |
Returns true if bitset is non-empty.
◆ operator&=()
Binary AND of the bit sets.
◆ operator<<()
BitSet BitSet::operator<< |
( |
unsigned int |
count | ) |
const |
|
inlinenoexcept |
Returns a left-shifted bit set.
◆ operator<<=()
BitSet& BitSet::operator<<= |
( |
unsigned int |
count | ) |
|
|
noexcept |
Binary left shift.
- Parameters
-
count | The number of bits to shift. |
◆ operator=()
Assignment of bit set to bit set.
◆ operator>>()
BitSet BitSet::operator>> |
( |
unsigned int |
count | ) |
const |
|
inlinenoexcept |
Returns a right-shifted bit set.
◆ operator>>=()
BitSet& BitSet::operator>>= |
( |
unsigned int |
count | ) |
|
|
noexcept |
Binary right shift.
- Parameters
-
count | The number of bits to shift. |
◆ operator[]() [1/2]
Element BitSet::operator[] |
( |
MemorySize |
index | ) |
|
|
inline |
Returns reference to the bit at the specified index. Raises OutOfRange if the index is invalid.
- Parameters
-
index | The index of the element. |
◆ operator[]() [2/2]
bool BitSet::operator[] |
( |
MemorySize |
index | ) |
const |
|
inline |
Returns the bit at the specified index. Raises OutOfRange if the index is invalid.
- Parameters
-
index | The index of the element. |
◆ operator^=()
Binary EXCLUSIVE OR of the bit sets.
◆ operator|=()
Binary OR of the bit sets.
◆ operator~()
BitSet BitSet::operator~ |
( |
| ) |
const |
|
inlinenoexcept |
Returns an inverted bit set.
◆ reinitialize()
void BitSet::reinitialize |
( |
| ) |
|
|
inlineprotectednoexcept |
◆ removeAll()
void BitSet::removeAll |
( |
| ) |
|
|
noexcept |
◆ reset() [1/2]
Resets (set to false) all the states of the bit set.
◆ reset() [2/2]
BitSet& BitSet::reset |
( |
MemorySize |
index | ) |
|
Resets (sets to false) the state at the specified index. Raises OutOfRange if the index is invalid.
◆ set() [1/2]
Sets (sets to true) all the states of the bit set.
◆ set() [2/2]
BitSet& BitSet::set |
( |
unsigned int |
index | ) |
|
Sets (sets to true) the state at the specified index. Raises OutOfRange if the index is invalid.
◆ setAt()
void BitSet::setAt |
( |
MemorySize |
index, |
|
|
bool |
value |
|
) |
| |
Sets the bit state at the specified index. Raises OutOfRange if the index is invalid.
- Parameters
-
index | The index of the element. |
value | The desired value. |
◆ setSize()
void BitSet::setSize |
( |
MemorySize |
size | ) |
|
|
inlineprotected |
Sets the number of bits in the bit set.
◆ zeroExtend()
void BitSet::zeroExtend |
( |
MemorySize |
size | ) |
|
|
protected |
Zero-extends the bit set to the specified size.