ApparatusFramework::HuffmanCodingStringCompression Class Reference
[Pattern Services]

#include <PatternServices/current/include/HuffmanCoding.h>

List of all members.


struct  huff_bitstream_t
struct  huff_symbol_t

Public Member Functions

 HuffmanCodingStringCompression ()
virtual ~HuffmanCodingStringCompression ()
 HuffmanCodingStringCompression (const HuffmanCodingStringCompression &lvalue)
const char * encodeString (const char *decodedData, float &compressionRatio, uint16 &length)
const char * decodeString (const unsigned char *encodedData)

Detailed Description

Huffman coding is a variant of a table compression pattern. The key of table compression is that some characters are statistically much more likely occur than others. You can easily map from a standard fixed size representation to one where each character takes a different number of bits. If you analyze the kind of text you are compressing to find which characters are most propable, and map these characters to the most compact encoding, then on average you will end up with smaller text.

In fact huffman coding is encoded with the huffman tree, a special type of binary tree. The technique works by creating a binary tree of nodes. These can be stored in a regular array, the size of which depends on the number of symbols(N). A node can be either a leaf node or an internal node. Initially, all nodes are leaf nodes, which contain the symbol itself, the weight (frequency of appearance) of the symbol and optionally, a link to a parent node which makes it easy to read the code (in reverse) starting from a leaf node. Internal nodes contain symbol weight, links to two child nodes and the optional link to a parent node. As a common convention, bit '0' represents following the left child and bit '1' represents following the right child. A finished tree has N leaf nodes and N-1 internal nodes.

The frequencies used are the actual frequencies found in the text being compressed. (This requires that a frequency table or other hint as to the encoding is stored with the compressed text.)

Huffman coding string compression provides the functionality to compress and decompress a string according the huffman coding table pattern.

Remark: Do NOT use this algorithm for short strings, because the generated huffman table is included in the compressed text!

Definition at line 82 of file HuffmanCoding.h.

Constructor & Destructor Documentation

ApparatusFramework::HuffmanCodingStringCompression::HuffmanCodingStringCompression (  ) 

Construction and destruction Default constructor. Constructs a new object of this class.

virtual ApparatusFramework::HuffmanCodingStringCompression::~HuffmanCodingStringCompression (  )  [virtual]

Destroys the object and releases all used resources.

ApparatusFramework::HuffmanCodingStringCompression::HuffmanCodingStringCompression ( const HuffmanCodingStringCompression lvalue  ) 

Copy constructor.

lvalue compress file object to be copied.

Member Function Documentation

const char* ApparatusFramework::HuffmanCodingStringCompression::decodeString ( const unsigned char *  encodedData  ) 

To decode encoded strings.

encodedData encoded string which is to decode.
returns the decoded string.
const char* ApparatusFramework::HuffmanCodingStringCompression::encodeString ( const char *  decodedData,
float &  compressionRatio,
uint16 length 

Operators Operator methods for the class. Helpers Methods used internally to implement more complex functionalities. To encode a strings.

decodedData decoded string which is to encode.
compressionRatio compression ratio by reference.
length string length by reference.
returns the encoded string.
© 2004-2010 bbv Software Services AG / Apparatus Services