New to Telerik UI for WinForms? Start a free 30-day trial

A red–black tree is a type of self-balancing binary search tree, a data structure used in computer science, typically to implement associative arrays.

Definition

Namespace:Telerik.Windows.Diagrams.Core

Assembly:Telerik.WinControls.RadDiagram.dll

Type Parameters:

TKey

The type of the key.

TValue

The type of the value.

Syntax:

C#
public class RedBlackTree<TKey, TValue> : RedBlackTree<KeyValuePair<TKey, TValue>>, ISearchTree<KeyValuePair<TKey, TValue>>, IEnumerable

Inheritance: objectBinarySearchTreeBase<KeyValuePair<TKey, TValue>>RedBlackTree<KeyValuePair<TKey, TValue>>RedBlackTree<TKey, TValue>

Implements: IEnumerableISearchTree<KeyValuePair<TKey, TValue>>

Inherited Members RedBlackTree<KeyValuePair<TKey, TValue>>.AddItem(KeyValuePair<TKey, TValue>)RedBlackTree<KeyValuePair<TKey, TValue>>.RemoveItem(KeyValuePair<TKey, TValue>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Clear()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[], int)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.DepthFirstTraversal(IVisitor<KeyValuePair<TKey, TValue>>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.GetEnumerator()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.GetOrderedEnumerator()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindMaximumNode(BinaryTree<KeyValuePair<TKey, TValue>>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindMinimumNode(BinaryTree<KeyValuePair<TKey, TValue>>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.ClearItems()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindMaximumNode()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindMinimumNode()BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindNode(KeyValuePair<TKey, TValue>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.FindNode<TSearch>(TSearch, BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.CustomComparison<TSearch>)BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.ComparerBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.CountBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.IsEmptyBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.IsReadOnlyBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.HeightBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.MaximumBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.MinimumBinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Tree...

Constructors

Initializes a new instance of the RedBlackTree<TKey, TValue> class.

C#
public RedBlackTree()

Initializes a new instance of the RedBlackTree<TKey, TValue> class.

C#
public RedBlackTree(Comparison<TKey> comparison)
Parameters:comparisonComparison<TKey>

The comparison.

Initializes a new instance of the RedBlackTree<TKey, TValue> class.

C#
public RedBlackTree(IComparer<TKey> comparer)
Parameters:comparerIComparer<TKey>

The comparer.

Properties

Keys

ICollection<TKey>

Gets an ICollection<T> containing the keys of the IDictionary<TKey, TValue>.

C#
public ICollection<TKey> Keys { get; }

Gets or sets the value with the specified key.

C#
public TValue this[TKey key] { get; set; }
Parameters:keyTKeyProperty Value:

The key of the item to set or get.

Values

ICollection<TValue>

Gets an ICollection<T> containing the values in the IDictionary<TKey, TValue>.

C#
public ICollection<TValue> Values { get; }

Methods

Adds an element with the provided key and value to the IDictionary<TKey, TValue>.

C#
public void Add(TKey key, TValue value)
Parameters:keyTKey

The object to use as the key of the element to add.

valueTValue

The object to use as the value of the element to add.

Determines whether this tree contains the given item.

C#
public override bool Contains(KeyValuePair<TKey, TValue> item)
Parameters:itemKeyValuePair<TKey, TValue>

The item.

Returns:

bool

true if the item is in this tree; otherwise, false.

Overrides: BinarySearchTreeBase<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue>)

Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.

C#
public bool ContainsKey(TKey key)
Parameters:keyTKey

The key to locate in the IDictionary<TKey, TValue>.

Returns:

bool

True if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.

Exceptions: ArgumentNullException

key is null.

Removes the element with the specified key from the IDictionary<TKey, TValue>.

C#
public bool Remove(TKey key)
Parameters:keyTKey

The key of the element to remove.

Returns:

bool

True if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary<TKey, TValue>.

Exceptions: ArgumentNullException

key is null.

NotSupportedException

The IDictionary<TKey, TValue> is read-only.

Attempts to the get value.

C#
public bool TryGetValue(TKey key, out TValue value)
Parameters:keyTKey

The key.

valueTValue

The value.

Returns:

bool