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()");
297 int64_t
rank(uint64_t i,
bool c)
const
310 int64_t p = this->tree.
search(i + 1);
317 if (p >= (int64_t)this->
size())
334 int64_t p = this->tree.
select0(i);
341 if (p >= (int64_t)this->
size())
395 uint64_t _size = this->
size();
412 uint64_t _size = this->
size();
429 uint64_t _size = this->
size();
444 uint64_t
psum(uint64_t i)
const
446 return this->tree.
psum(i);
455 return this->tree.
psum();
464 return this->tree.
search(x);
479 this->tree.
swap(item.tree);
497 uint64_t p = this->
size();
501 assert(p + 1 == this->
size());
529 this->tree.
insert(p, v, v);
538 if (p < this->
size())
544 throw std::range_error(
"Error: DynamicBitSequence::remove(p)");
554 bool b1 = this->
at(i);
574 for (uint64_t j = 0; j < bits.size(); j++)
589 std::cout <<
"unsorted" << std::endl;
606 std::cout <<
"DynamicBitSequence::print_debug_info()" << std::endl;
618 std::vector<std::string> r;
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)
628 r.push_back(stool::Message::get_paragraph_string(message_paragraph) +
"==");
639 for (std::string &s : log)
641 std::cout << s << std::endl;
651 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"Statistics(DynamicBitSequence):" << std::endl;
653 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"[END]" << std::endl;
662 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"Performance Information (DynamicSequence)[" << std::endl;
664 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
"]" << std::endl;
672 void print_content(std::string
name =
"DynamicBitSequence",
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
674 std::cout << stool::Message::get_paragraph_string(message_paragraph) <<
name <<
": " << this->
to_string() << std::endl;
711 r.tree.
swap(tree,
false);
722 r.tree.
swap(tree,
false);
756 s +=
"DynamicSequence(";
757 s += CONTAINER::name();
766 using DynamicBitDequeSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, bptree::DEFAULT_MAX_DEGREE_OF_INTERNAL_NODE, 1024>;
768 using SimpleDynamicBitSequence = DynamicBitSequence<BDC, BDC::BitVectorContainerIterator, 62, 8192>;