Package com.github.basking2.sdsai
Class IntervalTree.RBNode
java.lang.Object
com.github.basking2.sdsai.IntervalTree.RBNode
- Enclosing class:
- IntervalTree<K extends Comparable<K>,
V>
How a tree is represented.
The advantages to this internal class are:
- Truly empty data structure state.
- We can avoid recursion when "appropriate."
- We can compute and save global info like tree size.
- We can avoid recursion when "appropriate."
- We can compute and save global info like tree size.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThis is effectively the key, though order and indexing is done throughInterval.getMin().protected booleanprotected KTheInterval.getMin()value used to order and index nodes in the Red Black tree.protected IntervalTree<K,V>.RBNode protected IntervalTree<K,V>.RBNode protected IntervalTree<K,V>.RBNode protected VA value associated with the interval. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyData(IntervalTree<K, V>.RBNode that) Copy data members (not tree structure members) from another RBNode.voidprotected voidprotected IntervalTree<K,V>.RBNode max()protected IntervalTree<K,V>.RBNode min()protected IntervalTree<K,V>.RBNode Returns the predecessor to a node or RBNULL if there is none.voidprotected voidReturns the new "top" of the sub tree.protected voidReturns the new "top" of the sub tree.protected voidprotected IntervalTree<K,V>.RBNode Returns the successor to a node or RBNULL if there is none.voidUpdate themaxvalue for this node, considering children that are not RBNULL and the interval.voidWalk up the tree until we are at an RBNULL node and update themaxvalue.
-
Field Details
-
isBlack
protected boolean isBlack -
key
TheInterval.getMin()value used to order and index nodes in the Red Black tree. -
interval
This is effectively the key, though order and indexing is done throughInterval.getMin(). -
value
A value associated with the interval. -
parent
-
left
-
right
-
-
Constructor Details
-
RBNode
protected RBNode(boolean b) -
RBNode
-
-
Method Details
-
copyData
Copy data members (not tree structure members) from another RBNode. NOTE: This may make themaxinvalid. The functionupdateMax()should be called.- Parameters:
that- The node to copy data from.- See Also:
-
print
-
min
-
max
-
setMax
-
successor
Returns the successor to a node or RBNULL if there is none. -
predecessor
Returns the predecessor to a node or RBNULL if there is none. Reverse of successor function. -
rotateRight
protected void rotateRight()Returns the new "top" of the sub tree. -
rotateLeft
protected void rotateLeft()Returns the new "top" of the sub tree. -
insertFixup
protected void insertFixup() -
deleteFixup
public void deleteFixup() -
updateMax
public void updateMax()Update themaxvalue for this node, considering children that are not RBNULL and the interval. If this node is also RBNULL, this does nothing. -
updateMaxAncestry
public void updateMaxAncestry()Walk up the tree until we are at an RBNULL node and update themaxvalue.- See Also:
-