// Two-three tree implementation for the Dictionary ADT template class TTTree : public Dictionary { private: TTNode* root; // Root of the tree int reccount; // Number of records stored // Private "helper" functions void clearhelp(TTNode*) // Helper functions { cout << "Clearhelp not yet defined\n"; } bool inserthelp(TTNode*&, const Elem&, Elem&, TTNode*&); void splitnode(TTNode* subroot, const Elem& inval, TTNode*inptr, Elem& retval, TTNode*& retptr); bool findhelp(TTNode*, const Key&, Elem&) const; void printhelp(TTNode*, int) const; public: TTTree() { root = NULL; reccount = 0; } ~TTTree() { clearhelp(root); } void clear() { clearhelp(root); root = NULL; reccount = 0; } bool insert(const Elem& e) { // Insert node with value val Elem retval; // Smallest value in newly created node TTNode* retptr = NULL; // Newly created node bool inssucc = inserthelp(root, e, retval, retptr); if (retptr != NULL) { // Root overflowed: make new root TTNode* temp = new TTNode; temp->lkey = retval; temp->left = root; temp->center = retptr; root = temp; } if (inssucc) reccount++; return inssucc; } bool remove(const Key& K, Elem& e) { cout << "Remove not implemented\n"; return false; } bool removeAny(Elem& e) { cout << "RemoveAny not implemented\n"; return false; } bool find(const Key& K, Elem& e) const { return findhelp(root, K, e); } int size() { return reccount; } void print() const { cout << "Print tree: \n"; if (root == NULL) cout << "The 2-3 Tree is empty.\n"; else printhelp(root, 0); } };