b-tree-plus-alpha
|
A dynamic data structure supporting rank and select queries on a bit sequence. More...
#include <dynamic_bit_sequence.hpp>
Public Member Functions | |
DynamicBitSequence (const DynamicBitSequence &)=delete | |
Deleted copy constructor. | |
DynamicBitSequence () | |
Default constructor initializes the tree with default degree. | |
DynamicBitSequence & | operator= (const DynamicBitSequence &)=delete |
Deleted copy assignment operator. | |
DynamicBitSequence (DynamicBitSequence &&) noexcept=default | |
Default move constructor. | |
DynamicBitSequence & | operator= (DynamicBitSequence &&) noexcept=default |
Default move assignment operator. | |
Properties | |
The properties of this class. | |
uint64_t | size () const |
Returns the size of the bit sequence. | |
uint64_t | size_in_bytes () const |
Returns the size of the bit sequence in bytes. | |
Queries | |
The queries supported this data structure. | |
bool | empty () const |
Checks if the bit sequence is empty. | |
bool | at (uint64_t pos) const |
Returns the bit at the specified position. | |
int64_t | rank1 (uint64_t i) const |
Returns the number of 1s up to position i. | |
int64_t | rank0 (uint64_t i) const |
Returns the number of 0s up to position i. | |
int64_t | rank (uint64_t i, bool c) const |
Returns the number of bits with value c up to position i. | |
int64_t | select1 (uint64_t i) const |
Returns the position of the i-th 1. | |
int64_t | select0 (uint64_t i) const |
Returns the position of the i-th 0. | |
int64_t | select (uint64_t i, bool c) const |
Returns the position of the i-th bit with value c. | |
int64_t | count_c (bool c) const |
Returns the number of bits with value c in the sequence. | |
bool | operator[] (uint64_t n) const |
Returns the bit at the specified position. | |
uint64_t | psum (uint64_t x) const |
Returns the prefix sum up to position x. | |
uint64_t | psum () const |
Returns the total prefix sum. | |
int64_t | search (uint64_t sum) const |
Searches for the position where the prefix sum equals sum. | |
Update operations | |
The update operations supported this data structure. | |
void | set_degree (uint64_t degree) |
Sets the degree of the tree. | |
void | swap (DynamicBitSequence &item) |
Swaps the contents of this sequence with another. | |
void | clear () |
Clears the bit sequence. | |
void | push_back (bool value) |
Adds a bit to the end of the sequence. | |
void | push_front (bool value) |
Adds a bit to the beginning of the sequence. | |
void | insert (uint64_t pos, bool value) |
Inserts a bit at the specified position. | |
void | remove (uint64_t pos) |
Removes the bit at the specified position. | |
void | set_bit (uint64_t i, bool b) |
Sets the bit at the specified position. | |
void | sort_leaf_containers () |
Sorts the leaf containers. | |
void | push_many (const std::vector< bool > &items) |
Adds multiple bits to the end of the sequence. | |
void | print_debug_info () const |
Print functions | |
The functions for printing messages. | |
std::vector< std::string > | get_memory_usage_info (int message_paragraph=stool::Message::SHOW_MESSAGE) const |
Returns memory usage information. | |
void | print_memory_usage (int message_paragraph=stool::Message::SHOW_MESSAGE) const |
Prints memory usage information. | |
void | print_statistics (int message_paragraph=stool::Message::SHOW_MESSAGE) const |
Prints statistics about the bit sequence. | |
void | print_content (int message_paragraph=stool::Message::SHOW_MESSAGE) const |
Prints the content of the bit sequence. | |
void | print (std::string name="DynamicBitSequence", int message_paragraph=stool::Message::SHOW_MESSAGE) const |
Prints the bit sequence. | |
Conversion functions | |
The conversion functions supported this data structure. | |
std::vector< uint64_t > | to_value_vector () const |
Converts the bit sequence to a vector of uint64_t. | |
std::string | to_string () const |
Converts the bit sequence to a string. | |
std::vector< bool > | to_vector () const |
Converts the bit sequence to a vector of bool. | |
Iterators | |
The iterators supported this data structure. | |
BitForwardIterator< CONTAINER, CONTAINER_ITERATOR, MAX_TREE_DEGREE, MAX_BIT_CONTAINER_SIZE > | get_bit_forward_iterator_begin () const |
Returns an iterator to the beginning of the bit sequence. | |
BitForwardIterator< CONTAINER, CONTAINER_ITERATOR, MAX_TREE_DEGREE, MAX_BIT_CONTAINER_SIZE > | get_leaf_forward_iterator_end () const |
Returns an iterator to the end of the bit sequence. | |
Static Public Member Functions | |
Builder and Writer functions | |
The functions for building and writing this data structure. | |
static void | save (DynamicBitSequence &item, std::vector< uint8_t > &output, uint64_t &pos) |
Saves the bit sequence to a vector. | |
static void | save (DynamicBitSequence &item, std::ofstream &os) |
Saves the bit sequence to a file. | |
static DynamicBitSequence | build (const std::vector< bool > &items) |
Builds a bit sequence from a vector of bool. | |
static DynamicBitSequence | build_from_data (const std::vector< uint8_t > &data, uint64_t &pos) |
Builds a bit sequence from a vector of uint8_t. | |
static DynamicBitSequence | build_from_data (std::ifstream &ifs) |
Builds a bit sequence from a file. | |
Public Attributes | |
Tree | tree |
Other static functions | |
The other static functions supported this data structure. | |
void | print_information_about_performance (int message_paragraph=stool::Message::SHOW_MESSAGE) const |
double | density () const |
void | verify () const |
static std::string | name () |
Returns the name of the bit sequence. | |
A dynamic data structure supporting rank and select queries on a bit sequence.
|
inline |
Returns the bit at the specified position.
pos | The position to query. |
|
inlinestatic |
Builds a bit sequence from a vector of bool.
items | The vector of bool to build from. |
tree_degree | The degree of the tree. |
|
inlinestatic |
Builds a bit sequence from a vector of uint8_t.
data | The vector of uint8_t to build from. |
pos | The position in the input vector. |
|
inlinestatic |
Builds a bit sequence from a file.
ifs | The input file stream. |
|
inline |
Returns the number of bits with value c in the sequence.
c | The bit value to count. |
|
inline |
Checks if the bit sequence is empty.
|
inline |
Returns an iterator to the beginning of the bit sequence.
|
inline |
Returns an iterator to the end of the bit sequence.
|
inline |
Returns memory usage information.
message_paragraph | The paragraph level for messages. |
|
inline |
Inserts a bit at the specified position.
pos | The position to insert at. |
value | The bit value to insert. |
|
inlinestatic |
Returns the name of the bit sequence.
|
inline |
Returns the bit at the specified position.
n | The position to query. |
|
inline |
Prints the bit sequence.
name | The name to print. |
message_paragraph | The paragraph level for messages. |
|
inline |
Prints the content of the bit sequence.
message_paragraph | The paragraph level for messages. |
|
inline |
Prints memory usage information.
message_paragraph | The paragraph level for messages. |
|
inline |
Prints statistics about the bit sequence.
message_paragraph | The paragraph level for messages. |
|
inline |
Returns the total prefix sum.
|
inline |
Returns the prefix sum up to position x.
x | The position to query. |
|
inline |
Adds a bit to the end of the sequence.
value | The bit value to add. |
|
inline |
Adds a bit to the beginning of the sequence.
value | The bit value to add. |
|
inline |
Adds multiple bits to the end of the sequence.
items | The bits to add. |
|
inline |
Returns the number of bits with value c up to position i.
i | The position to query. |
c | The bit value to count. |
|
inline |
Returns the number of 0s up to position i.
i | The position to query. |
|
inline |
Returns the number of 1s up to position i.
i | The position to query. |
|
inline |
Removes the bit at the specified position.
pos | The position to remove from. |
|
inlinestatic |
Saves the bit sequence to a file.
item | The bit sequence to save. |
os | The output file stream. |
|
inlinestatic |
Saves the bit sequence to a vector.
item | The bit sequence to save. |
output | The output vector. |
pos | The position in the output vector. |
|
inline |
Searches for the position where the prefix sum equals sum.
sum | The sum to search for. |
|
inline |
Returns the position of the i-th bit with value c.
i | The index of the bit to find. |
c | The bit value to find. |
|
inline |
Returns the position of the i-th 0.
i | The index of the 0 to find. |
|
inline |
Returns the position of the i-th 1.
i | The index of the 1 to find. |
|
inline |
Sets the bit at the specified position.
i | The position to set. |
b | The bit value to set. |
|
inline |
Sets the degree of the tree.
degree | The degree to set. |
|
inline |
Returns the size of the bit sequence.
|
inline |
Returns the size of the bit sequence in bytes.
Swaps the contents of this sequence with another.
item | The sequence to swap with. |
|
inline |
Converts the bit sequence to a string.
|
inline |
Converts the bit sequence to a vector of uint64_t.
|
inline |
Converts the bit sequence to a vector of bool.