Class RedBlackTreeDictionary<TKey, TValue>
Sorted dictionary based on a red-black tree.
Inheritance
Namespace: ISynergy.Framework.Core.Collections
Assembly: ISynergy.Framework.Core.dll
Syntax
public class RedBlackTreeDictionary<TKey, TValue> : IDictionary<TKey, TValue>
Type Parameters
Name | Description |
---|---|
TKey | The type of keys in the collection. |
TValue | The type of the values in the collection |
Constructors
View SourceRedBlackTreeDictionary()
Creates a new RedBlackTreeDictionary<TKey, TValue>
using the default comparer for the TKey
.
Declaration
public RedBlackTreeDictionary()
RedBlackTreeDictionary(IComparer<TKey>)
Creates a new RedBlackTreeDictionary<TKey, TValue>.
Declaration
public RedBlackTreeDictionary(IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IComparer<TKey> | comparer |
Properties
View SourceCount
Gets the number of elements on this dictionary.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Gets a value indicating whether this instance is read only.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Returns |
Item[TKey]
Gets or sets the element with the specified key.
Declaration
public TValue this[TKey key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key. |
Property Value
Type | Description |
---|---|
TValue |
Keys
Gets an ICollection{T} containing the keys of the RedBlackTreeDictionary<TKey, TValue>.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<TKey> |
Values
Gets an ICollection{T} containing the values of the RedBlackTreeDictionary<TKey, TValue>.
Declaration
public ICollection<TValue> Values { get; }
Property Value
Type | Description |
---|---|
ICollection<TValue> |
Methods
View SourceAdd(TKey, TValue)
Adds an element with the provided key and value to the IDictionary<, >.
Declaration
public void Add(TKey key, TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The object to use as the key of the element to add. |
TValue | value | The object to use as the value of the element to add. |
Add(KeyValuePair<TKey, TValue>)
Adds an element with the provided key and value to the dictionary.
Declaration
public void Add(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The |
Clear()
Removes all elements from the dictionary.
Declaration
public void Clear()
Contains(KeyValuePair<TKey, TValue>)
Determines whether the dictionary contains a specific value.
Declaration
public bool Contains(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The object to locate in the dictionary. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ContainsKey(TKey)
Determines whether the dictionary contains an element with the specified key.
Declaration
public bool ContainsKey(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key to locate in the dictionary. |
Returns
Type | Description |
---|---|
System.Boolean |
|
CopyTo(KeyValuePair<TKey, TValue>[], Int32)
Copies the elements of this dictionary to an array, starting at a particular array index.
Declaration
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue>[] | array | The one-dimensional Array that is the destination of the elements copied from ICollection. The array must have zero-based indexing. |
System.Int32 | arrayIndex | The zero-based index in array at which copying begins. |
GetEnumerator()
Returns an enumerator that iterates through the dictionary.
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<TKey, TValue>> | An IEnumerator{T} object that can be used to iterate through the collection. |
GetNext(TKey)
Gets the next key-value pair in the dictionary whose key is
the immediate successor to the given key
.
Declaration
public KeyValuePair<TKey, TValue> GetNext(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose successor must be found. |
Returns
Type | Description |
---|---|
KeyValuePair<TKey, TValue> | The key-value pair whose key is the immediate successor of |
GetPrevious(TKey)
Gets the next key-value pair in the dictionary whose key is
the immediate ancestor of the given key
.
Declaration
public KeyValuePair<TKey, TValue> GetPrevious(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose ancestor must be found. |
Returns
Type | Description |
---|---|
KeyValuePair<TKey, TValue> | The key-value pair whose key is the immediate ancestor of |
Max()
Gets the pair with the maximum key
stored in the dictionary.
Declaration
public KeyValuePair<TKey, TValue> Max()
Returns
Type | Description |
---|---|
KeyValuePair<TKey, TValue> | The |
Min()
Gets the pair with the minimum key
stored in the dictionary.
Declaration
public KeyValuePair<TKey, TValue> Min()
Returns
Type | Description |
---|---|
KeyValuePair<TKey, TValue> | The |
Remove(TKey)
Removes the element with the specified key from the dictionary.
Declaration
public bool Remove(TKey key)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key of the element to remove. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remove(KeyValuePair<TKey, TValue>)
Removes the first occurrence of a specific object from the dictionary.
Declaration
public bool Remove(KeyValuePair<TKey, TValue> item)
Parameters
Type | Name | Description |
---|---|---|
KeyValuePair<TKey, TValue> | item | The object to remove from the dictionary. |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGetNext(TKey, out KeyValuePair<TKey, TValue>)
Gets the next key-value pair in the dictionary whose key is
the immediate successor to the given key
.
Declaration
public bool TryGetNext(TKey key, out KeyValuePair<TKey, TValue> next)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose successor must be found. |
KeyValuePair<TKey, TValue> | next | The key-value pair whose key is the immediate sucessor of
|
Returns
Type | Description |
---|---|
System.Boolean | True if there was a successor in the dictionary; false otherwise. |
TryGetPrevious(TKey, out KeyValuePair<TKey, TValue>)
Gets the next key-value pair in the dictionary whose key is
the immediate ancestor of the given key
.
Declaration
public bool TryGetPrevious(TKey key, out KeyValuePair<TKey, TValue> prev)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose ancestor must be found. |
KeyValuePair<TKey, TValue> | prev | The key-value pair whose key is the immediate ancestor of
|
Returns
Type | Description |
---|---|
System.Boolean | True if there was an ancestor in the dictionary; false otherwise. |
TryGetValue(TKey, out TValue)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TKey | key | The key whose value to get. |
TValue | value | When this method returns, the value associated with the specified key,
if the key is found; otherwise, the default value for the type of the
|
Returns
Type | Description |
---|---|
System.Boolean |
|