Class OrderedDictionary<TKey, TValue>
Ordered dictionary.
Inheritance
Namespace: ISynergy.Framework.Core.Collections
Assembly: ISynergy.Framework.Core.dll
Syntax
public class OrderedDictionary<TKey, TValue> : IDictionary<TKey, TValue>
  Type Parameters
| Name | Description | 
|---|---|
| TKey | The types of the keys in the dictionary.  | 
      
| TValue | The type of values in the dictionary.  | 
      
Remarks
This class provides a ordered dictionary implementation for C#/.NET. Unlike the rest of the framework, this class is available under a MIT license, so please feel free to re-use its source code in your own projects.
Constructors
View SourceOrderedDictionary()
Initializes a new instance of the OrderedDictionary<TKey, TValue> class.
Declaration
public OrderedDictionary()
  OrderedDictionary(IDictionary<TKey, TValue>, IEqualityComparer<TKey>)
Initializes a new instance of the OrderedDictionary<TKey, TValue> class.
Declaration
public OrderedDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IDictionary<TKey, TValue> | dictionary | The System.Collections.Generic.IDictionary`2 whose elements are copied to the new OrderedDictionary<TKey, TValue>.  | 
      
| IEqualityComparer<TKey> | comparer | The IEqualityComparer implementation to use when comparing keys, or null to use the default EqualityComparer for the type of the key.  | 
      
OrderedDictionary(IEqualityComparer<TKey>)
Initializes a new instance of the OrderedDictionary<TKey, TValue> class.
Declaration
public OrderedDictionary(IEqualityComparer<TKey> comparer)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IEqualityComparer<TKey> | comparer | The IEqualityComparer implementation to use when comparing keys, or null to use the default EqualityComparer for the type of the key.  | 
      
OrderedDictionary(Int32)
Initializes a new instance of the OrderedDictionary<TKey, TValue> class.
Declaration
public OrderedDictionary(int capacity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | capacity | The initial number of elements that the OrderedDictionary<TKey, TValue> can contain.  | 
      
OrderedDictionary(Int32, IEqualityComparer<TKey>)
Initializes a new instance of the OrderedDictionary<TKey, TValue> class.
Declaration
public OrderedDictionary(int capacity, IEqualityComparer<TKey> comparer)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | capacity | The initial number of elements that the OrderedDictionary<TKey, TValue> can contain.  | 
      
| IEqualityComparer<TKey> | comparer | The IEqualityComparer implementation to use when comparing keys, or null to use the default EqualityComparer for the type of the key.  | 
      
Properties
View SourceCount
Gets the number of elements contained in the System.Collections.Generic.ICollection<T>.
Declaration
public int Count { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
public bool IsReadOnly { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
      
Item[TKey]
Gets or sets the 
Declaration
public TValue this[TKey key] { get; set; }
  Parameters
| Type | Name | Description | 
|---|---|---|
| TKey | key | The key.  | 
      
Property Value
| Type | Description | 
|---|---|
| TValue | 
Keys
Gets an System.Collections.Generic.ICollection<T> containing the keys of the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public ICollection<TKey> Keys { get; }
  Property Value
| Type | Description | 
|---|---|
| ICollection<TKey> | The keys.  | 
      
Values
Gets an System.Collections.Generic.ICollection<T> containing the values in the System.Collections.Generic.IDictionary<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 System.Collections.Generic.IDictionary<TKey, TValue>.
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 item to the System.Collections.Generic.ICollection<T>.
Declaration
public void Add(KeyValuePair<TKey, TValue> item)
  Parameters
| Type | Name | Description | 
|---|---|---|
| KeyValuePair<TKey, TValue> | item | The object to add to the System.Collections.Generic.ICollection<T>.  | 
      
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
Declaration
public void Clear()
  Contains(KeyValuePair<TKey, TValue>)
Determines whether the System.Collections.Generic.ICollection<T> 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 System.Collections.Generic.ICollection<T>.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if   | 
      
ContainsKey(TKey)
Determines whether the System.Collections.Generic.IDictionary<TKey, TValue> 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 System.Collections.Generic.IDictionary<TKey, TValue>.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the key; otherwise, false.  | 
      
CopyTo(KeyValuePair<TKey, TValue>[], Int32)
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.Array, starting at a particular System.Array index.
Declaration
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
  Parameters
| Type | Name | Description | 
|---|---|---|
| KeyValuePair<TKey, TValue>[] | array | The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.ICollection<T>. The System.Array must have zero-based indexing.  | 
      
| System.Int32 | arrayIndex | The zero-based index in   | 
      
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
  Returns
| Type | Description | 
|---|---|
| IEnumerator<KeyValuePair<TKey, TValue>> | An enumerator that can be used to iterate through the collection.  | 
      
GetKeyByIndex(Int32)
Gets the 
Declaration
public TKey GetKeyByIndex(int index)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | index | The index.  | 
      
Returns
| Type | Description | 
|---|---|
| TKey | 
GetValueByIndex(Int32)
Gets the 
Declaration
public TValue GetValueByIndex(int index)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | index | The index.  | 
      
Returns
| Type | Description | 
|---|---|
| TValue | 
Remove(TKey)
Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public bool Remove(TKey key)
  Parameters
| Type | Name | Description | 
|---|---|---|
| TKey | key | The key of the element to remove.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the element is successfully removed; otherwise, false.  This method also returns false if   | 
      
Remove(KeyValuePair<TKey, TValue>)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
Declaration
public bool Remove(KeyValuePair<TKey, TValue> item)
  Parameters
| Type | Name | Description | 
|---|---|---|
| KeyValuePair<TKey, TValue> | item | The object to remove from the System.Collections.Generic.ICollection<T>.  | 
      
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if   | 
      
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 | true if the object that implements System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.  |