AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
A bitset class. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.5.0/src/axom/slam/BitSet.hpp>
Public Types | |
using | Index = int |
using | Word = axom::uint64 |
using | ArrayType = std::vector< Word > |
Public Member Functions | |
BitSet (int numBits=0) | |
BitSet class constructor. More... | |
BitSet (const BitSet &other) | |
Copy constructor for BitSet class. More... | |
bool | operator== (const BitSet &other) const |
Equality operator for two bitsets. More... | |
bool | operator!= (const BitSet &other) const |
Inequality operator for two bitsets. More... | |
Bitset bitwise assignment operators | |
BitSet & | operator= (const BitSet &other) |
Assignment operator for BitSet class. More... | |
BitSet & | operator|= (const BitSet &other) |
BitSet union-assignment operator. More... | |
BitSet & | operator &= (const BitSet &other) |
BitSet intersection-assignment operator. More... | |
BitSet & | operator^= (const BitSet &other) |
BitSet exclusive-or-assignment operator. More... | |
BitSet & | operator-= (const BitSet &other) |
BitSet difference-assignment operator. More... | |
Bitset iteration interface | |
Index | find_first () const |
Finds the index of the first bit that is set in the bitset. More... | |
Index | find_next (Index idx) const |
Finds the index of the next set bit in the bitset after idx. More... | |
Operations that affect all bits in the bitset | |
int | size () const |
Returns the cardinality of the bitset. More... | |
int | count () const |
Returns the number of bits that are set. More... | |
void | clear () |
Clears all bits in the bitset. More... | |
void | set () |
Sets all bits in the bitset. More... | |
void | flip () |
Toggles all bits in the bitset. More... | |
bool | isValid () const |
Checks if the bitset instance is valid. More... | |
Operations that affect a single bits in the bitset | |
void | clear (Index idx) |
Clears bit at index idx. More... | |
void | set (Index idx) |
Sets bit at index idx. More... | |
void | flip (Index idx) |
Toggles bit at index idx. More... | |
bool | test (Index idx) const |
Tests the bit at index idx. More... | |
Static Public Attributes | |
static const Index | npos |
A bitset class.
This class supports bitwise manipulation operations (e.g. set intersection, union and difference) on an ordered set of bits. The class has a similar interface to std::bitset and boost::dynamic_bitset, but with the following differences:
The individual bits in the bitset are packed into a contiguous array of Words (an unsigned integer type). Many bitset operations such as count() and flip() are performed at the granularity of a word.
BitSet uses the same interface as boost::dynamic_bitset to enumerate the set bits. Specifically, find_first() returns the index of the first set bit. and find_next(idx) returns the next bit that is set after bit index idx. BitSet::npos is used as a sentinal to indicate no more set bits.
using axom::slam::BitSet::Index = int |
using axom::slam::BitSet::Word = axom::uint64 |
using axom::slam::BitSet::ArrayType = std::vector<Word> |
|
inlineexplicit |
BitSet class constructor.
numBits | The number of bits in the bitset. |
References axom::utilities::max(), and SLIC_ASSERT_MSG.
|
inline |
Copy constructor for BitSet class.
References operator==().
bool axom::slam::BitSet::operator== | ( | const BitSet & | other | ) | const |
Equality operator for two bitsets.
Referenced by BitSet(), and operator!=().
|
inline |
Inequality operator for two bitsets.
References operator==().
Assignment operator for BitSet class.
References find_first(), find_next(), operator &=(), operator-=(), operator^=(), and operator|=().
BitSet union-assignment operator.
other | The other bitset |
Set union of the current instance and other. The i^th bit will be set if it is set in this bitset or in other
Referenced by operator=().
BitSet intersection-assignment operator.
other | The other bitset |
Set intersection of the current instance and other. The i^th bit will be set if it is set in this bitset and in other
Referenced by operator=().
BitSet exclusive-or-assignment operator.
other | The other bitset |
Set exclusive-or of the current instance and other. The i^th bit will be set if it is set in this bitset or in other, but not both.
Referenced by operator=().
BitSet difference-assignment operator.
other | The other bitset |
Set difference of the current instance and other. The i^th bit will be set if it is set in this bitset and not in other
Referenced by operator=().
Index axom::slam::BitSet::find_first | ( | ) | const |
Finds the index of the first bit that is set in the bitset.
Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidatesAsArray(), and operator=().
Finds the index of the next set bit in the bitset after idx.
idx | The starting index |
Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidatesAsArray(), and operator=().
|
inline |
int axom::slam::BitSet::count | ( | ) | const |
Returns the number of bits that are set.
Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::getCandidatesAsArray(), and size().
void axom::slam::BitSet::clear | ( | ) |
Clears all bits in the bitset.
Referenced by size().
void axom::slam::BitSet::set | ( | ) |
Sets all bits in the bitset.
void axom::slam::BitSet::flip | ( | ) |
Toggles all bits in the bitset.
Referenced by size().
bool axom::slam::BitSet::isValid | ( | ) | const |
|
inline |
Clears bit at index idx.
|
inline |
Sets bit at index idx.
|
inline |
Toggles bit at index idx.
|
inline |
Tests the bit at index idx.
References AXOM_DEBUG_VAR, and SLIC_ASSERT_MSG.
|
static |