My Project
 
Loading...
Searching...
No Matches
HuffmanNode Struct Reference

Represents a node in the Huffman encoding tree. More...

#include <Huffman.hpp>

Collaboration diagram for HuffmanNode:
Collaboration graph

Classes

struct  CompareNodes
 Comparator for use in priority queues (min-heap). More...
 

Public Member Functions

 HuffmanNode (uint8_t character, uint64_t frecuency)
 Constructor for a leaf node.
 
 HuffmanNode (uint8_t character, uint64_t frecuency, unique_ptr< HuffmanNode > lft, unique_ptr< HuffmanNode > rght)
 Constructor for an internal node.
 

Public Attributes

uint8_t ch
 The character stored in this node (only valid for leaf nodes).
 
uint64_t fr
 The frequency of the character or combined frequency of children.
 
unique_ptr< HuffmanNodeleft
 Pointer to the left child node.
 
unique_ptr< HuffmanNoderight
 Pointer to the right child node.
 

Detailed Description

Represents a node in the Huffman encoding tree.

Each node contains a character and its frequency, along with optional left and right child nodes for internal tree structure. Leaf nodes hold characters, while internal nodes combine frequencies.

Constructor & Destructor Documentation

◆ HuffmanNode() [1/2]

HuffmanNode::HuffmanNode ( uint8_t character,
uint64_t frecuency )

Constructor for a leaf node.

Parameters
characterThe character stored in the node.
frecuencyThe frequency of the character.

◆ HuffmanNode() [2/2]

HuffmanNode::HuffmanNode ( uint8_t character,
uint64_t frecuency,
unique_ptr< HuffmanNode > lft,
unique_ptr< HuffmanNode > rght )

Constructor for an internal node.

Parameters
characterThe character stored.
frecuencyThe combined frequency of the child nodes.
lftLeft child node.
rghtRight child node.

Member Data Documentation

◆ ch

uint8_t HuffmanNode::ch

The character stored in this node (only valid for leaf nodes).

◆ fr

uint64_t HuffmanNode::fr

The frequency of the character or combined frequency of children.

◆ left

unique_ptr<HuffmanNode> HuffmanNode::left

Pointer to the left child node.

◆ right

unique_ptr<HuffmanNode> HuffmanNode::right

Pointer to the right child node.


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