tudocomp
– The TU Dortmund Compression Framework
squeeze_node.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <tudocomp/ds/uint_t.hpp>
3 #include <tudocomp/def.hpp>
5 
6 namespace tdc {
7 namespace lz78 {
8 
9 // typedef uint32_t squeeze_node_t; // TODO: change this to bits_for(literal_t) + bits_for(len_t)
10 typedef uint_t<40> squeeze_node_t; // TODO: change this to bits_for(literal_t) + bits_for(len_t)
11 // #ifndef NODE_T
12 //typedef uint64_t squeeze_node_t;
13 // #else
14 // typedef NODE_T node_t;
15 // #endif
16 
17 
18 #ifndef ALPHABET_BITS
19  #define ALPHABET_BITS (sizeof(uliteral_t)*8)
20 #endif //TODO alphabet_bits -> effective alphabet size
21 
22 inline factorid_t get_id(squeeze_node_t data) {
23  return static_cast<uint64_t>(data)>>ALPHABET_BITS;
24 }
25 inline uliteral_t get_letter(squeeze_node_t data) {
26  return static_cast<char>(static_cast<uint64_t>(data)) & 0xff; //TODO 0xff hard coded
27 }
28 inline squeeze_node_t create_node(factorid_t id, uliteral_t c) {
29  return (static_cast<uint64_t>(id)<<ALPHABET_BITS) + static_cast<uint64_t>(c);
30 }
31 #undef ALPHABET_BITS
32 
33 }}//ns
34 
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
uint_t< 40 > squeeze_node_t
uint8_t uliteral_t
Type to represent signed single literals.
Definition: def.hpp:131
factorid_t get_id(squeeze_node_t data)
uliteral_t get_letter(squeeze_node_t data)
typename uint_dispatch_t< N >::type uint_t
Definition: uint_t.hpp:165
#define ALPHABET_BITS
uint32_t factorid_t
Type for the factor indices, bounded by the number of LZ78 trie nodes.
Definition: LZ78Trie.hpp:11
squeeze_node_t create_node(factorid_t id, uliteral_t c)