31 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
32 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
44 this->pi_tree = std::move(
other.pi_tree);
45 this->inverse_pi_tree = std::move(
other.inverse_pi_tree);
46 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
47 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
54 this->pi_tree = std::move(
other.pi_tree);
55 this->inverse_pi_tree = std::move(
other.inverse_pi_tree);
56 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
57 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
81 this->pi_tree.swap(
perm.pi_tree,
false);
82 this->inverse_pi_tree.swap(
perm.inverse_pi_tree,
false);
88 Tree &get_inverse_pi_tree()
90 return this->inverse_pi_tree;
97 template <
typename PI_ITERATOR_BEGIN,
typename PI_ITERATOR_END>
103 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Constructing Dynamic Permutation... " <<
"(input size = " <<
pi_size <<
")" << std::endl;
105 std::chrono::system_clock::time_point
st1,
st2;
106 st1 = std::chrono::system_clock::now();
112 this->pi_tree.set_linked_tree(
nullptr);
113 this->inverse_pi_tree.set_linked_tree(
nullptr);
145 std::unordered_map<uint64_t, uint64_t> mapper;
156 if (
f == mapper.end())
170 st2 = std::chrono::system_clock::now();
177 std::cout << std::endl;
220 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->pi_tree.get_temporary_path());
222 this->pi_tree.remove_using_path(
path,
idx1);
230 this->pi_tree.set_linked_tree(
nullptr);
231 this->inverse_pi_tree.set_linked_tree(
nullptr);
232 this->pi_tree.clear();
233 this->inverse_pi_tree.clear();
234 this->pi_tree.set_linked_tree(&this->inverse_pi_tree);
235 this->inverse_pi_tree.set_linked_tree(&this->pi_tree);
254 assert(this->pi_tree.get_linked_tree() == &
this->inverse_pi_tree);
255 assert(this->inverse_pi_tree.get_linked_tree() == &
this->pi_tree);
259 return this->pi_tree.
size();
282 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->pi_tree.get_temporary_path());
290 const std::vector<NodePointer> &
path =
const_cast<std::vector<NodePointer> &
>(this->inverse_pi_tree.get_temporary_path());
303 std::string to_string()
const
305 std::stringstream
ss;
306 auto vec = this->get_pi_vector();
307 ss << stool::DebugPrinter::to_integer_string(
vec);
311 std::vector<uint64_t> get_pi_vector()
const
313 std::vector<uint64_t>
r;
322 std::vector<uint64_t> get_inverse_pi_vector()
const
324 std::vector<uint64_t>
r;
334 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"========= DP ========" << std::endl;
335 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"PI: " << std::endl;
336 auto pi_vec = this->get_pi_vector();
337 stool::DebugPrinter::print_integers(
pi_vec, stool::Message::get_paragraph_string(
message_paragraph) +
"pi_vector");
338 this->pi_tree.print_tree();
339 this->pi_tree.print_leaves();
340 std::cout << std::endl;
341 std::cout <<
"Inv_PI: " << std::endl;
342 auto inv_pi_vec = this->get_inverse_pi_vector();
344 this->inverse_pi_tree.print_tree();
345 this->inverse_pi_tree.print_internal_nodes();
346 this->inverse_pi_tree.print_leaves();
347 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"=====================" << std::endl;
349 void print_information_about_performance(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const{
350 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Performance Information (DynamicPermutation)[" << std::endl;
352 this->inverse_pi_tree.print_information_about_performance(
message_paragraph + 1);
353 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"]" << std::endl;
360 std::vector<std::string> get_memory_usage_info(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
365 std::vector<std::string>
r;
366 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) = ");
367 for (std::string &
s :
log1)
371 for (std::string &
s :
log2)
378 void print_memory_usage(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
381 for (std::string &
s :
log)
383 std::cout <<
s << std::endl;
387 void sort_leaf_containers()
394 void print_statistics(
int message_paragraph = stool::Message::SHOW_MESSAGE)
const
396 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Statistics(DynamicPermutation):" << std::endl;
397 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"The size of permutation: " << this->size() << std::endl;
398 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"Estimated memory usage: " << this->size_in_bytes() <<
" bytes" << std::endl;
401 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"[END]" << std::endl;
405 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"Content(DynamicPermutation):" << std::endl;
407 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"PI: \t" << stool::DebugPrinter::to_integer_string(
pi_vector) << std::endl;
409 std::cout << stool::Message::get_paragraph_string(
message_paragraph + 1) <<
"Inverse PI: \t" << stool::DebugPrinter::to_integer_string(
inverse_pi_vector) << std::endl;
410 std::cout << stool::Message::get_paragraph_string(
message_paragraph) <<
"[END]" << std::endl;
415 dp.pi_tree.sort_leaf_containers();
416 dp.inverse_pi_tree.sort_leaf_containers();
423 dp.inverse_pi_tree.save(
os);