Huffman Zipper  v-1.0
Data Compression and Decompression using Greedy Huffman Algorithm
BinNode Class Reference

This class models a node structure used for building Huffman Binary Tree. More...

#include <BinNode.h>

Public Member Functions

 BinNode (char)
 
 BinNode (char, int)
 
bool operator< (const BinNode &)
 This method overloads less than operator for comparing node. More...
 
bool operator<= (const BinNode &)
 This method overloads less than and equal to (<=) operator for comparing node. More...
 
char getCharacter () const
 
int getFrequency () const
 
BinNodegetLeftChild () const
 
BinNodegetRightChild () const
 
void setLeftChild (BinNode *)
 sets parameter node as left child of the caller node instance. More...
 
void setRightChild (BinNode *)
 sets parameter node as left child of the caller node instance. More...
 
bool isLeaf ()
 

Private Attributes

char character
 Character present in input data. More...
 
int frequency
 Number of occurrence of a character. More...
 
BinNodeleftChild
 Pointer to the left child. More...
 
BinNoderightChild
 Pointer to the right child. More...
 

Friends

std::ostream & operator<< (std::ostream &, BinNode *)
 This method overloads insertion operator for printing node object. More...
 
std::ostream & operator<< (std::ostream &, const BinNode &)
 

Detailed Description

This class models a node structure used for building Huffman Binary Tree.

It stores character and frequency data in a binary tree of character-frequency pair.

Definition at line 9 of file BinNode.h.

Constructor & Destructor Documentation

◆ BinNode() [1/2]

BinNode::BinNode ( char  character)

Definition at line 3 of file BinNode.cpp.

◆ BinNode() [2/2]

BinNode::BinNode ( char  character,
int  frequency 
)

Definition at line 5 of file BinNode.cpp.

Member Function Documentation

◆ getCharacter()

char BinNode::getCharacter ( ) const
Returns
character present in the caller node instance.

Definition at line 25 of file BinNode.cpp.

◆ getFrequency()

int BinNode::getFrequency ( ) const
Returns
frequency of character present in the caller node instance.

Definition at line 29 of file BinNode.cpp.

◆ getLeftChild()

BinNode * BinNode::getLeftChild ( ) const
Returns
pointer to the left child of the caller node instance.

Definition at line 41 of file BinNode.cpp.

◆ getRightChild()

BinNode * BinNode::getRightChild ( ) const
Returns
pointer to the right child of the caller node instance.

Definition at line 45 of file BinNode.cpp.

◆ isLeaf()

bool BinNode::isLeaf ( )
Returns
true if the caller node instance is leaf node.

Definition at line 49 of file BinNode.cpp.

◆ operator<()

bool BinNode::operator< ( const BinNode other)

This method overloads less than operator for comparing node.

Returns
true if frequency of caller node is less than that of parameter node.

Definition at line 17 of file BinNode.cpp.

◆ operator<=()

bool BinNode::operator<= ( const BinNode other)

This method overloads less than and equal to (<=) operator for comparing node.

Returns
true if frequency of caller node is less than and equal to that of parameter node.

Definition at line 21 of file BinNode.cpp.

◆ setLeftChild()

void BinNode::setLeftChild ( BinNode left)

sets parameter node as left child of the caller node instance.


Definition at line 33 of file BinNode.cpp.

◆ setRightChild()

void BinNode::setRightChild ( BinNode right)

sets parameter node as left child of the caller node instance.


Definition at line 37 of file BinNode.cpp.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  os,
BinNode node 
)
friend

This method overloads insertion operator for printing node object.

Definition at line 7 of file BinNode.cpp.

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const BinNode node 
)
friend

Definition at line 12 of file BinNode.cpp.

Member Data Documentation

◆ character

char BinNode::character
private

Character present in input data.


Definition at line 11 of file BinNode.h.

◆ frequency

int BinNode::frequency
private

Number of occurrence of a character.


Definition at line 12 of file BinNode.h.

◆ leftChild

BinNode* BinNode::leftChild
private

Pointer to the left child.


Definition at line 13 of file BinNode.h.

◆ rightChild

BinNode* BinNode::rightChild
private

Pointer to the right child.


Definition at line 14 of file BinNode.h.