Specialized class for handling arrays of bits. More...
#include <bits_array.hpp>
Classes | |
struct | __bit |
proxy bit access More... | |
Public Member Functions | |
BitsArray (bool default_value=false) | |
creates a new prefilled BitsArray instance More... | |
const bool & | operator[] (int index) const |
random access iterator in const contexts More... | |
__bit | operator[] (int index) |
random access iterator for both l-value and r-value contexts More... | |
bool | at (int index) const |
alternative to random access iterator More... | |
int | find_free_bit () const |
finds a position of the first unset bit in the array More... | |
int | size () const |
void | clear () |
clears all bits of the array (sets them all to 0) | |
void | set_all () |
sets all bits of the array to 1 | |
void | unset_all () |
sets all bits of the array to 0 | |
Static Public Member Functions | |
static BitsArray< N > * | take_over (void *offset) |
Makes the memory at a certain offset available as a bits array and provides direct bit access to it More... | |
Specialized class for handling arrays of bits.
N | the size of the bits array |
The bits are packed into full words in a contiguous memory zone, so the size of the structure BitsArray<N> is the size of the minimum number of 32-bit integers required to contain all the N bits.
Actually, sizeof(BitsArray<N>) == 4*((N+31) / 32).
DSC::BitsArray< N >::BitsArray | ( | bool | default_value = false | ) |
creates a new prefilled BitsArray instance
default_value | the initial value of all bits |
bool DSC::BitsArray< N >::at | ( | int | index | ) | const |
alternative to random access iterator
index | the position of the bit 0..N-1 |
int DSC::BitsArray< N >::find_free_bit |
finds a position of the first unset bit in the array
DSC::BitsArray< N >::__bit DSC::BitsArray< N >::operator[] | ( | int | index | ) |
random access iterator for both l-value and r-value contexts
index | the position of the bit 0..N-1 |
const bool & DSC::BitsArray< N >::operator[] | ( | int | index | ) | const |
random access iterator in const contexts
index | the position of the bit 0..N-1 |
|
inline |
|
static |
Makes the memory at a certain offset available as a bits array and provides direct bit access to it
offset | the start of the bits array (must be word-aligned) |
N | the size of the bits array (must be multiple of 32) |