|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdsl.core.ref.HashtableDecorable
jdsl.core.ref.NodeBinaryTree.NBTNode
This is the class for all user-visible nodes It contains links for its parent, children, and element. It determines its container by asking its parent; the supernode will be at the end of a chain of parents, and it will know. All methods must be protected so subclasses can override them
Constructor Summary | |
protected |
NodeBinaryTree.NBTNode(NodeBinaryTree.NBTNode parent,
Object element)
make a new external node |
Method Summary | |
protected NodeBinaryTree |
container()
O(1) time |
Object |
element()
O(1) time |
protected void |
expand()
O(1) time Expands this node into an internal node Asserts if this node is external |
protected boolean |
isInternal()
O(1) time |
protected boolean |
isLeftChild()
O(1) time |
protected boolean |
isSuperNode()
Used to determine if this node is the super node |
protected NodeBinaryTree.NBTNode |
left()
O(1) time |
protected void |
makeUncontained()
O(1) time Makes this node uncontained |
protected NodeBinaryTree.NBTNode |
otherChild(NodeBinaryTree.NBTNode child)
O(1) time |
protected NodeBinaryTree.NBTNode |
parent()
O(1) time |
protected void |
removeSelfAndAbove()
O(1) time This method removes this node and its parent, replacing its parent with my sibling This is the asymmetric opposite of expand. |
protected Object |
replaceElement(Object newElement)
O(1) time Replaces my element, returning the old element |
protected void |
replaceSelf(NodeBinaryTree.NBTNode newSubtree)
O(1) time Replaces me with a new node, as far as my parent is concerned protected so restructurable trees can use it |
protected NodeBinaryTree.NBTNode |
right()
O(1) time |
protected void |
setChild(NodeBinaryTree.NBTNode currchild,
NodeBinaryTree.NBTNode newchild)
O(1) time Replaces one of my children with a new node protected to allow SuperNode to override it |
protected void |
setContainer(NodeBinaryTree x)
O(1) time Sets the parameter container as this node's container |
protected void |
setLeft(NodeBinaryTree.NBTNode x)
O(1) time Sets the parameter node as this node's left child |
protected void |
setParent(NodeBinaryTree.NBTNode x)
O(1) time Sets the parameter node as this node's parent |
protected void |
setRight(NodeBinaryTree.NBTNode x)
O(1) time Sets the parameter node as this node's right child |
String |
toString()
|
Methods inherited from class jdsl.core.ref.HashtableDecorable |
attributes, capacity, destroy, get, has, hash, rehash, set, size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface jdsl.core.api.Decorable |
attributes, destroy, get, has, set |
Constructor Detail |
protected NodeBinaryTree.NBTNode(NodeBinaryTree.NBTNode parent, Object element)
Method Detail |
public Object element()
element
in interface Accessor
protected NodeBinaryTree container()
protected NodeBinaryTree.NBTNode parent()
protected NodeBinaryTree.NBTNode left()
protected NodeBinaryTree.NBTNode right()
protected NodeBinaryTree.NBTNode otherChild(NodeBinaryTree.NBTNode child)
child
- of my children
protected boolean isInternal()
protected void setLeft(NodeBinaryTree.NBTNode x)
x
- nodeprotected void setRight(NodeBinaryTree.NBTNode x)
x
- nodeprotected void setParent(NodeBinaryTree.NBTNode x)
x
- nodeprotected void setContainer(NodeBinaryTree x)
protected boolean isLeftChild()
protected void makeUncontained()
protected void expand()
protected void removeSelfAndAbove()
protected void setChild(NodeBinaryTree.NBTNode currchild, NodeBinaryTree.NBTNode newchild)
currchild
- My current childnewchild
- The node to replace it withprotected void replaceSelf(NodeBinaryTree.NBTNode newSubtree)
newSubtree
- the node to replace me withprotected Object replaceElement(Object newElement)
newElement
- my new element
protected boolean isSuperNode()
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |