Class BitVector
Defined in File BitVector.h
Class Documentation
-
class BitVector
a vector of bits packed in words of 64 bits
Public Types
-
using value_type = bool
-
using size_type = std::size_t
-
using difference_type = std::ptrdiff_t
-
using reference = bool
-
using const_reference = bool
-
using const_iterator = SubscriptIterator<BitVector, bool>
-
using iterator = const_iterator
Public Functions
-
BitVector(void) = default
-
explicit BitVector(std::size_t n, bool b = false)
n bits equal to b
-
explicit BitVector(std::string_view s)
the bits written in s, the bit 0 first
- Pre:
s has only the characters ‘0’ and ‘1’
-
BitVector(std::span<const Word> w, std::size_t n)
the n bits of the words w, the bit i in the bit i mod 64 of the word i / 64 as in words()
- Pre:
w holds ( n + 63 ) / 64 words at least
-
std::size_t size(void) const
-
bool empty(void) const
-
void set(std::size_t i, bool b = true)
writes b in the bit i
- Pre:
i < size()
- Post:
( *this )[ i ] == b
-
void push_back(bool b)
appends the bit b
- Post:
the size grows by 1 and the last bit is b
-
void append(Word v, int len)
appends the len bits of v, its bit 0 first
- Pre:
len <= 64 and v < 2^len
- Post:
get( size() - len , len ) == v
-
Word get(std::size_t i, int len) const
the len bits from the place i, the bit i in the bit 0 of the result
- Pre:
len <= 64 and i + len <= size()
-
void put(std::size_t i, Word v, int len)
writes the len bits of v from the place i, its bit 0 in the bit i
- Pre:
len <= 64, v < 2^len and i + len <= size()
- Post:
get( i , len ) == v
-
std::size_t count(void) const
the number of 1 bits, in O( n / 64 ) time
-
const Words &words(void) const
the words, the bits past the size being 0; they are at least size() / 64 + 2, a multiple of 8, and start on a line of the cache
-
std::string toString(void) const
the bits as a string of ‘0’ and ‘1’, the bit 0 first
-
void reserve(std::size_t n)
room for n bits
-
void clear(void)
no bit
-
inline const_iterator begin(void) const
-
inline const_iterator end(void) const
-
inline const_iterator cbegin(void) const
-
inline const_iterator cend(void) const
-
using value_type = bool