1 #ifndef COMPRESSOR_H_INCLUDED
2 #define COMPRESSOR_H_INCLUDED
9 typedef unsigned char GLubyte;
28 auto getEncodings(crstring enc =
"") const -> std::map<GLubyte,std::
string>;
50 GLubyte getData()
const;
56 static std::string toBinary(
int num,
int numBits = 8);
58 static int fromBinary(crstring num);
60 static void createTree(
const std::vector<GLubyte>& data);
67 static std::vector<GLubyte> decompress(
const std::vector<GLubyte>& data);
69 static std::vector<GLubyte> compress(
const std::vector<GLubyte>& data);
73 #endif // COMPRESSOR_H_INCLUDED
A node in a Huffman tree.
auto getEncodings(crstring enc="") const -> std::map< GLubyte, std::string >
returns map of all the bytes and how they are encoded
HuffmanNode()
basic constructor
bool hasChildren() const
returns whether or not the node has children
virtual ~HuffmanNode()
recursively destroys node
Static class for compressing byte buffers.
static HuffmanNode * m_root
the root of the created Huffman tree
int getFrequency() const
returns the frequency of the node
represents a leaf in a Huffman tree
static std::map< GLubyte, std::string > m_encodings
the encodings generated from the tree
HuffmanNode * getLeft() const
returns children
HuffmanNode * m_lChild
the children of the node
GLubyte m_data
the byte associated with the leaf
int m_freq
the frequency of the nodes associated bytes