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 | |
Result< void, AllocationError > | init (mtcore::Allocator &allocator, const size_t height, const size_t width) |
Initializes a bitset to have a total number of bits All bits will be set to zero. | |
Result< void, BitStrInitError > | init (mtcore::Allocator &allocator, const Slice< const Slice< const char > > binaryStr) |
Initializes a bitset from a binary string of 1's and 0's. | |
Result< void, BitStrInitError > | init (mtcore::Allocator &allocator, const Slice< Slice< const char > > binaryStr) |
Initializes a bitset from a binary string of 1's and 0's. | |
Result< void, BitStrInitError > | init (mtcore::Allocator &allocator, const size_t height, const size_t width, const Slice< Slice< const char > > binaryStr) |
Initializes a bitset of a given size from a string Any bits not set by the string will be zero. | |
Result< void, BitStrInitError > | init (mtcore::Allocator &allocator, const size_t height, const size_t width, const Slice< const Slice< const char > > binaryStr) |
Initializes a bitset of a given size from a string Any bits not set by the string will be zero. | |
void | deinit (mtcore::Allocator &allocator) |
Deinitialies a bitset. | |
bool | operator[] (std::tuple< size_t, size_t > index) const |
Access an individual bit at a specific position. | |
BitsetAccess | operator[] (std::tuple< size_t, size_t > index) |
Access an individual bit at a specific position. | |
std::tuple< size_t, size_t > | size () const |
Gets the size of the bitset. | |
bool | at (size_t row, size_t col) const |
Reads a bit at a specific position. | |
Result< Bitset2D, AllocationError > | clone (mtcore::Allocator &allocator) |
Clones a bitset using a specific allocator. | |
Result< Bitset2D, AllocationError > | clone (mtcore::Allocator &allocator, const size_t newHeight, const size_t newWidth) |
Clones and resizes a bitset using a specific allocator. | |
Bitset2D & | set (size_t row, size_t col, bool val) |
Sets a bit at a position to a specific value. | |
Bitset2D & | toggle (size_t row, size_t col) |
Toggles a bit at a specific position. | |
Optional< std::tuple< size_t, 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. | |
Bitset2D & | operator&= (const Bitset2D &other) |
Bitset2D & | operator|= (const Bitset2D &other) |
Bitset2D & | operator^= (const Bitset2D &other) |
void | set_all (bool value) |
Sets all bits to a specific value. | |
Public Attributes | |
Bitset | underlying |
size_t | width |
size_t | height |
Represents a bitset with dynamically allocated memory (using an mtcore allocator) Allows operating on an arbitrary number of bits.
Definition at line 477 of file bitset.hpp.
|
inlinenodiscard |
Reads a bit at a specific position.
row | Bit row index to read |
col | Bit col index to read |
Definition at line 647 of file bitset.hpp.
|
inline |
Clones a bitset using a specific allocator.
allocator | Allocator to use for cloning |
Definition at line 659 of file bitset.hpp.
|
inline |
Clones and resizes a bitset using a specific allocator.
allocator | Allocator to use for cloning |
newHeight | New 2d array height |
newWidth | New 2d array width |
Definition at line 676 of file bitset.hpp.
|
inline |
Deinitialies a bitset.
allocator | Allocator to use for deinitialization |
Definition at line 589 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 724 of file bitset.hpp.
|
inline |
Initializes a bitset to have a total number of bits All bits will be set to zero.
allocator | Allocator to use for memory allocation |
height | 2d array height |
width | 2d array width |
Definition at line 489 of file bitset.hpp.
|
inline |
Initializes a bitset of a given size from a string Any bits not set by the string will be zero.
allocator | Allocator to use for memory allocation |
height | 2D array height |
width | 2D array width |
binaryStr | Binary string to use for initializing bits |
Definition at line 547 of file bitset.hpp.
|
inline |
Initializes a bitset of a given size from a string Any bits not set by the string will be zero.
allocator | Allocator to use for memory allocation |
height | 2D array height |
width | 2D array width |
binaryStr | Binary string to use for initializing bits |
Definition at line 534 of file bitset.hpp.
|
inline |
Initializes a bitset from a binary string of 1's and 0's.
allocator | Allocator to use for memory allocation |
binaryStr | Binary string to use for initializing bits |
Definition at line 508 of file bitset.hpp.
|
inline |
Initializes a bitset from a binary string of 1's and 0's.
allocator | Allocator to use for memory allocation |
binaryStr | Binary string to use for initializing bits |
Definition at line 522 of file bitset.hpp.
Definition at line 775 of file bitset.hpp.
|
inlinenodiscard |
Access an individual bit at a specific position.
index | Bit index to access |
Definition at line 629 of file bitset.hpp.
|
inlinenodiscard |
Access an individual bit at a specific position.
index | Bit index to access |
Definition at line 620 of file bitset.hpp.
Definition at line 803 of file bitset.hpp.
Definition at line 794 of file bitset.hpp.
|
inlinenodiscard |
Counts the number of set bits in the bitset.
Definition at line 739 of file bitset.hpp.
|
inline |
Sets a bit at a position to a specific value.
row | Bit row to set |
col | Bit col to set |
val | Bit value to set to |
Definition at line 697 of file bitset.hpp.
|
inline |
Sets all bits to a specific value.
value | to set to |
Definition at line 816 of file bitset.hpp.
|
inlinenodiscard |
Iterates over the indices of all set bits in the bitset.
Definition at line 773 of file bitset.hpp.
|
inlinenodiscard |
Gets the size of the bitset.
Definition at line 639 of file bitset.hpp.
|
inline |
Toggles a bit at a specific position.
row | Bit row to set |
col | Bit col to set |
Definition at line 711 of file bitset.hpp.
size_t mtcore::Bitset2D::height |
Definition at line 480 of file bitset.hpp.
Bitset mtcore::Bitset2D::underlying |
Definition at line 478 of file bitset.hpp.
size_t mtcore::Bitset2D::width |
Definition at line 479 of file bitset.hpp.