implementation of Red-Black Tree More...
#include <wl.h>
Public Member Functions | |
| RBTree () | |
| Constructor of RBTree. More... | |
| ~RBTree () | |
| Destructor of RBTree. More... | |
| void | insert (wpp_t newword) |
| Insert a word-pos pair into the tree. More... | |
| void | clear () |
| Clear the tree. More... | |
| TreeNode * | getNode (string word) |
| Get the node that stores the word. More... | |
| void | printTree () |
implementation of Red-Black Tree
| RBTree::RBTree | ( | ) |
Constructor of RBTree.
Not much to be done. Initialize the root pointer to NULL
| RBTree::~RBTree | ( | ) |
Destructor of RBTree.
Rree all nodes
| void RBTree::clear | ( | ) |
Clear the tree.
Clear the tree by free and delete all nodes. Root is set to NULL
| TreeNode * RBTree::getNode | ( | string | word | ) |
Get the node that stores the word.
Locate and return the node that saves the occurance of the word
| word | - A string word that is needed to locate and return |
| void RBTree::insert | ( | wpp_t | newword | ) |
Insert a word-pos pair into the tree.
Insert new word, either add to existing or create new node
| newword | - wpp_t stucture with {word, pos} |
| void RBTree::printTree | ( | ) |
Public method to in-order print tree
1.8.6