17 constexpr
size_t DMS_MAX = std::numeric_limits<factorid_t>::max();
27 m_id(id), m_is_new(is_new) {}
31 inline bool is_new()
const {
return m_is_new; }
35 #define LZ78_DICT_SIZE_DESC \ 36 "`dict_size` has to either be 0 (unlimited), or a positive integer,\n" \ 37 "and determines the maximum size of the backing storage of\n" \ 38 "the dictionary before it gets reset." 40 template<
typename _node_t = LZ78TrieNode>
46 const size_t& m_remaining_characters;
48 LZ78Trie(
const size_t n,
const size_t& remaining_characters)
49 : m_n(n), m_remaining_characters(remaining_characters) {}
52 return lz78_expected_number_of_remaining_elements(z, m_n, m_remaining_characters);
62 CHECK(
false) <<
"This needs to be implemented by a inheriting class";
70 CHECK(
false) <<
"This needs to be implemented by a inheriting class";
79 CHECK(
false) <<
"This needs to be implemented by a inheriting class";
88 CHECK(
false) <<
"This needs to be implemented by a inheriting class";
95 inline size_t size()
const {
96 CHECK(
false) <<
"This needs to be implemented by a inheriting class";
node_t get_rootnode(uliteral_t c) const
Returns the root node corresponding to literal c.
Contains the text compression and encoding framework.
uint8_t uliteral_t
Type to represent signed single literals.
node_t add_rootnode(uliteral_t c)
The dictionary can store multiple root nodes For LZ78, we use a root node with the id = c = 0...
void clear()
Erases the contents of the dictionary.
LZ78Trie(const size_t n, const size_t &remaining_characters)
Default return type of find_or_insert.
size_t size() const
Returns the number of entries, plus the number of rootnodes.
LZ78TrieNode(factorid_t id, bool is_new)
constexpr size_t DMS_MAX
Maximum legal dictionary size.
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.
node_t find_or_insert(const node_t &parent, uliteral_t c)
Searches a pair (parent, c).
size_t expected_number_of_remaining_elements(const size_t z) const