isomatch
|
#include <dyn_bitset.h>
Classes | |
class | Reference |
class | SizeMismatch |
Public Member Functions | |
DynBitset (size_t size) | |
size is expressed in bits. Initializes to zeroes. More... | |
DynBitset (const DynBitset &oth) | |
~DynBitset () | |
void | operator= (const DynBitset &oth) |
DynBitset & | operator= (DynBitset &&oth)=delete |
size_t | size () const |
bool | operator[] (size_t pos) const |
Constant bit access operator. More... | |
Reference | operator[] (size_t pos) |
Alterable bit reference. More... | |
DynBitset & | operator&= (const DynBitset &oth) |
DynBitset & | operator|= (const DynBitset &oth) |
In-place bitwise or. More... | |
DynBitset & | operator^= (const DynBitset &oth) |
In-place bitwise xor. More... | |
DynBitset & | flip () |
In-place bitwise flip. More... | |
DynBitset | operator& (const DynBitset &oth) const |
Bitwise AND of two DynBitset s. More... | |
DynBitset | operator| (const DynBitset &oth) const |
Bitwise OR of two DynBitset s. More... | |
DynBitset | operator^ (const DynBitset &oth) const |
Bitwise XOR of two DynBitset s. More... | |
DynBitset | operator~ () const |
Bitwise flip. More... | |
void | reset () |
Sets all bits to false. More... | |
bool | any () const |
Checks if any bit is true. More... | |
bool | anyOver (size_t pos) const |
Checks if any bit above the pos th (incl.) is true. More... | |
int | singleBit () const |
Checks if a single bit is set. More... | |
std::string | dump () const |
Dumps the DynBitset to an hex representation. More... | |
Friends | |
class | Reference |
Dynamically sized bitset
Makes up for the lack of a std::bitset
equivalent that can have runtime-defined size. std::vector<bool>
does not support efficient bitwise operations, and is not well-defined apart from "more space-efficient" (leaves a great deal of liberty to the implementation).
The size of the bitset must be known at allocation time, and cannot be changed afterwards (apart from copying the bitset to a freshly allocated one).
DynBitset::DynBitset | ( | size_t | size | ) |
size
is expressed in bits. Initializes to zeroes.
DynBitset::DynBitset | ( | const DynBitset & | oth | ) |
DynBitset::~DynBitset | ( | ) |
bool DynBitset::any | ( | ) | const |
Checks if any bit is true.
bool DynBitset::anyOver | ( | size_t | pos | ) | const |
Checks if any bit above the pos
th (incl.) is true.
std::string DynBitset::dump | ( | ) | const |
Dumps the DynBitset to an hex representation.
DynBitset & DynBitset::flip | ( | ) |
In-place bitwise flip.
void DynBitset::operator= | ( | const DynBitset & | oth | ) |
|
inline |
Constant bit access operator.
DynBitset::Reference DynBitset::operator[] | ( | size_t | pos | ) |
Alterable bit reference.
In-place bitwise and
DynBitset DynBitset::operator~ | ( | ) | const |
Bitwise flip.
void DynBitset::reset | ( | ) |
Sets all bits to false.
int DynBitset::singleBit | ( | ) | const |
Checks if a single bit is set.
Checks whether a single bit is set. If so, returns this bit's position; if no or multiple bits are set, returns -1.
|
inline |
|
friend |