#ifndef __GTNODE__ #define __GTNODE__ #include using namespace std; template class GTNode { private: Elem element; GTNode* rent; GTNode* leftchild; GTNode* rightsib; public: GTNode(const Elem& value) // Constructor { rent = leftchild = rightsib = NULL; element = value ; } Elem value() // Return node's value { return element ; } bool isLeaf() // TRUE if node is a leaf { return leftchild == NULL ; } GTNode* parent() // Return node's parent { return rent ; } GTNode* leftmost_child() // Return node's first child { return leftfchild ; } GTNode* right_sibling() // Return node's right sibling { return rightsib ; } void setValue(Elem& value) // Set node's value { element = value ; } void insert_first(GTNode* n) // Insert as the first child { n->rightsib = leftchild; n->rent = this; leftchild = n; } void insert_next(GTNode* n) // Insert as the right sibling { n->rightsib = rightsib; n->rent = rent; rightsib = n; } }; #endif