14 std::vector<factorid_t> m_first_child;
15 std::vector<factorid_t> m_next_sibling;
16 std::vector<uliteral_t> m_literal;
20 size_t m_specialresizes = 0;
23 inline static Meta meta() {
24 Meta m(
"lz78trie",
"binarysorted",
"Lempel-Ziv 78 Sorted Binary Trie");
32 m_first_child.reserve(reserve);
33 m_next_sibling.reserve(reserve);
34 m_literal.reserve(reserve);
42 m_literal.push_back(c);
51 m_first_child.clear();
52 m_next_sibling.clear();
58 m_first_child.push_back(m_first_child_id);
59 m_next_sibling.push_back(m_next_sibling_id);
60 m_literal.push_back(c);
61 return node_t(size() - 1,
true);
65 auto parent = parent_w.
id();
68 DCHECK_LT(parent, size());
71 if(m_first_child[parent] ==
undef_id) {
72 m_first_child[parent] = newleaf_id;
76 if(m_literal[node] > c) {
77 m_first_child[parent] = newleaf_id;
81 if(c == m_literal[node])
return node_t(node,
false);
82 if(m_next_sibling[node] ==
undef_id) {
83 m_next_sibling[node] = newleaf_id;
86 const factorid_t nextnode = m_next_sibling[node];
87 if(m_literal[nextnode] > c) {
88 m_next_sibling[node] = newleaf_id;
89 return new_node(c,
undef_id, nextnode);
91 node = m_next_sibling[node];
92 if(m_first_child.capacity() == m_first_child.size()) {
94 if(newbound < m_first_child.size()*2 ) {
95 m_first_child.reserve (newbound);
96 m_next_sibling.reserve (newbound);
97 m_literal.reserve (newbound);
98 IF_STATS(++m_specialresizes);
100 IF_STATS(++m_resizes);
106 inline size_t size()
const {
107 return m_first_child.size();
Contains the text compression and encoding framework.
uint8_t uliteral_t
Type to represent signed single literals.
Algorithm(Algorithm const &)=default
LZ78Trie(const size_t n, const size_t &remaining_characters)
Env & env()
Provides access to the environment that the algorithm works in.
Default return type of find_or_insert.
uint32_t factorid_t
Type for the factor indices, bounded by the number of LZ78 trie nodes.
constexpr factorid_t undef_id
Id that can be used for a non-existing factor.
Local environment for a compression/encoding/decompression call.
Interface for algorithms.
size_t expected_number_of_remaining_elements(const size_t z) const