My Project
Loading...
Searching...
No Matches
Node Class Reference

Represents a single element (leaf or interior node) in the Huffman tree. More...

#include <Node.h>

Public Member Functions

 Node (uint8_t symbol, uint64_t frequency)
 Constructor for a new Node.
uint64_t getFrequency () const
 Gets the frequency of the node.

Static Public Member Functions

static Nodejoin (Node *leftChild, Node *rightChild)
 Joins two child nodes to create an interior parent node.

Friends

class Huffman

Detailed Description

Represents a single element (leaf or interior node) in the Huffman tree.

Constructor & Destructor Documentation

◆ Node()

Node::Node ( uint8_t symbol,
uint64_t frequency )

Constructor for a new Node.

Parameters
symbolThe 8-bit character this node represents.
frequencyThe number of times this symbol appears in the input data.

Member Function Documentation

◆ getFrequency()

uint64_t Node::getFrequency ( ) const
inline

Gets the frequency of the node.

Returns
The occurrence count of the symbol.

◆ join()

Node * Node::join ( Node * leftChild,
Node * rightChild )
static

Joins two child nodes to create an interior parent node.

  • The new parent node will have the symbol '$' and a frequency equal to the sum of its children's frequencies.
  • Parameters
    leftChildPointer to the node that will become the left child.
    rightChildPointer to the node that will become the right child.
    Returns
    Pointer to the newly dynamically allocated parent node.

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