pasta_bit_vector
1.0.1
Bit Vector with Compact and Fast Rank and Select Support
|
Uncompressed, highly tuned, fixed size bit vector. More...
#include <bit_vector.hpp>
Classes | |
struct | Iterator |
Custom iterator for BitVector . More... | |
Public Types | |
using | RawDataType = uint64_t |
Type that is used to store the raw data of the bit vector. | |
using | RawDataPointer = RawDataType* |
using | RawDataConstAccess = RawDataType const* |
Public Member Functions | |
BitVector ()=default | |
Default empty constructor. | |
BitVector (BitVector &&)=default | |
Default move constructor. | |
BitVector (BitVector const &)=default | |
Default copy constructor. | |
BitVector & | operator= (BitVector const &)=delete |
BitVector & | operator= (BitVector &&)=default |
Default move assignment. | |
BitVector (size_t const size) noexcept | |
Constructor. Creates a bit vector that holds a specific, fixed number of bits. | |
BitVector (size_t const size, bool const init_value) noexcept | |
Constructor. Creates a bit vector that holds a specific, fixed number of bits set to a default value. | |
BitAccess | operator[] (size_t const index) noexcept |
Access operator to read/write to a bit of the bit vector. | |
BitAccess | operator[] (size_t const index) const noexcept |
Access operator to read to a bit of the bit vector. | |
void | resize (size_t const size) noexcept |
Resize the bit vector to contain size bits. | |
void | resize (size_t const size, bool const init_value) noexcept |
Resize the bit vector to contain size bits and fill new bits with default value. | |
Iterator | begin () noexcept |
Get iterator representing the first element of the BitVector . | |
Iterator | end () noexcept |
Get iterator representing the end of the BitVector . | |
std::span< uint64_t > | data () noexcept |
Direct access to the raw data of the bit vector. | |
std::span< uint64_t > | data () const noexcept |
Direct access to the raw data of the bit vector. | |
uint64_t | data (size_t const index) const noexcept |
Direct access to one 64-bit element of the raw data of the bit vector. | |
size_t | space_usage () const |
Estimate for the space usage. | |
size_t | size () const noexcept |
Get the size of the bit vector in bits. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, BitVector const &bv) |
formatted output of the BitVector | |
Uncompressed, highly tuned, fixed size bit vector.
The uncompressed bit vector can be used as a replacement for std::vector<bool>
, when the size of the vector is known in advance. It provides an access operator.
Important: If you plan on accessing the data directly, note that the bits are stored in reverse order in the 64-bit words. This saves an subtraction, when shifting the bits for access. To be more precise, the bits are stored as follows (for simplicity, we show it for 8-bit words):
| 7 6 5 4 3 2 1 0 | 15 14 13 12 11 10 9 8 | 23 22 21 20 19 18 17 16 | ...
using pasta::BitVector::RawDataConstAccess = RawDataType const* |
Type that can be used to access constant values of the raw data used to represent the bit vector.
Pointer to the data type that is used to store the raw data of the bit vector.
|
inlinenoexcept |
Constructor. Creates a bit vector that holds a specific, fixed number of bits.
size | Number of bits the bit vector contains. |
|
inlinenoexcept |
Constructor. Creates a bit vector that holds a specific, fixed number of bits set to a default value.
size | Number of bits the bit vector contains. |
init_value | Value all bits initially are set to. Either 0 (false ) or 1 (true ). |
|
inlinenoexcept |
|
inlinenoexcept |
Direct access to the raw data of the bit vector.
Note that the raw data does not contain the bits from left to right. A detailed description can be found at the top of this file.
std::span<uint64_t>
pointing to the bit vector's raw data.
|
inlinenoexcept |
Direct access to the raw data of the bit vector.
Note that the raw data does not contain the bits from left to right. A detailed description can be found at the top of this file.
std::span<uint64_t>
pointing to the bit vector's raw data.
|
inlinenoexcept |
Direct access to one 64-bit element of the raw data of the bit vector.
Note that the raw data does not contain the bits from left to right. A detailed description can be found at the top of this file.
index | Index of the 64-bit bit word that should be returned. |
|
inlinenoexcept |
Deleted copy assignment, due to SimpleVector
not supporting copy assignment.
|
inlinenoexcept |
Access operator to read to a bit of the bit vector.
index | Index of the bit to be read to in the bit vector. |
BitAccess
that allows to read access to a single bit.
|
inlinenoexcept |
Access operator to read/write to a bit of the bit vector.
index | Index of the bit to be read/write to in the bit vector. |
BitAccess
that allows to access to a single bit.
|
inlinenoexcept |
Resize the bit vector to contain size
bits.
size | Number of bits the resized bit vector contains. |
|
inlinenoexcept |
Resize the bit vector to contain size
bits and fill new bits with default value.
size | Number of bits the resized bit vector contains. |
init_value | Value all bits that are appended to the bit vector (if any) will have. |
|
inlinenoexcept |
Get the size of the bit vector in bits.
|
inlinenodiscard |
Estimate for the space usage.