30 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
31 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
43 this->pi_tree = std::move(
other.pi_tree);
44 this->inverse_pi_tree = std::move(
other.inverse_pi_tree);
45 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
46 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
53 this->pi_tree = std::move(
other.pi_tree);
54 this->inverse_pi_tree = std::move(
other.inverse_pi_tree);
55 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
56 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
80 this->pi_tree.swap(
perm.pi_tree,
false);
81 this->inverse_pi_tree.swap(
perm.inverse_pi_tree,
false);
87 Tree &get_inverse_pi_tree()
89 return this->inverse_pi_tree;
96 template <
typename PI_ITERATOR_BEGIN,
typename PI_ITERATOR_END>
102 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Constructing Dynamic Permutation... " <<
"(input size = " <<
pi_size <<
")" << std::endl;
104 std::chrono::system_clock::time_point
st1,
st2;
105 st1 = std::chrono::system_clock::now();
111 this->pi_tree.set_linked_tree(
nullptr);
112 this->inverse_pi_tree.set_linked_tree(
nullptr);
144 std::unordered_map<uint64_t, uint64_t> mapper;
155 if (
f == mapper.end())
169 st2 = std::chrono::system_clock::now();
176 std::cout << std::endl;
219 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->pi_tree.get_temporary_path());
221 this->pi_tree.remove_using_path(
path,
idx1);
229 this->pi_tree.set_linked_tree(
nullptr);
230 this->inverse_pi_tree.set_linked_tree(
nullptr);
231 this->pi_tree.clear();
232 this->inverse_pi_tree.clear();
233 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
234 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
253 assert(this->pi_tree.get_linked_tree() == &
this->inverse_pi_tree);
254 assert(this->inverse_pi_tree.get_linked_tree() == &
this->pi_tree);
258 return this->pi_tree.
size();
281 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->pi_tree.get_temporary_path());
289 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->inverse_pi_tree.get_temporary_path());
302 std::string to_string()
const
304 std::stringstream
ss;
305 auto vec = this->get_pi_vector();
306 ss << stool::DebugPrinter::to_integer_string(
vec);
310 std::vector<uint64_t> get_pi_vector()
const
312 std::vector<uint64_t>
r;
321 std::vector<uint64_t> get_inverse_pi_vector()
const
323 std::vector<uint64_t>
r;
333 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"========= DP ========" << std::endl;
334 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"PI: " << std::endl;
335 auto pi_vec = this->get_pi_vector();
336 stool::DebugPrinter::print_integers(
pi_vec, stool::Message::get_paragraph_string(
message_paragraph) +
"pi_vector");
337 this->pi_tree.print_tree();
338 this->pi_tree.print_leaves();
339 std::cout << std::endl;
340 std::cout <<
"Inv_PI: " << std::endl;
341 auto inv_pi_vec = this->get_inverse_pi_vector();
343 this->inverse_pi_tree.print_tree();
344 this->inverse_pi_tree.print_internal_nodes();
345 this->inverse_pi_tree.print_leaves();
346 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"=====================" << std::endl;
348 void print_information_about_performance(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const{
349 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Performance Information (DynamicPermutation)[" << std::endl;
351 this->inverse_pi_tree.print_information_about_performance(
message_paragraph + 1);
352 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"]" << std::endl;
359 std::vector<std::string> get_memory_usage_info(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
364 std::vector<std::string>
r;
365 r.
push_back(
"=Dynamic Permutation: " + std::to_string(this->size_in_bytes()) +
" bytes ( " + std::to_string(this->size_in_bytes() / this->size()) +
" bytes per element) = ");
366 for (std::string &
s :
log1)
370 for (std::string &
s :
log2)
377 void print_memory_usage(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
380 for (std::string &
s :
log)
382 std::cout <<
s << std::endl;
386 void sort_leaf_containers()
393 void print_statistics(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
395 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Statistics(DynamicPermutation):" << std::endl;
396 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"The size of permutation: " << this->size() << std::endl;
397 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"Estimated memory usage: " << this->size_in_bytes() <<
" bytes" << std::endl;
400 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"[END]" << std::endl;
404 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Content(DynamicPermutation):" << std::endl;
406 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"PI: \t" << stool::DebugPrinter::to_integer_string(
pi_vector) << std::endl;
408 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"Inverse PI: \t" << stool::DebugPrinter::to_integer_string(
inverse_pi_vector) << std::endl;
409 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"[END]" << std::endl;
414 dp.pi_tree.sort_leaf_containers();
415 dp.inverse_pi_tree.sort_leaf_containers();
416 Tree::store_to_bytes(dp.pi_tree,
output,
pos);
417 Tree::store_to_bytes(dp.inverse_pi_tree,
output,
pos);
421 Tree::store_to_file(dp.pi_tree,
os);
422 Tree::store_to_file(dp.inverse_pi_tree,
os);