Celeritas
0.5.0-86+4a8eea4
|
Device-compatible bitset implementation. More...
#include <Bitset.hh>
Classes | |
class | reference |
Reference to a single bit in the bitset. More... | |
Public Types | |
Type aliases | |
using | word_type = unsigned int |
Public Member Functions | |
CELER_CONSTEXPR_FUNCTION | Bitset (word_type value) noexcept |
Construct from a word value. | |
CELER_CONSTEXPR_FUNCTION bool | operator== (Bitset const &other) const noexcept |
Compare for equality. | |
CELER_CONSTEXPR_FUNCTION bool | operator!= (Bitset const &other) const noexcept |
Compare for inequality. | |
CELER_CONSTEXPR_FUNCTION bool | operator[] (size_type pos) const noexcept(!CELERITAS_DEBUG) |
Access a single bit. | |
CELER_CONSTEXPR_FUNCTION reference | operator[] (size_type pos) noexcept(!CELERITAS_DEBUG) |
Mutable access to a single bit. | |
CELER_CONSTEXPR_FUNCTION bool | all () const noexcept |
Check if all bits are set. | |
CELER_CONSTEXPR_FUNCTION bool | any () const noexcept |
Check if any bits are set. | |
CELER_CONSTEXPR_FUNCTION bool | none () const noexcept |
Check if no bits are set. | |
CELER_CONSTEXPR_FUNCTION size_type | count () const noexcept |
Number of bits set to true. | |
CELER_CONSTEXPR_FUNCTION size_type | size () const noexcept |
Number of bits in the bitset. | |
CELER_CONSTEXPR_FUNCTION Bitset & | operator&= (Bitset const &other) noexcept |
Bitwise AND with another bitset. | |
CELER_CONSTEXPR_FUNCTION Bitset & | operator|= (Bitset const &other) noexcept |
Bitwise OR with another bitset. | |
CELER_CONSTEXPR_FUNCTION Bitset & | operator^= (Bitset const &other) noexcept |
Bitwise XOR with another bitset. | |
CELER_CONSTEXPR_FUNCTION Bitset | operator~ () const noexcept |
Return a copy with all bits flipped (bianry NOT) | |
CELER_CONSTEXPR_FUNCTION Bitset & | set () noexcept |
Set all bits. | |
CELER_CONSTEXPR_FUNCTION Bitset & | set (size_type pos, bool value=true) noexcept(!CELERITAS_DEBUG) |
Set the bit at position pos. | |
CELER_CONSTEXPR_FUNCTION Bitset & | reset () noexcept |
Reset all bits. | |
CELER_CONSTEXPR_FUNCTION Bitset & | reset (size_type pos) noexcept(!CELERITAS_DEBUG) |
Reset the bit at position pos. | |
CELER_CONSTEXPR_FUNCTION Bitset & | flip () noexcept |
Flip all bits. | |
CELER_CONSTEXPR_FUNCTION Bitset & | flip (size_type pos) noexcept(!CELERITAS_DEBUG) |
Flip the bit at position pos. | |
Device-compatible bitset implementation.
This implementation is based on libstdc++'s std::bitset implementation. It it a subset of the C++ standard, but it should be sufficient for our current use case. Given that GPU typically use 32-bit words, this uses unsigned int as the word type instead of the unsigned long used by the standard library. This container is not thread-safe, multiple threads are likely to manipulate the same word, even we accessing different indices.
The following methods are not implemented: