25 #ifndef __CLOCKUTILS_COMPRESSION_ALGORITHM_HUFFMANBASE_H__ 26 #define __CLOCKUTILS_COMPRESSION_ALGORITHM_HUFFMANBASE_H__ 38 namespace compression {
60 std::shared_ptr<Node>
left =
nullptr;
61 std::shared_ptr<Node>
right =
nullptr;
69 static std::shared_ptr<Node>
buildTree(
const std::vector<uint8_t> & header);
77 static void generateMapping(
const std::shared_ptr<Node> & node,
const std::vector<bool> & bitSeq, std::vector<std::vector<bool>> & mapping);
86 static ClockError getChar(
const std::string & compressed,
const std::shared_ptr<Node> & root, len_t length, std::string & result);
static std::shared_ptr< Node > buildTree(const std::vector< uint8_t > &header)
creates a Huffman tree with given list of probabilities header must have size 256 and values have to ...
static ClockError getChar(const std::string &compressed, const std::shared_ptr< Node > &root, len_t length, std::string &result)
converts bit sequence to the real character
std::shared_ptr< Node > right
std::shared_ptr< Node > left
uint32_t len_t
type that should be used as the 'length' counter This controls the size of the header, the maximum string length etc.
static void generateMapping(const std::shared_ptr< Node > &node, const std::vector< bool > &bitSeq, std::vector< std::vector< bool >> &mapping)
constructs a mapping from character to a bit sequence
represents a node in the probability tree if left and right are both nullptr this node is a leave and...
base class for Huffman compression contains common methods and helper structures