RBTreeBase<T, N, P>
Base class for the tree. Based on the Damian Ivereigh implementation Support for the multi-trees has been added. Do not use this class directly. Use RBTree, RBMultiTree, RBOrderedTree and RBOrderedMultiTree classes
Definition
Namespace:Telerik.Collections.Generic
Assembly:Telerik.WinControls.dll
Type Parameters:
T
Key type
N
Node type
P
Node parameter type
Syntax:
public abstract class RBTreeBase<T, N, P> : ISortedTree<T>, ITree<T>, IEnumerable where N : RBTreeNodeBase<T, P>, new()
Inheritance: objectRBTreeBase<T, N, P>
Derived Classes:
Implements:
Constructors
Tree constructor
Tree constructor with comparer
public RBTreeBase(IComparer<T> aComparer, bool unique)
Fields
mRoot
RBTreeNodeBase<T, P>
protected RBTreeNodeBase<T, P> mRoot
Properties
Collection
IList<T>
Get collection object for this
public IList<T> Collection { get; }
Root
N
Root of the tree
public N Root { get; }
Methods
Add new key into the tree
This operation is O(logN) operation
public N Add(T aKey)
N
Exceptions:In case the key is already in the tree
Add new key into the tree or get existing node This operation is O(logN) operation
public N AddOrGet(T aKey)
N
Balance tree past inserting
Remove all items
public void Clear()
Delete the node z, and free up the space
Restore the reb-black properties after a delete
Find key in the dictionary This operation is O(logN) operation
public N Find(T aKey)
N
Get first node This operation is O(logN) operation
public N First()
N
Get last node This operation is O(logN) operation
public N Last()
N
Rotate our tree Left
X rb_left_rotate(X)---> Y
/ \ / \
A Y X C
/ \ / \
B C A B
N.B. This does not change the ordering.
We assume that neither X or Y is NULL
Create new node
Get next node This operation is O(logN) operation
public N Next(N aNode)
N
Return a pointer to the largest key smaller than x
protected RBTreeNodeBase<T, P> Predecessor(RBTreeNodeBase<T, P> x)
RBTreeNodeBase<T, P>
Get previous node This operation is O(logN) operation
public N Previous(N aNode)
N
Remove node from the dictionary This operation is O(1) operation
Remove key from the dictionary This operation is O(logN) operation
Rotate our tree Right
X Y
/ \ / \
A Y leftArrow--rb_right_rotate(Y) X C
/ \ / \
B C A B
N.B. This does not change the ordering.
We assume that neither X or Y is NULL
Return a pointer to the smallest key greater than x
protected RBTreeNodeBase<T, P> Successor(RBTreeNodeBase<T, P> x)
RBTreeNodeBase<T, P>