SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | List of all members
SLNet::HuffmanEncodingTree Class Reference

This generates special cases of the huffman encoding tree using 8 bit keys with the additional condition that unused combinations of 8 bits are treated as a frequency of 1. More...

`#include <slikenet/DS_HuffmanEncodingTree.h>`

## Public Member Functions

| HuffmanEncodingTree ()
| ~HuffmanEncodingTree ()
void | EncodeArray (unsigned char *input, size_t sizeInBytes, SLNet::BitStream *output)
| Pass an array of bytes to array and a preallocated BitStream to receive the output.
unsigned | DecodeArray (SLNet::BitStream *input, BitSize_t sizeInBits, size_t maxCharsToWrite, unsigned char *output)
void | DecodeArray (unsigned char *input, BitSize_t sizeInBits, SLNet::BitStream *output)
void | GenerateFromFrequencyTable (unsigned int frequencyTable[256])
| Given a frequency table of 256 elements, all with a frequency of 1 or more, generate the tree.
void | FreeMemory (void)
| Free the memory used by the tree.

## Detailed Description

This generates special cases of the huffman encoding tree using 8 bit keys with the additional condition that unused combinations of 8 bits are treated as a frequency of 1.

Definition at line 34 of file DS_HuffmanEncodingTree.h.

## Constructor & Destructor Documentation

HuffmanEncodingTree::HuffmanEncodingTree | ( |  | ) |

Definition at line 23 of file DS_HuffmanEncodingTree.cpp.

HuffmanEncodingTree::~HuffmanEncodingTree | ( |  | ) |

Definition at line 28 of file DS_HuffmanEncodingTree.cpp.

References FreeMemory().

## Member Function Documentation

unsigned HuffmanEncodingTree::DecodeArray | ( | SLNet::BitStream * | input,
|  | BitSize_t | sizeInBits,
|  | size_t | maxCharsToWrite,
|  | unsigned char * | output
| ) |  |

Definition at line 200 of file DS_HuffmanEncodingTree.cpp.

References if(), HuffmanEncodingTreeNode::left, SLNet::BitStream::ReadBit(), HuffmanEncodingTreeNode::right, and HuffmanEncodingTreeNode::value.

Referenced by SLNet::StringCompressor::DecodeString(), and SLNet::DataCompressor::DecompressAndAllocate().

void HuffmanEncodingTree::DecodeArray | ( | unsigned char * | input,
|  | BitSize_t | sizeInBits,
|  | SLNet::BitStream * | output
| ) |  |

Definition at line 233 of file DS_HuffmanEncodingTree.cpp.

References BITS_TO_BYTES, if(), HuffmanEncodingTreeNode::left, SLNet::BitStream::ReadBit(), return, HuffmanEncodingTreeNode::right, HuffmanEncodingTreeNode::value, and SLNet::BitStream::WriteBits().

void HuffmanEncodingTree::EncodeArray | ( | unsigned char * | input,
|  | size_t | sizeInBytes,
|  | SLNet::BitStream * | output
| ) |  |

Pass an array of bytes to array and a preallocated BitStream to receive the output.

Parameters

  [in] | input | Array of bytes to encode
  [in] | sizeInBytes | size of input
  [out] | output | The bitstream to write to

Definition at line 169 of file DS_HuffmanEncodingTree.cpp.

References SLNet::BitStream::GetNumberOfBitsUsed(), RakAssert, and SLNet::BitStream::WriteBits().

Referenced by SLNet::DataCompressor::Compress(), and SLNet::StringCompressor::EncodeString().

void HuffmanEncodingTree::FreeMemory | ( | void |  | ) |

Free the memory used by the tree.

Definition at line 33 of file DS_HuffmanEncodingTree.cpp.

References _FILE_AND_LINE_, HuffmanEncodingTreeNode::left, SLNet::OP_DELETE(), DataStructures::Queue< queue_type >::Pop(), DataStructures::Queue< queue_type >::Push(), rakFree_Ex, return, HuffmanEncodingTreeNode::right, and DataStructures::Queue< queue_type >::Size().

Referenced by GenerateFromFrequencyTable(), and ~HuffmanEncodingTree().

void HuffmanEncodingTree::GenerateFromFrequencyTable | ( | unsigned int | frequencyTable[256] | ) |

Given a frequency table of 256 elements, all with a frequency of 1 or more, generate the tree.

Definition at line 69 of file DS_HuffmanEncodingTree.cpp.

References _FILE_AND_LINE_, DataStructures::CircularLinkedList< LinkedListType >::Beginning(), SLNet::BitStream::CopyData(), FreeMemory(), HuffmanEncodingTreeNode::left, HuffmanEncodingTreeNode::parent, DataStructures::CircularLinkedList< LinkedListType >::Pop(), SLNet::BitStream::Reset(), HuffmanEncodingTreeNode::right, DataStructures::CircularLinkedList< LinkedListType >::Size(), HuffmanEncodingTreeNode::value, HuffmanEncodingTreeNode::weight, SLNet::BitStream::Write0(), and SLNet::BitStream::Write1().

Referenced by SLNet::DataCompressor::Compress(), SLNet::DataCompressor::DecompressAndAllocate(), SLNet::StringCompressor::GenerateTreeFromStrings(), and SLNet::StringCompressor::StringCompressor().

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

- Source/include/slikenet/DS_HuffmanEncodingTree.h
- Source/src/DS_HuffmanEncodingTree.cpp