MT Core (C++)
Core library for replacing C++ standard in project usage
|
Represents a bitset with dynamically allocated memory (using an mtcore allocator) Allows operating on an arbitrary number of bits. More...
#include <bitset.hpp>
Classes | |
struct | BitsetAccess |
Helper for accessing a bitset position (including for setting bits) More... | |
struct | SetBitIter |
Simple bit set iterator that uses next() iteration to return the indices of all set bits. More... | |
Public Member Functions | |
void | init (u64 val) |
Result< void, BitStrInitError > | init (const Slice< const char > binaryStr) |
Initializes a bitset from a binary string of 1's and 0's. | |
BitsetAccess | operator[] (const size_t index) |
Access an individual bit at a specific position. | |
bool | operator[] (const size_t index) const |
Access an individual bit at a specific position. | |
constexpr size_t | size () const |
Gets the size of the bitset. | |
bool | at (const size_t pos) const |
Reads a bit at a specific position. | |
BitsetFixed & | set (const size_t pos, const bool val) |
Sets a bit at a position to a specific value. | |
Bitset & | toggle (const size_t pos) |
Toggles a bit at a specific position. | |
Optional< size_t > | last_set () const |
Returns the position of the last set bit (if one is set) Otherwise, returns a null Optional. | |
Optional< size_t > | first_set () const |
Returns the position of the first set bit (if one is set) Otherwise, returns a null Optional. | |
size_t | pop_count () const |
Counts the number of set bits in the bitset. | |
SetBitIter | set_bits () const |
Iterates over the indices of all set bits in the bitset. | |
BitsetFixed & | operator&= (const BitsetFixed &other) |
BitsetFixed & | operator|= (const BitsetFixed &other) |
BitsetFixed & | operator^= (const BitsetFixed &other) |
void | set_all (const bool value) |
Sets all bits to a specific value. | |
BitsetFixed & | operator<<= (const size_t amount) |
BitsetFixed & | operator>>= (const size_t amount) |
Public Attributes | |
std::array< u64,(NumBits+63)/64 > | bytes = {0} |
Slice< u64 > | bits = mut_slice_from(bytes) |
Represents a bitset with dynamically allocated memory (using an mtcore allocator) Allows operating on an arbitrary number of bits.
Definition at line 826 of file bitset.hpp.
|
inlinenodiscard |
Reads a bit at a specific position.
pos | Bit index to read |
Definition at line 912 of file bitset.hpp.
|
inlinenodiscard |
Returns the position of the first set bit (if one is set) Otherwise, returns a null Optional.
Definition at line 974 of file bitset.hpp.
|
inline |
Initializes a bitset from a binary string of 1's and 0's.
binaryStr | Binary string to use for initializing bits |
Definition at line 841 of file bitset.hpp.
|
inline |
|
inlinenodiscard |
Returns the position of the last set bit (if one is set) Otherwise, returns a null Optional.
Definition at line 959 of file bitset.hpp.
|
inline |
Definition at line 1027 of file bitset.hpp.
|
inline |
Definition at line 1070 of file bitset.hpp.
|
inline |
Definition at line 1105 of file bitset.hpp.
|
inlinenodiscard |
|
inlinenodiscard |
Access an individual bit at a specific position.
index | Bit index to access |
Definition at line 899 of file bitset.hpp.
|
inline |
|
inline |
|
inlinenodiscard |
|
inline |
Sets a bit at a position to a specific value.
pos | Bit index to set |
val | Bit value to set to |
Definition at line 925 of file bitset.hpp.
|
inline |
Sets all bits to a specific value.
value | to set to |
Definition at line 1056 of file bitset.hpp.
|
inlinenodiscard |
Iterates over the indices of all set bits in the bitset.
Definition at line 1025 of file bitset.hpp.
|
inlinenodiscardconstexpr |
Gets the size of the bitset.
Definition at line 905 of file bitset.hpp.
|
inline |
Toggles a bit at a specific position.
pos | Bit index to toggle |
Definition at line 945 of file bitset.hpp.
Slice<u64> mtcore::BitsetFixed< NumBits >::bits = mut_slice_from(bytes) |
Definition at line 828 of file bitset.hpp.
std::array<u64, (NumBits + 63) / 64> mtcore::BitsetFixed< NumBits >::bytes = {0} |
Definition at line 827 of file bitset.hpp.