deleteNode
You have seen how the optionally recursive node deletion works. Now let's look at the public method by which a user application deletes a BonNode from a ForestHashtable. Here is the source code for its deleteNode() method:
public boolean deleteNode(NodeKey keyOfNodeToDelete, boolean leafOnly) { if(this.containsKey(keyOfNodeToDelete)) { if(leafOnly) {
if(hasAtLeastOneChild(keyOfNodeToDelete)) {
return false;// was not a leaf node, so not deleted
return doDeleteNodeRecursive(keyOfNodeToDelete);
return false; // no such node
You can see how easy node access is when you have the NodeKey. Of course, this does not require the three keys in the NodeKey, as discussed at the beginning of this chapter.
But it is rather nice to have one key encoding both order in a table and hierarchy in a tree at the same time. It would be more expensive to keep these two potentially independent factors in separate objects.
Post a comment