// From the software distribution accompanying the textbook // "A Practical Introduction to Data Structures and Algorithm Analysis, // Third Edition (C++)" by Clifford A. Shaffer. // Source code Copyright (C) 2007-2011 by Clifford A. Shaffer. // HuffTree is a template of two parameters: the element // type being coded and a comparator for two such elements. template class HuffTree { private: HuffNode* Root; // Tree root public: HuffTree(E& val, int freq) // Leaf constructor { Root = new LeafNode(val, freq); } // Internal node constructor HuffTree(HuffTree* l, HuffTree* r) { Root = new IntlNode(l->root(), r->root()); } ~HuffTree() {} // Destructor HuffNode* root() { return Root; } // Get root int weight() { return Root->weight(); } // Root weight };