A class for a dynamic bit mask specialised for fast, ordered iteration using the forEachSetBit method.
More...
#include <IdentifierMask.h>
|
| | IdentifierMask (size_t maxHash) |
| void | set (size_t hash) |
| | Mark a hash as present.
|
| bool | test (size_t hash) const |
| | Check if a hash is present.
|
| void | unset (size_t hash) |
| | Remove a hash from the mask (Set bit to 0).
|
| void | clear () |
| | Reset all bits to 0.
|
| template<typename Func> |
| void | forEachSetBit (Func &&f) const |
| | Execute a lambda for every set bit The lambda should accept a size_t index.
|
| size_t | size () const |
| | Return the total size of the mask.
|
| size_t | count () const |
| | Return a count of the bits set to 1.
|
|
| static constexpr size_t | BitsPerWord = 64 |
| | Bits per storage unit (64).
|
| static constexpr size_t | Mask = BitsPerWord - 1 |
| | Mask for the bit index (63).
|
| static constexpr size_t | MaskShift = std::countr_one(Mask) |
| | Mask shift value for this word size.
|
A class for a dynamic bit mask specialised for fast, ordered iteration using the forEachSetBit method.
Definition at line 17 of file IdentifierMask.h.
◆ IdentifierMask()
| EventContainers::IdentifierMask::IdentifierMask |
( |
size_t | maxHash | ) |
|
|
inlineexplicit |
Definition at line 26 of file IdentifierMask.h.
static constexpr size_t BitsPerWord
Bits per storage unit (64).
std::vector< uint64_t > m_bits
static constexpr size_t Mask
Mask for the bit index (63).
◆ clear()
| void EventContainers::IdentifierMask::clear |
( |
| ) |
|
|
inline |
◆ count()
| size_t EventContainers::IdentifierMask::count |
( |
| ) |
const |
|
inline |
Return a count of the bits set to 1.
Definition at line 87 of file IdentifierMask.h.
87 {
88 size_t total = 0;
89 for (uint64_t word :
m_bits) total += std::popcount(word);
90 return total;
91 }
◆ forEachSetBit()
template<typename Func>
| void EventContainers::IdentifierMask::forEachSetBit |
( |
Func && | f | ) |
const |
|
inline |
Execute a lambda for every set bit The lambda should accept a size_t index.
Definition at line 60 of file IdentifierMask.h.
60 {
61 for (
size_t block_idx = 0; block_idx <
m_bits.size(); ++block_idx) {
63
64
65 while (word != 0) {
66
67
68 int bit_idx = std::countr_zero(word);
69
70
71
72
74
75
76
77
78 word &= (word - 1);
79 }
80 }
81 }
static constexpr size_t MaskShift
Mask shift value for this word size.
◆ set()
| void EventContainers::IdentifierMask::set |
( |
size_t | hash | ) |
|
|
inline |
◆ size()
| size_t EventContainers::IdentifierMask::size |
( |
| ) |
const |
|
inline |
◆ test()
| bool EventContainers::IdentifierMask::test |
( |
size_t | hash | ) |
const |
|
inline |
◆ unset()
| void EventContainers::IdentifierMask::unset |
( |
size_t | hash | ) |
|
|
inline |
◆ BitsPerWord
| size_t EventContainers::IdentifierMask::BitsPerWord = 64 |
|
staticconstexpr |
◆ m_bits
| std::vector<uint64_t> EventContainers::IdentifierMask::m_bits |
|
private |
◆ m_maxHash
| size_t EventContainers::IdentifierMask::m_maxHash |
|
private |
◆ Mask
| size_t EventContainers::IdentifierMask::Mask = BitsPerWord - 1 |
|
staticconstexpr |
◆ MaskShift
| size_t EventContainers::IdentifierMask::MaskShift = std::countr_one(Mask) |
|
staticconstexpr |
The documentation for this class was generated from the following file: