base class for Huffman compression contains common methods and helper structures
More...
#include <HuffmanBase.h>
|
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...
|
|
|
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 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 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...
|
|
base class for Huffman compression contains common methods and helper structures
Definition at line 45 of file HuffmanBase.h.
§ 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.
§ 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] | node | Root node of the probability tree |
[in] | bitSeq | Bit sequence until this point in the tree |
[out] | mapping | Constructed 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] | compressed | the compressed string containing the bit sequence |
[in] | root | the tree root with the encoding |
[in] | length | the amount of characters that are encoded in the compressed string |
[in,out] | result | the resulting string containing the decompressed string |
The documentation for this class was generated from the following file: