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/develop/src/axom/slam/BitSet.hpp>
Public Types | |
using | Index = int |
using | Word = std::uint64_t |
using | ArrayType = axom::Array< Word, 1 > |
Public Member Functions | |
BitSet (int numBits=0, int allocatorID=axom::getDefaultAllocatorID()) | |
BitSet class constructor. 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... | |
AXOM_HOST_DEVICE const Word * | data () const |
Gets the underlying data of a BitSet. More... | |
Bitset bitwise assignment operators | |
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 | |
AXOM_HOST_DEVICE 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... | |
Atomic versions of single-bit operations | |
void | atomicClear (Index idx) |
Clears bit at index idx. More... | |
AXOM_HOST_DEVICE void | atomicSet (Index idx) |
Sets bit at index idx. More... | |
void | atomicFlip (Index idx) |
Toggles bit at index idx. More... | |
Static Public Attributes | |
static constexpr Index | npos = -2 |
static constexpr int | BitsPerWord |
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 sentinel to indicate no more set bits.
using axom::slam::BitSet::Index = int |
using axom::slam::BitSet::Word = std::uint64_t |
using axom::slam::BitSet::ArrayType = axom::Array<Word, 1> |
|
inlineexplicit |
BitSet class constructor.
numBits | The number of bits in the bitset. |
References BitsPerWord, axom::Array< T, DIM, SPACE >::fill(), axom::utilities::max(), and SLIC_ASSERT_MSG.
bool axom::slam::BitSet::operator== | ( | const BitSet & | other | ) | const |
Equality operator for two bitsets.
|
inline |
Inequality operator for two bitsets.
References operator==().
|
inline |
Gets the underlying data of a BitSet.
References axom::Array< T, DIM, SPACE >::data().
Index axom::slam::BitSet::find_first | ( | ) | const |
Finds the index of the first bit that is set in the bitset.
Finds the index of the next set bit in the bitset after idx.
idx | The starting index |
|
inline |
Returns the cardinality of the bitset.
int axom::slam::BitSet::count | ( | ) | const |
Returns the number of bits that are set.
void axom::slam::BitSet::clear | ( | ) |
Clears all bits in the bitset.
void axom::slam::BitSet::set | ( | ) |
Sets all bits in the bitset.
void axom::slam::BitSet::flip | ( | ) |
Toggles all bits in the bitset.
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.
|
inline |
|
inline |
|
inline |
|
staticconstexpr |
|
staticconstexpr |