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"
22 template <
typename CONTAINER,
typename CONTAINER_ITERATOR, u
int64_t MAX_TREE_DEGREE, u
int64_t MAX_BIT_CONTAINER_SIZE>
30 static inline constexpr int DEFAULT_CONTAINER_DEGREE = 62;
97 bool operator[](uint64_t i)
const
114 return this->tree.
empty();
122 return this->tree.
size();
130 return this->tree.
height();
160 std::vector<uint64_t> r;
161 r.resize(vec.size());
162 for (uint64_t i = 0; i < vec.size(); i++)
177 for (uint64_t i = 0; i < bits.size(); i++)
179 s.push_back(bits[i] >= 1 ?
'1' :
'0');
191 uint64_t _size = this->
size();
193 r.resize(_size,
false);
194 uint64_t counter = 0;
204 while (i < 64 && counter < _size)
206 bool b = stool::MSBByte::get_bit(bits, i);
215 assert(counter == _size);
229 bool at(uint64_t i)
const
231 return this->tree.
at(i) & 1;
244 else if (i <= this->
size())
246 uint64_t p = this->tree.
psum(i - 1);
253 throw std::range_error(
"Error: DynamicBitSequence::rank1()");
281 int64_t p = this->tree.
search(i + 1);
288 if (p >= (int64_t)this->
size())
305 int64_t p = this->tree.
select0(i);
312 if (p >= (int64_t)this->
size())
338 uint64_t _size = this->
size();
355 uint64_t _size = this->
size();
372 uint64_t _size = this->
size();
387 uint64_t
psum(uint64_t i)
const
389 return this->tree.
psum(i);
398 return this->tree.
psum();
407 return this->tree.
search(x);
422 this->tree.
swap(item.tree);
440 uint64_t p = this->
size();
444 assert(p + 1 == this->
size());
472 this->tree.
insert(p, v, v);
481 if (p < this->
size())
487 throw std::range_error(
"Error: DynamicBitSequence::remove(p)");
497 bool b1 = this->
at(i);
517 for (uint64_t j = 0; j < bits.size(); j++)
532 std::cout <<
"unsorted" << std::endl;
549 std::cout <<
"DynamicBitSequence::print_debug_info()" << std::endl;
561 std::vector<std::string> r;
566 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 =");
567 for (std::string &s : log1)
571 r.push_back(stool::Message::get_paragraph_string(message_paragraph) +
"==");
582 for (std::string &s : log)
584 std::cout << s << std::endl;
594 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"Statistics(DynamicBitSequence):" << std::endl;
596 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"[END]" << std::endl;
605 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"Performance Information (DynamicSequence)[" << std::endl;
607 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"]" << std::endl;
615 void print_content(std::string
name =
"DynamicBitSequence",
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
617 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
name <<
": " << this->
to_string() << std::endl;
654 r.tree.
swap(tree,
false);
665 r.tree.
swap(tree,
false);
699 s +=
"DynamicSequence(";
700 s += CONTAINER::name();
709 using DynamicBitDequeSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, bptree::DEFAULT_MAX_DEGREE_OF_INTERNAL_NODE, 1024>;
711 using SimpleDynamicBitSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 8192>;