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
Modifier and TypeFieldDescriptionThis is effectively the key, though order and indexing is done throughInterval.getMin()
.protected boolean
protected K
TheInterval.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 V
A value associated with the interval. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copyData
(IntervalTree<K, V>.RBNode that) Copy data members (not tree structure members) from another RBNode.void
protected void
protected 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.void
protected void
Returns the new "top" of the sub tree.protected void
Returns the new "top" of the sub tree.protected void
protected IntervalTree<K,
V>.RBNode Returns the successor to a node or RBNULL if there is none.void
Update themax
value for this node, considering children that are not RBNULL and the interval.void
Walk up the tree until we are at an RBNULL node and update themax
value.
-
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 themax
invalid. 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 themax
value 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 themax
value.- See Also:
-