Bitcoin Core 28.99.0
P2P Digital Currency
|
A bitset implementation backed by a single integer of type I. More...
#include <bitset.h>
Classes | |
class | Iterator |
Iterator type returned by begin(), which efficiently iterates all 1 positions. More... | |
class | IteratorEnd |
Dummy type to return using end(). More... | |
Public Member Functions | |
constexpr | IntBitSet () noexcept |
Construct an all-zero bitset. More... | |
constexpr | IntBitSet (const IntBitSet &) noexcept=default |
Copy construct a bitset. More... | |
constexpr | IntBitSet (std::initializer_list< unsigned > ilist) noexcept |
Construct from a list of values. More... | |
constexpr IntBitSet & | operator= (const IntBitSet &) noexcept=default |
Copy assign a bitset. More... | |
constexpr IntBitSet & | operator= (std::initializer_list< unsigned > ilist) noexcept |
Assign from a list of positions (which will be made true, all others false). More... | |
constexpr void | Set (unsigned pos) noexcept |
Set a bit to 1. More... | |
constexpr void | Set (unsigned pos, bool val) noexcept |
Set a bit to the specified value. More... | |
constexpr void | Reset (unsigned pos) noexcept |
Set a bit to 0. More... | |
constexpr bool | operator[] (unsigned pos) const noexcept |
Retrieve a bit at the given position. More... | |
constexpr unsigned | Count () const noexcept |
Compute the number of 1 bits in the bitset. More... | |
constexpr bool | None () const noexcept |
Check if all bits are 0. More... | |
constexpr bool | Any () const noexcept |
Check if any bits are 1. More... | |
constexpr Iterator | begin () const noexcept |
Return an object that iterates over all 1 bits (++ and * only allowed when != end()). More... | |
constexpr IteratorEnd | end () const noexcept |
Return a dummy object to compare Iterators with. More... | |
constexpr unsigned | First () const noexcept |
Find the first element (requires Any()). More... | |
constexpr unsigned | Last () const noexcept |
Find the last element (requires Any()). More... | |
constexpr IntBitSet & | operator|= (const IntBitSet &a) noexcept |
Set this object's bits to be the binary AND between respective bits from this and a. More... | |
constexpr IntBitSet & | operator&= (const IntBitSet &a) noexcept |
Set this object's bits to be the binary OR between respective bits from this and a. More... | |
constexpr IntBitSet & | operator-= (const IntBitSet &a) noexcept |
Set this object's bits to be the binary AND NOT between respective bits from this and a. More... | |
constexpr IntBitSet & | operator^= (const IntBitSet &a) noexcept |
Set this object's bits to be the binary XOR between respective bits from this as a. More... | |
constexpr bool | Overlaps (const IntBitSet &a) const noexcept |
Check if the intersection between two sets is non-empty. More... | |
constexpr bool | IsSupersetOf (const IntBitSet &a) const noexcept |
Check if bitset a is a superset of bitset b (= every 1 bit in b is also in a). More... | |
constexpr bool | IsSubsetOf (const IntBitSet &a) const noexcept |
Check if bitset a is a subset of bitset b (= every 1 bit in a is also in b). More... | |
Static Public Member Functions | |
static constexpr IntBitSet | Singleton (unsigned i) noexcept |
Construct a bitset with the singleton i. More... | |
static constexpr IntBitSet | Fill (unsigned count) noexcept |
Construct a bitset with bits 0..count-1 (inclusive) set to 1. More... | |
static constexpr unsigned | Size () noexcept |
Return the number of bits that this object holds. More... | |
Private Member Functions | |
IntBitSet (I val) noexcept | |
Internal constructor with a given integer as contents. More... | |
Private Attributes | |
I | m_val |
Integer whose bits represent this bitset. More... | |
Static Private Attributes | |
static constexpr unsigned | MAX_SIZE = std::numeric_limits<I>::digits |
The maximum number of bits this bitset supports. More... | |
Friends | |
constexpr IntBitSet | operator& (const IntBitSet &a, const IntBitSet &b) noexcept |
Return an object with the binary AND between respective bits from a and b. More... | |
constexpr IntBitSet | operator| (const IntBitSet &a, const IntBitSet &b) noexcept |
Return an object with the binary OR between respective bits from a and b. More... | |
constexpr IntBitSet | operator- (const IntBitSet &a, const IntBitSet &b) noexcept |
Return an object with the binary AND NOT between respective bits from a and b. More... | |
constexpr IntBitSet | operator^ (const IntBitSet &a, const IntBitSet &b) noexcept |
Return an object with the binary XOR between respective bits from a and b. More... | |
constexpr bool | operator== (const IntBitSet &a, const IntBitSet &b) noexcept=default |
Check if bitset a and bitset b are identical. More... | |
constexpr void | swap (IntBitSet &a, IntBitSet &b) noexcept |
Swap two bitsets. More... | |
A bitset implementation backed by a single integer of type I.
|
inlineprivatenoexcept |
|
inlineconstexprnoexcept |
|
constexprdefaultnoexcept |
Copy construct a bitset.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
constexprdefaultnoexcept |
Copy assign a bitset.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
|
friend |
Check if bitset a and bitset b are identical.
|
private |
|
staticconstexprprivate |