b-tree-plus-alpha
Loading...
Searching...
No Matches
dynamic_bit_sequence.hpp
Go to the documentation of this file.
1
6#pragma once
7#include "./bp_tree.hpp"
8#include "./sequence/bit_container.hpp"
9#include "./sequence/bit_forward_iterator.hpp"
10#include "./sequence/bit_deque_container.hpp"
11#include "stool/include/all.hpp"
12namespace stool
13{
14 namespace bptree
15 {
16
22 template <typename CONTAINER, typename CONTAINER_ITERATOR, uint64_t MAX_TREE_DEGREE, uint64_t MAX_BIT_CONTAINER_SIZE>
24 {
25
27 using T = uint64_t;
29
30 static inline constexpr int DEFAULT_CONTAINER_DEGREE = 62;
31 // static inline constexpr int DEFAULT_CONTAINER_DEGREE = 124;
32 Tree tree;
33
34 public:
38
39
44 {
45 }
46
54 DynamicBitSequence(DynamicBitSequence &&) noexcept = default;
55
57
61
62
65 BitForwardIterator<CONTAINER, CONTAINER_ITERATOR, MAX_TREE_DEGREE, MAX_BIT_CONTAINER_SIZE> get_bit_forward_iterator_begin() const
66 {
67 auto leaf_it = this->tree.get_leaf_forward_iterator_begin();
69 }
70
79
83
84
88
93
97 bool operator[](uint64_t i) const
98 {
99 return this->at(i);
100 }
101
103
107
108
112 bool empty() const
113 {
114 return this->tree.empty();
115 }
116
120 uint64_t size() const
121 {
122 return this->tree.size();
123 }
124
128 uint64_t height() const
129 {
130 return this->tree.height();
131 }
136 uint64_t size_in_bytes(bool only_dynamic_memory = false) const
137 {
138 return this->tree.size_in_bytes(only_dynamic_memory);
139 }
143 double density() const
144 {
145 return this->tree.get_value_density();
146 }
147
149
153
154
157 std::vector<uint64_t> to_packed_vector() const
158 {
159 auto vec = this->tree.to_value_vector();
160 std::vector<uint64_t> r;
161 r.resize(vec.size());
162 for (uint64_t i = 0; i < vec.size(); i++)
163 {
164 r[i] = vec[i];
165 }
166 return r;
167 }
168
172 std::string to_string() const
173 {
174 std::string s;
175 std::vector<uint64_t> bits = this->to_packed_vector();
176 s.push_back('[');
177 for (uint64_t i = 0; i < bits.size(); i++)
178 {
179 s.push_back(bits[i] >= 1 ? '1' : '0');
180 // assert(bits[i] == this->at(i));
181 }
182 s.push_back(']');
183 return s;
184 }
185
189 std::vector<bool> to_vector() const
190 {
191 uint64_t _size = this->size();
192 std::vector<bool> r;
193 r.resize(_size, false);
194 uint64_t counter = 0;
195
196 auto _end = this->get_leaf_forward_iterator_end();
197
199 while (!it.is_end())
200 {
201 uint64_t bits = *it;
202 uint64_t i = 0;
203
204 while (i < 64 && counter < _size)
205 {
206 bool b = stool::MSBByte::get_bit(bits, i);
207 r[counter] = b;
208
209 counter++;
210 i++;
211 }
212 ++it;
213 }
214
215 assert(counter == _size);
216 return r;
217 }
219
223
224
229 bool at(uint64_t i) const
230 {
231 return this->tree.at(i) & 1;
232 }
233
238 int64_t one_based_rank1(uint64_t i) const
239 {
240 if (i == 0)
241 {
242 return 0;
243 }
244 else if (i <= this->size())
245 {
246 uint64_t p = this->tree.psum(i - 1);
247
248 return p;
249 }
250 else
251 {
252 assert(false);
253 throw std::range_error("Error: DynamicBitSequence::rank1()");
254 }
255 }
256
261 int64_t one_based_rank0(uint64_t i) const
262 {
263 return i - this->one_based_rank1(i);
264 }
265
270 int64_t one_based_rank(uint64_t i, bool c) const
271 {
272 return c ? this->one_based_rank1(i) : this->one_based_rank0(i);
273 }
274
279 int64_t rank0(uint64_t i) const
280 {
281 return this->one_based_rank0(i);
282 }
283
288 int64_t rank1(uint64_t i) const
289 {
290 return this->one_based_rank1(i);
291 }
292
297 int64_t rank(uint64_t i, bool c) const
298 {
299 return this->one_based_rank(i, c);
300 }
301
302
303
308 int64_t zero_based_select1(uint64_t i) const
309 {
310 int64_t p = this->tree.search(i + 1);
311 if (p == -1)
312 {
313 return p;
314 }
315 else
316 {
317 if (p >= (int64_t)this->size())
318 {
319 return -1;
320 }
321 else
322 {
323 return p;
324 }
325 }
326 }
327
332 int64_t zero_based_select0(uint64_t i) const
333 {
334 int64_t p = this->tree.select0(i);
335 if (p == -1)
336 {
337 return p;
338 }
339 else
340 {
341 if (p >= (int64_t)this->size())
342 {
343 return -1;
344 }
345 else
346 {
347 return p;
348 }
349 }
350 }
351
356 int64_t zero_based_select(uint64_t i, bool c) const
357 {
358 return c ? this->select1(i) : this->select0(i);
359 }
360
365 int64_t select1(uint64_t i) const
366 {
367 return this->zero_based_select1(i);
368 }
369
374 int64_t select0(uint64_t i) const
375 {
376 return this->zero_based_select0(i);
377 }
378
383 int64_t select(uint64_t i, bool c) const
384 {
385 return this->zero_based_select(i, c);
386 }
387
388
393 int64_t count1() const
394 {
395 uint64_t _size = this->size();
396 if (_size > 0)
397 {
398 return this->one_based_rank1(_size);
399 }
400 else
401 {
402 return 0;
403 }
404 }
405
410 int64_t count0() const
411 {
412 uint64_t _size = this->size();
413 if (_size > 0)
414 {
415 return this->one_based_rank0(_size);
416 }
417 else
418 {
419 return 0;
420 }
421 }
422
427 int64_t count_c(bool c) const
428 {
429 uint64_t _size = this->size();
430 if (_size > 0)
431 {
432 return this->one_based_rank(_size, c);
433 }
434 else
435 {
436 return 0;
437 }
438 }
439
444 uint64_t psum(uint64_t i) const
445 {
446 return this->tree.psum(i);
447 }
448
453 uint64_t psum() const
454 {
455 return this->tree.psum();
456 }
457
462 int64_t search(uint64_t x) const
463 {
464 return this->tree.search(x);
465 }
466
468
472
473
478 {
479 this->tree.swap(item.tree);
480 }
481
485 void clear()
486 {
487 this->tree.clear();
488 }
489
494 void push_back(bool value)
495 {
496#if DEBUG
497 uint64_t p = this->size();
498#endif
499 this->tree.push_back(value);
500#if DEBUG
501 assert(p + 1 == this->size());
502#endif
503 }
504
509 void push_many(const std::vector<bool> &items_Q)
510 {
511 this->tree.push_many(items_Q);
512 }
513
518 void push_front(bool value)
519 {
520 this->tree.push_front(value);
521 }
522
527 void insert(uint64_t p, bool v)
528 {
529 this->tree.insert(p, v, v);
530 }
531
536 void remove(uint64_t p)
537 {
538 if (p < this->size())
539 {
540 this->tree.remove(p);
541 }
542 else
543 {
544 throw std::range_error("Error: DynamicBitSequence::remove(p)");
545 }
546 }
547
552 void set_bit(uint64_t i, bool b)
553 {
554 bool b1 = this->at(i);
555 if (b != b1)
556 {
557 if (b)
558 {
559 this->tree.increment(i, 1);
560 }
561 else
562 {
563 this->tree.increment(i, -1);
564 }
565 }
566 }
567
572 void set_bits(uint64_t i, std::vector<bool> &bits)
573 {
574 for (uint64_t j = 0; j < bits.size(); j++)
575 {
576 this->set_bit(i + j, bits[j]);
577 }
578 }
579
585 {
586 bool b = this->tree.check_if_leaf_container_vec_is_sorted();
587 if (!b)
588 {
589 std::cout << "unsorted" << std::endl;
590 this->tree.sort_leaf_containers();
591 }
592 }
593
595
599
600
604 void print_debug_info() const
605 {
606 std::cout << "DynamicBitSequence::print_debug_info()" << std::endl;
607 this->tree.print_debug_info();
608 }
609
614 std::vector<std::string> get_memory_usage_info(int message_paragraph = stool::Message::SHOW_MESSAGE) const
615 {
616 std::vector<std::string> log1 = this->tree.get_memory_usage_info(message_paragraph + 1);
617
618 std::vector<std::string> r;
619 uint64_t size_in_bytes = this->size_in_bytes();
620 uint64_t size = this->size();
621 double bits_per_element = size > 0 ? ((double)size_in_bytes / (double)size) : 0;
622
623 r.push_back(stool::Message::get_paragraph_string(message_paragraph) + "=DynamicBitSequence: " + std::to_string(this->size_in_bytes()) + " bytes, " + std::to_string(size) + " elements, " + std::to_string(bits_per_element) + " bytes per element =");
624 for (std::string &s : log1)
625 {
626 r.push_back(s);
627 }
628 r.push_back(stool::Message::get_paragraph_string(message_paragraph) + "==");
629 return r;
630 }
631
636 void print_memory_usage(int message_paragraph = stool::Message::SHOW_MESSAGE) const
637 {
638 std::vector<std::string> log = this->get_memory_usage_info(message_paragraph);
639 for (std::string &s : log)
640 {
641 std::cout << s << std::endl;
642 }
643 }
644
649 void print_statistics(int message_paragraph = stool::Message::SHOW_MESSAGE) const
650 {
651 std::cout << stool::Message::get_paragraph_string(message_paragraph) << "Statistics(DynamicBitSequence):" << std::endl;
652 this->tree.print_statistics(message_paragraph + 1);
653 std::cout << stool::Message::get_paragraph_string(message_paragraph) << "[END]" << std::endl;
654 }
655
660 void print_information_about_performance(int message_paragraph = stool::Message::SHOW_MESSAGE) const
661 {
662 std::cout << stool::Message::get_paragraph_string(message_paragraph) << "Performance Information (DynamicSequence)[" << std::endl;
663 this->tree.print_information_about_performance(message_paragraph + 1);
664 std::cout << stool::Message::get_paragraph_string(message_paragraph) << "]" << std::endl;
665 }
666
672 void print_content(std::string name = "DynamicBitSequence", int message_paragraph = stool::Message::SHOW_MESSAGE) const
673 {
674 std::cout << stool::Message::get_paragraph_string(message_paragraph) << name << ": " << this->to_string() << std::endl;
675 }
676
680 void verify() const
681 {
682 this->tree.verify();
683 }
684
686
690
691
692
696 static DynamicBitSequence build(const std::vector<bool> &items)
697 {
699 r.tree.initialize();
700 r.tree.build(items);
701 return r;
702 }
703
707 static DynamicBitSequence load_from_bytes(const std::vector<uint8_t> &data, uint64_t &pos)
708 {
710 Tree tree = Tree::load_from_bytes(data, pos);
711 r.tree.swap(tree, false);
712 return r;
713 }
714
718 static DynamicBitSequence load_from_file(std::ifstream &ifs)
719 {
721 Tree tree = Tree::load_from_file(ifs);
722 r.tree.swap(tree, false);
723 return r;
724 }
725
726
730 static void store_to_bytes(DynamicBitSequence &item, std::vector<uint8_t> &output, uint64_t &pos)
731 {
732 Tree::store_to_bytes(item.tree, output, pos);
733 }
734
738 static void store_to_file(DynamicBitSequence &item, std::ofstream &os)
739 {
740 Tree::store_to_file(item.tree, os);
741 }
742
743
745
749
750
753 static std::string name()
754 {
755 std::string s;
756 s += "DynamicSequence(";
757 s += CONTAINER::name();
758 s += ")";
759 return s;
760 }
762 };
763
765
766 using DynamicBitDequeSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, bptree::DEFAULT_MAX_DEGREE_OF_INTERNAL_NODE, 1024>;
767 // using SimpleDynamicBitSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 8192>;
768 using SimpleDynamicBitSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 8192>;
769
770 /*
771 using DynamicBitDequeSequenceA = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 512>;
772 using DynamicBitDequeSequenceB = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 1024>;
773 using DynamicBitDequeSequenceC = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 2048>;
774 using DynamicBitDequeSequenceD = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 4096>;
775
776 using DynamicBitDequeSequence1 = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 14, 8192>;
777 using DynamicBitDequeSequence2 = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 30, 8192>;
778 using DynamicBitDequeSequence3 = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 8192>;
779 using DynamicBitDequeSequence4 = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 126, 8192>;
780 */
781
782 // using DynamicBitDequeSequenceE = DynamicBitSequence<stool::bptree::BitVectorContainer, stool::bptree::BitVectorContainer::BitVectorContainerIterator, 8190, 2048>;
783
784 // template <typename T>
785 // using VLCDequeSeq = DynamicSequence<VLCDeque, T>;
786 }
787
788}
A pointer to a node of BPTree [Unchecked AI's Comment].
Definition bp_node_pointer.hpp:14
std::vector< VALUE > to_value_vector() const
Return the values S[0..n-1] as a vector of VALUE.
Definition bp_tree.hpp:403
void build(const std::vector< VALUE > &_values)
Builds the B+ tree so that S[0..n-1] = _values[0..n-1].
Definition bp_tree.hpp:1491
void insert(uint64_t i, VALUE v, uint64_t weight_w)
Insert a given value v with weight w at position i in the sequence S.
Definition bp_tree.hpp:1275
static void store_to_bytes(BPTree &item, std::vector< uint8_t > &output, uint64_t &pos)
Save the given instance item to a byte vector output at the position pos.
Definition bp_tree.hpp:1554
static void store_to_file(BPTree &item, std::ofstream &os)
Save the given instance item to a file stream os.
Definition bp_tree.hpp:1581
void print_statistics(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the statistics of this data structure.
Definition bp_tree.hpp:971
void increment(uint64_t i, int64_t delta)
Update S[i] and its weight using a given value delta and the increment function supported by the LEAF...
Definition bp_tree.hpp:1332
bool check_if_leaf_container_vec_is_sorted() const
Checks if the leaf containers are sorted in the vector W, i.e., W[i] is the leaf container of the i-t...
Definition bp_tree.hpp:758
bool empty() const
Return true if n = 0, false otherwise.
Definition bp_tree.hpp:353
void swap(BPTree &_tree, bool swap_linked_tree=true)
Swap operation.
Definition bp_tree.hpp:1087
static BPTree load_from_file(std::ifstream &ifs)
Returns the BPTree instance loaded from a file stream ifs.
Definition bp_tree.hpp:1536
VALUE at(uint64_t i) const
Return B[i].
Definition bp_tree.hpp:440
void push_back(VALUE value)
Push a given value to the end of the sequence S.
Definition bp_tree.hpp:1154
uint64_t size_in_bytes(bool only_dynamic_memory=false) const
Returns the total memory size of this B+-tree.
Definition bp_tree.hpp:377
void initialize()
Initializes this instance.
Definition bp_tree.hpp:1063
std::vector< std::string > get_memory_usage_info(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Return the memory usage information of this data structure as a vector of strings.
Definition bp_tree.hpp:789
int64_t search(uint64_t u) const
Return the smallest index i such that psum(i) >= u if it exists, otherwise return -1.
Definition bp_tree.hpp:572
LeafForwardIterator get_leaf_forward_iterator_begin() const
Return an iterator pointing to the first leaf in forward traversal.
Definition bp_tree.hpp:231
uint64_t size() const
Return the number of values stored in this tree (i.e., n).
Definition bp_tree.hpp:282
bool verify() const
Verify the internal consistency of this data structure.
Definition bp_tree.hpp:1040
void push_front(VALUE value)
Push a given value to the beginning of the sequence S.
Definition bp_tree.hpp:1189
int64_t select0(uint64_t i) const
Returns the position of the (i+1)-th 0 in S[0..n-1] if it exists, otherwise return -1.
Definition bp_tree.hpp:596
static BPTree load_from_bytes(const std::vector< uint8_t > &data, uint64_t &pos)
Returns the BPTree instance loaded from a byte vector data at the position pos.
Definition bp_tree.hpp:1515
void remove(uint64_t i)
Remove S[i] from the sequence S.
Definition bp_tree.hpp:1255
void push_many(const std::vector< VALUE > &values_Q)
Add a given sequence Q[0..k-1] to the end of S[0..n-1] (i.e., S = S[0..n-1]Q[0..k-1])
Definition bp_tree.hpp:1164
void clear()
Clear the B+-tree and reset it to an empty state (i.e., n = 0, x = 0, y = 0).
Definition bp_tree.hpp:1110
void print_debug_info() const
Print debug information about this instance.
Definition bp_tree.hpp:1024
uint64_t psum() const
Return the sum of the weights of S[0..n-1].
Definition bp_tree.hpp:521
void sort_leaf_containers()
Sorts the leaf containers so that each W[i] is the LEAF CONTAINER of the i-th leaf.
Definition bp_tree.hpp:1410
uint64_t height() const
Return the height of this tree.
Definition bp_tree.hpp:329
void print_information_about_performance(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the performance information of this data structure.
Definition bp_tree.hpp:947
double get_value_density() const
Return the density of this tree (i.e., n / capacity()).
Definition bp_tree.hpp:313
A forward iterator for traversing the bits stored in a BP-tree. [Unchecked AI's Comment].
Definition bit_forward_iterator.hpp:16
A container that stores a short sequence of bits. [Unchecked AI's Comment].
Definition bit_deque_container.hpp:14
A dynamic data structure supporting rank and select queries on a bit sequence B[0....
Definition dynamic_bit_sequence.hpp:24
int64_t rank0(uint64_t i) const
Alias for one_based_rank0.
Definition dynamic_bit_sequence.hpp:279
int64_t rank(uint64_t i, bool c) const
Alias for one_based_rank.
Definition dynamic_bit_sequence.hpp:297
uint64_t size_in_bytes(bool only_dynamic_memory=false) const
Return the total memory usage in bytes.
Definition dynamic_bit_sequence.hpp:136
DynamicBitSequence()
Default constructor with |B| = 0.
Definition dynamic_bit_sequence.hpp:43
DynamicBitSequence(DynamicBitSequence &&) noexcept=default
Default move constructor.
uint64_t psum() const
Returns the number of 1s in the bit sequence B[0..n-1].
Definition dynamic_bit_sequence.hpp:453
static void store_to_file(DynamicBitSequence &item, std::ofstream &os)
Save the given instance item to a file stream os.
Definition dynamic_bit_sequence.hpp:738
std::vector< bool > to_vector() const
Return B as a vector of bool.
Definition dynamic_bit_sequence.hpp:189
uint64_t psum(uint64_t i) const
Returns the number of 1s in the bit sequence B[0..i].
Definition dynamic_bit_sequence.hpp:444
int64_t select1(uint64_t i) const
Alias for zero_based_select1.
Definition dynamic_bit_sequence.hpp:365
int64_t one_based_rank0(uint64_t i) const
Returns the number of 0 in B[0..i-1].
Definition dynamic_bit_sequence.hpp:261
int64_t select(uint64_t i, bool c) const
Alias for zero_based_select.
Definition dynamic_bit_sequence.hpp:383
double density() const
Return the density of the internal tree.
Definition dynamic_bit_sequence.hpp:143
int64_t zero_based_select(uint64_t i, bool c) const
Returns the position p of the (i+1)-th c in B if such a position exists, otherwise returns -1.
Definition dynamic_bit_sequence.hpp:356
bool empty() const
Checks if B is empty.
Definition dynamic_bit_sequence.hpp:112
void set_bits(uint64_t i, std::vector< bool > &bits)
Replace the bits B[i..i+m-1] with the bits bits[0..m-1].
Definition dynamic_bit_sequence.hpp:572
int64_t zero_based_select0(uint64_t i) const
Returns the position p of the (i+1)-th 0 in B if such a position exists, otherwise returns -1.
Definition dynamic_bit_sequence.hpp:332
int64_t rank1(uint64_t i) const
Alias for one_based_rank1.
Definition dynamic_bit_sequence.hpp:288
void insert(uint64_t p, bool v)
Insert a bit v at the position p in the bits B.
Definition dynamic_bit_sequence.hpp:527
void set_bit(uint64_t i, bool b)
Replace the bit B[i] with the bit b.
Definition dynamic_bit_sequence.hpp:552
void print_content(std::string name="DynamicBitSequence", int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the bit sequence B.
Definition dynamic_bit_sequence.hpp:672
static DynamicBitSequence build(const std::vector< bool > &items)
Build a new DynamicBitSequence from a given sequence items.
Definition dynamic_bit_sequence.hpp:696
void swap(DynamicBitSequence &item)
Swap operation.
Definition dynamic_bit_sequence.hpp:477
bool at(uint64_t i) const
Return B[i].
Definition dynamic_bit_sequence.hpp:229
int64_t count_c(bool c) const
Return the number of c in B[0..n-1].
Definition dynamic_bit_sequence.hpp:427
std::string to_string() const
Return B as a binary string.
Definition dynamic_bit_sequence.hpp:172
DynamicBitSequence & operator=(DynamicBitSequence &&) noexcept=default
Default move assignment operator.
DynamicBitSequence(const DynamicBitSequence &)=delete
Deleted copy constructor.
void push_back(bool value)
Adds a bit to the end of the sequence B.
Definition dynamic_bit_sequence.hpp:494
std::vector< uint64_t > to_packed_vector() const
Return B as a packed vector of uint64_t (i.e., the length of the vector is |B| / 64).
Definition dynamic_bit_sequence.hpp:157
static DynamicBitSequence load_from_file(std::ifstream &ifs)
Returns the DynamicBitSequence instance loaded from a file stream ifs.
Definition dynamic_bit_sequence.hpp:718
DynamicBitSequence & operator=(const DynamicBitSequence &)=delete
Deleted copy assignment operator.
void print_debug_info() const
Print debug information about this instance.
Definition dynamic_bit_sequence.hpp:604
static void store_to_bytes(DynamicBitSequence &item, std::vector< uint8_t > &output, uint64_t &pos)
Save the given instance item to a byte vector output at the position pos.
Definition dynamic_bit_sequence.hpp:730
void print_memory_usage(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the memory usage information of this data structure.
Definition dynamic_bit_sequence.hpp:636
uint64_t size() const
Return |B|.
Definition dynamic_bit_sequence.hpp:120
int64_t one_based_rank1(uint64_t i) const
Returns the number of 1 in B[0..i-1].
Definition dynamic_bit_sequence.hpp:238
int64_t count1() const
Return the number of 1 in B[0..n-1].
Definition dynamic_bit_sequence.hpp:393
static DynamicBitSequence load_from_bytes(const std::vector< uint8_t > &data, uint64_t &pos)
Returns the DynamicBitSequence instance loaded from a byte vector data at the position pos.
Definition dynamic_bit_sequence.hpp:707
void print_statistics(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the statistics of this data structure.
Definition dynamic_bit_sequence.hpp:649
int64_t select0(uint64_t i) const
Alias for zero_based_select0.
Definition dynamic_bit_sequence.hpp:374
void verify() const
Verify the internal consistency of this data structure.
Definition dynamic_bit_sequence.hpp:680
void print_information_about_performance(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Print the performance information of this data structure.
Definition dynamic_bit_sequence.hpp:660
void clear()
Clear the elements in B.
Definition dynamic_bit_sequence.hpp:485
uint64_t height() const
Return the height of the internal tree storing the bit sequence B.
Definition dynamic_bit_sequence.hpp:128
int64_t zero_based_select1(uint64_t i) const
Returns the position p of the (i+1)-th 1 in B if such a position exists, otherwise returns -1.
Definition dynamic_bit_sequence.hpp:308
void push_front(bool value)
Adds a bit to the beginning of the sequence B.
Definition dynamic_bit_sequence.hpp:518
static std::string name()
Return the name of the DynamicBitSequence for debugging.
Definition dynamic_bit_sequence.hpp:753
int64_t one_based_rank(uint64_t i, bool c) const
Returns the number of c in B[0..i-1].
Definition dynamic_bit_sequence.hpp:270
int64_t search(uint64_t x) const
Returns the first position p such that psum(p) >= x if such a position exists, otherwise returns -1.
Definition dynamic_bit_sequence.hpp:462
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 B.
Definition dynamic_bit_sequence.hpp:65
std::vector< std::string > get_memory_usage_info(int message_paragraph=stool::Message::SHOW_MESSAGE) const
Return the memory usage information of this data structure as a vector of strings.
Definition dynamic_bit_sequence.hpp:614
int64_t count0() const
Return the number of 0 in B[0..n-1].
Definition dynamic_bit_sequence.hpp:410
void sort_leaf_containers()
Sorts the leaf containers of the internal tree.
Definition dynamic_bit_sequence.hpp:584
void push_many(const std::vector< bool > &items_Q)
Add a given sequence Q[0..k-1] to the end of S[0..n-1] (i.e., S = S[0..n-1]Q[0..k-1])
Definition dynamic_bit_sequence.hpp:509
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 B.
Definition dynamic_bit_sequence.hpp:74
void remove(uint64_t p)
Removes the bit at the position p in the bits B.
Definition dynamic_bit_sequence.hpp:536