67 std::vector<uint64_t> symbols;
68 std::for_each(std::begin(C),
70 [&](
decltype(*std::begin(C)) & freq)
78 uint64_t sigma = symbols.size();
83 for (uint64_t i = 1; i < temp_nodes.size(); ++i)
85 temp_nodes[i - 1] = temp_nodes[i];
86 temp_nodes[i - 1].parent = (temp_nodes[i - 1].parent + temp_nodes.size() - 1) % temp_nodes.size();
87 temp_nodes[i - 1].child[0] -= (temp_nodes[i - 1].child[0] !=
pc_node::undef);
88 temp_nodes[i - 1].child[1] -= (temp_nodes[i - 1].child[1] !=
pc_node::undef);
92 temp_nodes[temp_nodes.size() - 1] = root;
99 std::vector<uint64_t>
const & symbols,
103 std::vector<pc_node> & temp_nodes)
107 uint64_t freq = C[symbols[lb]];
109 return tPII(freq, temp_nodes.size() - 1);
114 uint64_t node_id = temp_nodes.size() - 1;
115 uint64_t l_sigma = (sigma + 1) / 2;
117 tPII freq_nptr_1 =
_construct_tree(node_id, symbols, lb + l_sigma, sigma - l_sigma, C, temp_nodes);
118 uint64_t freq = freq_nptr_0.first + freq_nptr_1.first;
119 temp_nodes[node_id].freq = freq;
120 temp_nodes[node_id].child[0] = freq_nptr_0.second;
121 temp_nodes[node_id].child[1] = freq_nptr_1.second;
122 return tPII(freq, node_id);