clockUtils  1.1
clockUtils::compression::algorithm::HuffmanBase Class Reference

base class for Huffman compression contains common methods and helper structures More...

#include <HuffmanBase.h>

Inheritance diagram for clockUtils::compression::algorithm::HuffmanBase:
Inheritance graph

Classes

struct  Node
 represents a node in the probability tree if left and right are both nullptr this node is a leave and c has a valid value More...
 

Protected Types

typedef 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. More...
 

Static Protected Member Functions

static std::shared_ptr< NodebuildTree (const std::vector< uint8_t > &header)
 creates a Huffman tree with given list of probabilities header must have size 256 and values have to be between 0 and 255 (unsigned char) if a value is zero no node is inserted into the tree and this value isn't accessible More...
 
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 More...
 
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 More...
 

Detailed Description

base class for Huffman compression contains common methods and helper structures

Definition at line 45 of file HuffmanBase.h.

Member Typedef Documentation

§ len_t

type that should be used as the 'length' counter This controls the size of the header, the maximum string length etc.

Definition at line 51 of file HuffmanBase.h.

Member Function Documentation

§ buildTree()

static std::shared_ptr<Node> clockUtils::compression::algorithm::HuffmanBase::buildTree ( const std::vector< uint8_t > &  header)
staticprotected

creates a Huffman tree with given list of probabilities header must have size 256 and values have to be between 0 and 255 (unsigned char) if a value is zero no node is inserted into the tree and this value isn't accessible

§ generateMapping()

static void clockUtils::compression::algorithm::HuffmanBase::generateMapping ( const std::shared_ptr< Node > &  node,
const std::vector< bool > &  bitSeq,
std::vector< std::vector< bool >> &  mapping 
)
staticprotected

constructs a mapping from character to a bit sequence

Parameters
[in]nodeRoot node of the probability tree
[in]bitSeqBit sequence until this point in the tree
[out]mappingConstructed mapping

§ getChar()

static ClockError clockUtils::compression::algorithm::HuffmanBase::getChar ( const std::string &  compressed,
const std::shared_ptr< Node > &  root,
len_t  length,
std::string &  result 
)
staticprotected

converts bit sequence to the real character

Parameters
[in]compressedthe compressed string containing the bit sequence
[in]rootthe tree root with the encoding
[in]lengththe amount of characters that are encoded in the compressed string
[in,out]resultthe resulting string containing the decompressed string

The documentation for this class was generated from the following file: