|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--Opus5.AbstractObject
|
+--Opus5.AbstractContainer
|
+--Opus5.AbstractTree
|
+--Opus5.MWayTree
A node in an M-way tree.
| Inner classes inherited from class Opus5.AbstractTree |
AbstractTree.TreeEnumeration |
| Field Summary | |
protected Comparable[] |
key
Array of keys. |
protected MWayTree[] |
subtree
Array of subtrees. |
| Fields inherited from class Opus5.AbstractContainer |
count |
| Fields inherited from interface Opus5.SearchTree |
copyright |
| Constructor Summary | |
MWayTree(int m)
Constructs an empty MWayTree with the specified order. |
|
| Method Summary | |
void |
breadthFirstTraversal(Visitor visitor)
Causes a visitor to visit the nodes of this tree in breadth-first traversal order starting from this node. |
protected int |
compareTo(Comparable arg)
Compares this M-way tree with the specified comparable object. |
void |
depthFirstTraversal(PrePostVisitor visitor)
Causes a visitor to visit the nodes of this tree in depth-first traversal order starting from this node. |
Comparable |
find(Comparable object)
Finds an object in this M-way tree that matches the specified object. |
protected int |
findIndex(Comparable object)
Finds the position of the specified object in the array of keys contained in this M-way tree node. |
Comparable |
findMax()
Finds the "largest" key in this M-way tree. |
Comparable |
findMin()
Finds the "smallest" key in this M-way tree. |
Comparable |
findV2(Comparable object)
Finds an object in this M-way tree that matches the specified object. |
int |
getCount()
Returns the number of keys in this M-way tree. |
int |
getDegree()
Returns the degree of this M-way tree node. |
Enumeration |
getEnumeration()
Returns an enumeration that enumerates the keys in this M-way tree. |
java.lang.Object |
getKey()
Undefined in an M-way tree node. |
java.lang.Object |
getKey(int i)
Returns the specified key in this M-way tree node. |
Tree |
getSubtree(int i)
Returns the specified subtree of this M-way tree node. |
void |
insert(Comparable object)
Inserts the specified object into this M-way tree. |
boolean |
isEmpty()
Tests whether this M-way tree node is empty. |
boolean |
isFull()
Tests whether this M-way tree node is full. |
boolean |
isLeaf()
Tests whether this M-way tree node is a leaf node. |
boolean |
isMember(Comparable object)
Tests whether the specified object is a key in this M-way tree. |
void |
purge()
Purges this M-way tree node, making it empty. |
void |
withdraw(Comparable object)
Withdraws the specfied object from this M-way tree. |
| Methods inherited from class Opus5.AbstractTree |
accept, getHeight |
| Methods inherited from class Opus5.AbstractContainer |
hashCode, toString |
| Methods inherited from class Opus5.AbstractObject |
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Opus5.Tree |
getHeight |
| Methods inherited from interface Opus5.Container |
accept |
| Methods inherited from interface Opus5.Comparable |
compare, isEQ, isGE, isGT, isLE, isLT, isNE |
| Field Detail |
protected Comparable[] key
protected MWayTree[] subtree
| Constructor Detail |
public MWayTree(int m)
MWayTree with the specified order.m - The desired order.java.lang.IllegalArgumentException - If the order is less than two.| Method Detail |
public void purge()
purge in interface Containerpublic void breadthFirstTraversal(Visitor visitor)
visit method of the visitor
for each node in this tree.
Uses a queue to keep track of the nodes to be visited.
The traversal continues as long as the isDone
method of the visitor returns false.breadthFirstTraversal in interface TreebreadthFirstTraversal in class AbstractTreevisitor - The visitor to accept.Visitorpublic boolean isEmpty()
isEmpty in interface TreeisEmpty in class AbstractContainerpublic boolean isFull()
isFull in interface ContainerisFull in class AbstractContainerpublic boolean isLeaf()
isLeaf in interface Treepublic int getDegree()
getDegree in interface Treepublic java.lang.Object getKey(int i)
i - The number of the key to return.InvalidOperationException - If this node is empty.public java.lang.Object getKey()
getKey in interface TreeInvalidOperationException - Always.public Tree getSubtree(int i)
getSubtree in interface Treei - The number of the subtree to return.InvalidOperationException - If this node is empty.public void depthFirstTraversal(PrePostVisitor visitor)
preVisit, inVisit
and postVisit methods of the visitor
for each node in this tree.depthFirstTraversal in interface TreedepthFirstTraversal in class AbstractTreevisitor - The visitor to accept.public int getCount()
getCount in interface ContainergetCount in class AbstractTreepublic Comparable find(Comparable object)
find in interface SearchableContainerobject - The object to match.null if the tree is empty.findV2(Opus5.Comparable)public boolean isMember(Comparable object)
isMember in interface SearchableContainerobject - The object for which to look.public Comparable findMin()
findMin in interface SearchTreenull if the tree is empty.public Comparable findMax()
findMax in interface SearchTreenull if the tree is empty.protected int findIndex(Comparable object)
object - The object for which to look.public Comparable findV2(Comparable object)
object - The object to match.null if the tree is empty.find(Opus5.Comparable)public void insert(Comparable object)
insert in interface SearchableContainerobject - The object to insert.java.lang.IllegalArgumentException - If there is already a matching object in this tree.public void withdraw(Comparable object)
withdraw in interface SearchableContainerobject - The object to withdraw.java.lang.IllegalArgumentException - If the specified object is not in this tree.public Enumeration getEnumeration()
getEnumeration in interface ContainergetEnumeration in class AbstractTreeprotected int compareTo(Comparable arg)
compareTo in class AbstractObjectarg - The comparable object with which to compare this tree.MethodNotImplemented - Always.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||