ClassRBTreeBase<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
RBTreeBase(IComparer<T>, bool)
Tree constructor with comparer
Declaration
public RBTreeBase(IComparer<T> aComparer, bool unique)
Parameters
aComparer
IComparer<T>
unique
RBTreeBase(bool)
Tree constructor
Fields
Properties
Collection
Get collection object for this
Declaration
public IList<T> Collection { get; }
Property Value
IList<T>
Count
Number of nodes in the tree
SyncRoot
Object can be used for synchronization
Methods
Add(T)
Add new key into the tree
This operation is O(logN) operation
Declaration
public N Add(T aKey)
Parameters
aKey
T
Returns
N
Exceptions
In case the key is already in the tree
AddOrGet(T)
Add new key into the tree or get existing node This operation is O(logN) operation
Declaration
public N AddOrGet(T aKey)
Parameters
aKey
T
Returns
N
Balance(RBTreeNodeBase<T, P>)
Balance tree past inserting
Declaration
protected void Balance(RBTreeNodeBase<T, P> z)
Parameters
z
RBTreeNodeBase<T, P>
Delete(RBTreeNodeBase<T, P>)
Delete the node z, and free up the space
Declaration
protected virtual void Delete(RBTreeNodeBase<T, P> z)
Parameters
z
RBTreeNodeBase<T, P>
DeleteFix(RBTreeNodeBase<T, P>)
Restore the reb-black properties after a delete
Declaration
protected void DeleteFix(RBTreeNodeBase<T, P> x)
Parameters
x
RBTreeNodeBase<T, P>
Find(T)
Find key in the dictionary This operation is O(logN) operation
Declaration
public N Find(T aKey)
Parameters
aKey
T
Returns
N
First()
Get first node This operation is O(logN) operation
Declaration
public N First()
Returns
N
Last()
Get last node This operation is O(logN) operation
Declaration
public N Last()
Returns
N
LeftRotate(RBTreeNodeBase<T, P>)
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
Declaration
protected void LeftRotate(RBTreeNodeBase<T, P> x)
Parameters
x
RBTreeNodeBase<T, P>
NewNode()
Create new node
Declaration
protected abstract RBTreeNodeBase<T, P> NewNode()
Returns
RBTreeNodeBase<T, P>
Next(N)
Get next node This operation is O(logN) operation
Declaration
public N Next(N aNode)
Parameters
aNode
N
Returns
N
Predecessor(RBTreeNodeBase<T, P>)
Return a pointer to the largest key smaller than x
Declaration
protected RBTreeNodeBase<T, P> Predecessor(RBTreeNodeBase<T, P> x)
Parameters
x
RBTreeNodeBase<T, P>
Returns
RBTreeNodeBase<T, P>
Previous(N)
Get previous node This operation is O(logN) operation
Declaration
public N Previous(N aNode)
Parameters
aNode
N
Returns
N
Remove(N)
Remove node from the dictionary This operation is O(1) operation
Remove(T)
Remove key from the dictionary This operation is O(logN) operation
RightRotate(RBTreeNodeBase<T, P>)
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
Declaration
protected void RightRotate(RBTreeNodeBase<T, P> y)
Parameters
y
RBTreeNodeBase<T, P>
Successor(RBTreeNodeBase<T, P>)
Return a pointer to the smallest key greater than x
Declaration
protected RBTreeNodeBase<T, P> Successor(RBTreeNodeBase<T, P> x)
Parameters
x
RBTreeNodeBase<T, P>
Returns
RBTreeNodeBase<T, P>