|
FE 0.13.1
Header-only C++ frontend library
|
A dynamically growing set of bits with small storage optimization. More...
#include <fe/bitset.h>
Classes | |
| class | reference |
| Proxy that Bitset::operator[] hands out to read/write the bit it refers to. More... | |
| class | iterator |
| Iterates over the indices of all set bits in ascending order. More... | |
| struct | Hash |
Public Member Functions | |
Access | |
| constexpr bool | test (size_t i) const noexcept |
| constexpr bool | operator[] (size_t i) const noexcept |
| constexpr reference | operator[] (size_t i) noexcept |
| constexpr size_t | next (size_t i) const noexcept |
Index of the first bit that is set at or after i - or npos, if there is none. | |
Modifiers | |
Bitset::set and Bitset::flip grow the storage as needed; the others never allocate. | |
| constexpr Bitset & | set (size_t i) |
| constexpr Bitset & | set (size_t i, bool b) |
| constexpr Bitset & | flip (size_t i) |
| constexpr Bitset & | clear (size_t i) noexcept |
| constexpr Bitset & | clear () noexcept |
| Clears all bits and releases the heap storage again. | |
Queries | |
| constexpr size_t | count () const noexcept |
| constexpr bool | any () const noexcept |
| constexpr bool | none () const noexcept |
| constexpr size_t | capacity () const noexcept |
| Number of bits available without growing. | |
| constexpr bool | on_heap () const noexcept |
| Outgrown the inline storage? | |
Comparisons | |
The bits beyond Bitset::capacity are all zero, so a different capacity does not make two Bitsets differ. | |
| constexpr bool | operator== (const Bitset &other) const noexcept |
| constexpr bool | subset_of (const Bitset &other) const noexcept |
Is every bit set in this also set in other? | |
| constexpr bool | intersects (const Bitset &other) const noexcept |
Do this and other have at least one bit in common? | |
Iterators | |
Yield the index of each set bit in ascending order. | |
| constexpr iterator | begin () const noexcept |
| constexpr iterator | end () const noexcept |
Hash | |
| constexpr size_t | hash () const noexcept |
Static Public Attributes | |
| static constexpr size_t | Bits_Per_Word = sizeof(uint64_t) * 8 |
| Number of bits in one word. | |
| static constexpr size_t | Inline_Bits = Bits_Per_Word |
| Number of bits available without allocating. | |
| static constexpr size_t | npos = size_t(-1) |
| Returned by Bitset::next if there is no set bit. | |
Constructors, Destructor, Assignment | |
| constexpr | Bitset () noexcept=default |
| constexpr | Bitset (std::initializer_list< size_t > bits) |
| constexpr | Bitset (const Bitset &other) |
| constexpr | Bitset (Bitset &&other) noexcept |
| constexpr | ~Bitset () noexcept |
| constexpr Bitset & | operator= (Bitset other) noexcept |
| constexpr void | swap (Bitset &b1, Bitset &b2) noexcept |
Set Operations | |
Union, intersection, symmetric difference, and difference. | |
| constexpr Bitset & | operator|= (const Bitset &other) |
| constexpr Bitset & | operator&= (const Bitset &other) noexcept |
| constexpr Bitset & | operator^= (const Bitset &other) |
| constexpr Bitset & | operator-= (const Bitset &other) noexcept |
| constexpr Bitset | operator| (Bitset b1, const Bitset &b2) |
| constexpr Bitset | operator& (Bitset b1, const Bitset &b2) |
| constexpr Bitset | operator^ (Bitset b1, const Bitset &b2) |
| constexpr Bitset | operator- (Bitset b1, const Bitset &b2) |
Output | |
| void | dump () const |
| std::ostream & | operator<< (std::ostream &os, const Bitset &bitset) |
A dynamically growing set of bits with small storage optimization.
The first Bitset::Inline_Bits bits live inside the Bitset itself; only beyond that it allocates on the heap. Think of a Bitset as an infinite sequence of bits that are zero except for the ones you set: Bitset::set/Bitset::flip grow the storage on demand, while testing or clearing a bit beyond Bitset::capacity needs no storage at all.
|
constexprdefaultnoexcept |
Referenced by Bitset(), Bitset(), Bitset(), clear(), clear(), flip(), intersects(), operator&, operator&=(), fe::Bitset::Hash::operator()(), operator-, operator-=(), operator<<, operator=(), operator==(), operator^, operator^=(), operator|, operator|=(), set(), set(), subset_of(), and swap.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Number of bits available without growing.
Definition at line 188 of file bitset.h.
References Bits_Per_Word.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 164 of file bitset.h.
References Bits_Per_Word, and Bitset().
Referenced by set().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexpr |
Definition at line 159 of file bitset.h.
References Bits_Per_Word, and Bitset().
|
inlinenodiscardconstexprnoexcept |
Definition at line 265 of file bitset.h.
References fe::hash_begin(), and fe::hash_combine().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
Index of the first bit that is set at or after i - or npos, if there is none.
Definition at line 138 of file bitset.h.
References Bits_Per_Word, and npos.
Referenced by begin().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexpr |
Definition at line 153 of file bitset.h.
References Bits_Per_Word, and Bitset().
Referenced by Bitset().
|
inlineconstexpr |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Returned by Bitset::next if there is no set bit.
Definition at line 32 of file bitset.h.
Referenced by next(), and fe::Bitset::iterator::operator++().