#include "huffman.h"
int Node::addParentNode(Node *pNode)
{
// add this node to either leg of parent node, starting from the left
if (pNode->pLeftChild == NULL)
{
pNode->pLeftChild = this;
}
else if (pNode->pRightChild == NULL)
{
pNode->pRightChild = this;
}
else
{
// this should never happen
return -1;
}
// add local frequency to parent's total
pNode->freqTotal += freqTotal;
return 0;
}
Node::Node(int initialCharCode)
{
this->freqTotal = 0;
this->charCode = initialCharCode;
this->pParent = NULL;
this->pLeftChild = NULL;
this->pRightChild = NULL;
} Powered by
GeSHi Syntax Highlighting software.
Author of all (other) material unless otherwise specified:
Loren Segal. Copyright 2005.