|
CoreComponents 3.0.0
A Modern C++ Toolkit
|
Array of bits More...
#include <cc/BitArray>
Classes | |
| class | Access |
| Provide access to a single bit in a BitArray. More... | |
Public Types | |
| using | Item = bool |
| Item type. | |
Public Member Functions | |
| BitArray () | |
| Create an empty bit array. | |
| BitArray (long n, bool on=false) | |
| Create a new bit array of n bits preset to on. | |
| long | count () const |
| Number of bits. | |
| bool | has (long i) const |
| Check if i is a valid index. | |
| operator bool () const | |
| Check if this bit array is non-empty. | |
| long | operator+ () const |
| Number of bits. | |
| bool | at (long i) const |
| Read the bit at index i. | |
| Access | at (long i) |
| Access the bit at index i | |
| bool | operator[] (long i) const |
| Read the bit at index i. | |
| Access | operator[] (long i) |
| Access the bit at index i | |
| bool | operator() (long i, bool fallback=false) const |
| Get value at index if 0 <= index && index < count(), otherwise return fallback. | |
| void | fill (bool on) |
| Set all bits to on | |
| BitArray | copy () const |
| Create a deep copy of this array. | |
Standard Iterators | |
| using | value_type = Item |
| Item value type. | |
| using | size_type = long |
| Type of the container capacity. | |
| using | iterator = ArrayIterator<BitArray, 1> |
| Value iterator. | |
| using | const_iterator = ArrayIterator<const BitArray, 1> |
| Readonly value iterator. | |
| using | reverse_iterator = ArrayIterator<BitArray, -1> |
| Reverse value iterator. | |
| using | const_reverse_iterator = ArrayIterator<const BitArray, -1> |
| Readonly reverse value iterator. | |
| iterator | begin () |
| Return iterator pointing to the first item (if any) | |
| iterator | end () |
| Return iterator pointing behind the last item | |
| const_iterator | begin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | cbegin () const |
| Return readonly iterator pointing to the first item (if any) | |
| const_iterator | end () const |
| Return readonly iterator pointing behind the last item | |
| const_iterator | cend () const |
| Return readonly iterator pointing behind the last item | |
| reverse_iterator | rbegin () |
| Return reverse iterator pointing to the last item (if any) | |
| reverse_iterator | rend () |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | rbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | crbegin () const |
| Return readonly reverse iterator pointing to the last item (if any) | |
| const_reverse_iterator | rend () const |
| Return reverse iterator pointing before the first item | |
| const_reverse_iterator | crend () const |
| Return reverse iterator pointing before the first item | |
Comparism Operators | |
| bool | operator== (const BitArray &other) const |
| Equal to operator. | |
| bool | operator!= (const BitArray &other) const |
| Not equal to operator. | |
Array of bits
| using Item = bool |
Item type.
| using value_type = Item |
Item value type.
| using size_type = long |
Type of the container capacity.
| using iterator = ArrayIterator<BitArray, 1> |
Value iterator.
| using const_iterator = ArrayIterator<const BitArray, 1> |
Readonly value iterator.
| using reverse_iterator = ArrayIterator<BitArray, -1> |
Reverse value iterator.
| using const_reverse_iterator = ArrayIterator<const BitArray, -1> |
Readonly reverse value iterator.
| BitArray | ( | ) |
Create an empty bit array.
|
explicit |
Create a new bit array of n bits preset to on.
| long count | ( | ) | const |
Number of bits.
| bool has | ( | long | i | ) | const |
Check if i is a valid index.
|
explicit |
Check if this bit array is non-empty.
| long operator+ | ( | ) | const |
Number of bits.
| bool at | ( | long | i | ) | const |
Read the bit at index i.
| Access at | ( | long | i | ) |
Access the bit at index i
| bool operator[] | ( | long | i | ) | const |
Read the bit at index i.
| Access operator[] | ( | long | i | ) |
Access the bit at index i
| bool operator() | ( | long | i, |
| bool | fallback = false ) const |
Get value at index if 0 <= index && index < count(), otherwise return fallback.
| void fill | ( | bool | on | ) |
Set all bits to on
| BitArray copy | ( | ) | const |
Create a deep copy of this array.
| BitArray::iterator begin | ( | ) |
Return iterator pointing to the first item (if any)
| BitArray::iterator end | ( | ) |
Return iterator pointing behind the last item
| BitArray::const_iterator begin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| BitArray::const_iterator cbegin | ( | ) | const |
Return readonly iterator pointing to the first item (if any)
| BitArray::const_iterator end | ( | ) | const |
Return readonly iterator pointing behind the last item
| BitArray::const_iterator cend | ( | ) | const |
Return readonly iterator pointing behind the last item
| BitArray::reverse_iterator rbegin | ( | ) |
Return reverse iterator pointing to the last item (if any)
| BitArray::reverse_iterator rend | ( | ) |
Return reverse iterator pointing before the first item
| BitArray::const_reverse_iterator rbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| BitArray::const_reverse_iterator crbegin | ( | ) | const |
Return readonly reverse iterator pointing to the last item (if any)
| BitArray::const_reverse_iterator rend | ( | ) | const |
Return reverse iterator pointing before the first item
| BitArray::const_reverse_iterator crend | ( | ) | const |
Return reverse iterator pointing before the first item
| bool operator== | ( | const BitArray & | other | ) | const |
Equal to operator.
| bool operator!= | ( | const BitArray & | other | ) | const |
Not equal to operator.