openMSX
|
#include <IterableBitSet.hh>
Public Member Functions | |
bool | empty () const |
(Implicit) default constructor. | |
void | set (size_t pos) |
Set the (single) bit at position 'pos' to '1'. | |
void | setPosN (size_t pos, size_t n) |
Starting from position 'pos', set the 'n' following bits to '1'. | |
void | setRange (size_t begin, size_t end) |
Set all bits in the half-open range [begin, end) to '1'. | |
void | foreachSetBit (std::invocable< size_t > auto op) const |
Execute the given operation 'op' for all '1' bits. | |
A collection of N bits, with N a compile-time constant.
The main difference with std::bitset is that this implementation allows to efficiently:
This implementation is well suited for bitsets of size up to hundreds or even a few thousand bits. For much larger bitsets and/or for bitsets with specific patterns (e.g. very sparse, or large bursts), other implementations might be better suited.
The interface of this class is (intentionally) minimal. If/when needed we can easily extend it.
Definition at line 30 of file IterableBitSet.hh.
|
inline |
(Implicit) default constructor.
Sets all bits to '0'. Returns true iff none of the bits are set.
Definition at line 45 of file IterableBitSet.hh.
References ranges::all_of().
Referenced by TEST_CASE().
|
inline |
Execute the given operation 'op' for all '1' bits.
The operation is called with the index of the bit as parameter. The bits are visited in ascending order.
Definition at line 117 of file IterableBitSet.hh.
References xrange().
Referenced by expect().
|
inline |
Set the (single) bit at position 'pos' to '1'.
Definition at line 52 of file IterableBitSet.hh.
Referenced by TEST_CASE().
|
inline |
Starting from position 'pos', set the 'n' following bits to '1'.
Definition at line 66 of file IterableBitSet.hh.
References IterableBitSet< N >::setRange().
Referenced by test().
|
inline |
Set all bits in the half-open range [begin, end) to '1'.
Definition at line 73 of file IterableBitSet.hh.
References begin(), and end().
Referenced by IterableBitSet< N >::setPosN(), and test().