A drop-in replacement for std::vector<bool>, but with extra bitwise logic features.
More...
|
| BitVector (size_t in_num_bits=0, bool init_val=false) |
| Build a new BitVector with specified bit count (default 0) and initialization (default 0) More...
|
|
| BitVector (const BitVector &in_set) |
| Copy constructor of existing bit field. More...
|
|
| BitVector (BitVector &&in_set) |
| Move constructor of existing bit field. More...
|
|
| ~BitVector () |
| Destructor. More...
|
|
BitVector & | operator= (const BitVector &in_set) |
| Assignment operator. More...
|
|
BitVector & | operator= (BitVector &&in_set) |
| Move operator. More...
|
|
BitVector & | Resize (size_t new_bits) |
| Resize this BitVector to have the specified number of bits. More...
|
|
bool | operator== (const BitVector &in_set) const |
| Test if two bit vectors are identical. More...
|
|
bool | operator< (const BitVector &in_set) const |
| Compare the would-be numerical values of two bit vectors. More...
|
|
bool | operator<= (const BitVector &in_set) const |
| Compare the would-be numerical values of two bit vectors. More...
|
|
bool | operator!= (const BitVector &in_set) const |
| Determine if two bit vectors are different. More...
|
|
bool | operator> (const BitVector &in_set) const |
| Compare the would-be numerical values of two bit vectors. More...
|
|
bool | operator>= (const BitVector &in_set) const |
| Compare the would-be numerical values of two bit vectors. More...
|
|
size_t | GetSize () const |
| How many bits do we currently have? More...
|
|
bool | Get (size_t index) const |
| Retrive the bit value from the specified index. More...
|
|
void | Set (size_t index, bool value=true) |
| Update the bit value at the specified index. More...
|
|
std::size_t | Hash () const |
| A simple hash function for bit vectors. More...
|
|
uint8_t | GetByte (size_t index) const |
| Retrive the byte at the specified byte index. More...
|
|
void | SetByte (size_t index, uint8_t value) |
| Update the byte at the specified byte index. More...
|
|
uint32_t | GetUInt (size_t index) const |
| Retrive the 32-bit uint from the specifeid uint index. More...
|
|
void | SetUInt (size_t index, uint32_t value) |
| Update the 32-bit uint at the specified uint index. More...
|
|
uint32_t | GetUIntAtBit (size_t index) |
| Retrive the 32-bit uint at the specified BIT index. More...
|
|
template<size_t OUT_BITS> |
field_t | GetValueAtBit (size_t index) |
| Retrieve the specified number of bits (stored in the field type) at the target bit index. More...
|
|
bool | Any () const |
| Return true if ANY bits are set to 1, otherwise return false. More...
|
|
bool | None () const |
| Return true if NO bits are set to 1, otherwise return false. More...
|
|
bool | All () const |
| Return true if ALL bits are set to 1, otherwise return false. More...
|
|
| operator bool () const |
| Casting a bit array to bool identifies if ANY bits are set to 1. More...
|
|
bool | operator[] (size_t index) const |
| Const index operator – return the bit at the specified position. More...
|
|
BitProxy | operator[] (size_t index) |
| Index operator – return a proxy to the bit at the specified position so it can be an lvalue. More...
|
|
void | Clear () |
| Set all bits to 0. More...
|
|
void | SetAll () |
| Set all bits to 1. More...
|
|
void | Print (std::ostream &out=std::cout) const |
| Regular print function (from most significant bit to least) More...
|
|
void | PrintFields (std::ostream &out=std::cout, const std::string spacer=" ") const |
| Print a space between each field (or other provided spacer) More...
|
|
void | PrintArray (std::ostream &out=std::cout) const |
| Print from smallest bit position to largest. More...
|
|
void | PrintOneIDs (std::ostream &out=std::cout, std::string spacer=" ") const |
| Print the positions of all one bits, spaces are the default separator. More...
|
|
size_t | CountOnes_Sparse () const |
| Count 1's by looping through once for each bit equal to 1. More...
|
|
size_t | CountOnes_Mixed () const |
| Count 1's in semi-parallel; fastest for even 0's & 1's. More...
|
|
size_t | CountOnes () const |
| Count the number of ones in the BitVector. More...
|
|
int | FindBit () const |
| Return the position of the first one; return -1 if no ones in vector. More...
|
|
int | PopBit () |
| Return the position of the first one and change it to a zero. Return -1 if no ones. More...
|
|
int | FindBit (const size_t start_pos) const |
|
emp::vector< size_t > | GetOnes () const |
| Return positions of all ones. More...
|
|
BitVector | NOT () const |
| Perform a Boolean NOT on this BitVector and return the result. More...
|
|
BitVector | AND (const BitVector &set2) const |
| Perform a Boolean AND on this BitVector and return the result. More...
|
|
BitVector | OR (const BitVector &set2) const |
| Perform a Boolean OR on this BitVector and return the result. More...
|
|
BitVector | NAND (const BitVector &set2) const |
| Perform a Boolean NAND on this BitVector and return the result. More...
|
|
BitVector | NOR (const BitVector &set2) const |
| Perform a Boolean NOR on this BitVector and return the result. More...
|
|
BitVector | XOR (const BitVector &set2) const |
| Perform a Boolean XOR on this BitVector and return the result. More...
|
|
BitVector | EQU (const BitVector &set2) const |
| Perform a Boolean EQU on this BitVector and return the result. More...
|
|
BitVector & | NOT_SELF () |
| Perform a Boolean NOT with this BitVector, store result here, and return this object. More...
|
|
BitVector & | AND_SELF (const BitVector &set2) |
| Perform a Boolean AND with this BitVector, store result here, and return this object. More...
|
|
BitVector & | OR_SELF (const BitVector &set2) |
| Perform a Boolean OR with this BitVector, store result here, and return this object. More...
|
|
BitVector & | NAND_SELF (const BitVector &set2) |
| Perform a Boolean NAND with this BitVector, store result here, and return this object. More...
|
|
BitVector & | NOR_SELF (const BitVector &set2) |
| Perform a Boolean NOR with this BitVector, store result here, and return this object. More...
|
|
BitVector & | XOR_SELF (const BitVector &set2) |
| Perform a Boolean XOR with this BitVector, store result here, and return this object. More...
|
|
BitVector & | EQU_SELF (const BitVector &set2) |
| Perform a Boolean EQU with this BitVector, store result here, and return this object. More...
|
|
BitVector | SHIFT (const int shift_size) const |
| Positive shifts go left and negative go right (0 does nothing); return result. More...
|
|
BitVector & | SHIFT_SELF (const int shift_size) |
| Positive shifts go left and negative go right; store result here, and return this object. More...
|
|
BitVector | operator~ () const |
| Operator bitwise NOT... More...
|
|
BitVector | operator& (const BitVector &ar2) const |
| Operator bitwise AND... More...
|
|
BitVector | operator| (const BitVector &ar2) const |
| Operator bitwise OR... More...
|
|
BitVector | operator^ (const BitVector &ar2) const |
| Operator bitwise XOR... More...
|
|
BitVector | operator<< (const size_t shift_size) const |
| Operator shift left... More...
|
|
BitVector | operator>> (const size_t shift_size) const |
| Operator shift right... More...
|
|
const BitVector & | operator&= (const BitVector &ar2) |
| Compound operator bitwise AND... More...
|
|
const BitVector & | operator|= (const BitVector &ar2) |
| Compound operator bitwise OR... More...
|
|
const BitVector & | operator^= (const BitVector &ar2) |
| Compound operator bitwise XOR... More...
|
|
const BitVector & | operator<<= (const size_t shift_size) |
| Compound operator for shift left... More...
|
|
const BitVector & | operator>>= (const size_t shift_size) |
| Compound operator for shift right... More...
|
|
size_t | size () const |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
void | resize (std::size_t new_size) |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
bool | all () const |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
bool | any () const |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
bool | none () const |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
size_t | count () const |
| Function to allow drop-in replacement with std::vector<bool>. More...
|
|
A drop-in replacement for std::vector<bool>, but with extra bitwise logic features.
This class stores an arbirary number of bits in a set of "fields" (either 32-bit or 64-bit, depending on which should be faster.) Individual bits can be extracted, -or- bitwise logic (or bit magic) can be used on the groups of bits,