Huffman coding: Difference between revisions

(added Fantom example)
Line 630:
{
public:
const int f;
 
virtual ~INode() {}
Line 641:
{
public:
INode *const children[2]left;
INode *const right;
 
InternalNode(INode* c0, INode* c1) : INode(c0->f + c1->f), left(c0), right(c1) {}
{
children[0] = c0;
children[1] = c1;
}
~InternalNode()
{
delete children[0]left;
delete children[1]right;
}
};
Line 658 ⟶ 655:
{
public:
const char c;
 
LeafNode(int f, char c) : INode(f), c(c) {}
{}
};
 
struct NodeCmp
{
bool operator()(const INode* lhs, const INode* rhs) { return (lhs->f > rhs->f); }
};
 
Anonymous user