9 #include <unordered_map> 15 typedef std::unordered_map<squeeze_node_t, factorid_t, _VignaHasher> table_t;
23 const size_t& m_remaining_characters;
27 Meta m(
"lz78trie",
"exthash",
"Hash Trie with external hash table");
35 , m_remaining_characters(remaining_characters)
39 m_table.reserve(reserve);
62 m_table.insert(std::make_pair<squeeze_node_t,factorid_t>(
create_node(0, c),
size()));
76 auto parent = parent_w.
id();
79 auto ret = m_table.insert(std::make_pair(
create_node(parent,c), newleaf_id));
82 if(
tdc_unlikely(m_table.bucket_count()*m_table.max_load_factor() < m_table.size()+1)) {
83 const size_t expected_size = (m_table.size() + 1 + lz78_expected_number_of_remaining_elements(m_table.size(), m_n, m_remaining_characters))/0.95;
84 if(expected_size < m_table.bucket_count()*2.0*0.95) {
85 m_table.reserve(expected_size);
91 return node_t(ret.first->second,
false);
94 inline size_t size()
const {
95 return m_table.size();
Contains the text compression and encoding framework.
#define tdc_unlikely(x)
Provides a hint to the compiler that x is expected to resolve to false.
uint8_t uliteral_t
Type to represent signed single literals.
node_t find_or_insert(const node_t &parent_w, uliteral_t c)
node_t add_rootnode(uliteral_t c)
ExtHashTrie(Env &&env, const size_t n, const size_t &remaining_characters, factorid_t reserve=0)
Env & env()
Provides access to the environment that the algorithm works in.
Default return type of find_or_insert.
node_t get_rootnode(uliteral_t c) const
ExtHashTrie & operator=(ExtHashTrie &&other)=default
IF_STATS(MoveGuard m_guard;inline ~ExtHashTrie() { if(m_guard) { StatPhase::log("table size", m_table.bucket_count());StatPhase::log("load factor", m_table.max_load_factor());StatPhase::log("entries", m_table.size());StatPhase::log("load ratio", m_table.load_factor());} }) ExtHashTrie(ExtHashTrie &&other)=default
static void log(const char *key, const T &value)
Logs a user statistic for the current phase.
uint32_t factorid_t
Type for the factor indices, bounded by the number of LZ78 trie nodes.
squeeze_node_t create_node(factorid_t id, uliteral_t c)
Local environment for a compression/encoding/decompression call.
Interface for algorithms.