Class OrderedDictionary<TKey, TValue>
A dictionary object that allows rapid hash lookups using keys, but also maintains the key insertion order so that values can be retrieved by key index.
Inheritance
Implements
Namespace: FlaxEngine.Collections
Assembly: FlaxEngine.CSharp.dll
Syntax
public class OrderedDictionary<TKey, TValue> : Object, IOrderedDictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IOrderedDictionary, ICollection, IDictionary
Type Parameters
TKey
|
TValue
|
Constructors
OrderedDictionary()
A dictionary object that allows rapid hash lookups using keys, but also maintains the key insertion order so that values can be retrieved by key index.
Declaration
public OrderedDictionary()
OrderedDictionary(IOrderedDictionary<TKey, TValue>)
Declaration
public OrderedDictionary(IOrderedDictionary<TKey, TValue> dictionary)
Parameters
IOrderedDictionary<TKey, TValue>
dictionary
|
Remarks
Copy constructor
OrderedDictionary(IOrderedDictionary<TKey, TValue>, IEqualityComparer<TKey>)
Declaration
public OrderedDictionary(IOrderedDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer)
Parameters
IOrderedDictionary<TKey, TValue>
dictionary
|
System.Collections.Generic.IEqualityComparer<TKey>
comparer
|
Remarks
Copy constructor with custom items comparer
OrderedDictionary(IEqualityComparer<TKey>)
Declaration
public OrderedDictionary(IEqualityComparer<TKey> comparer)
Parameters
System.Collections.Generic.IEqualityComparer<TKey>
comparer
|
Remarks
Allows custom comparer for items
Properties
Comparer
The keys equality comparer.
Declaration
public IEqualityComparer<TKey> Comparer { get; }
Property Value
System.Collections.Generic.IEqualityComparer<TKey>
|
Count
Gets the number of elements contained in the OrderedDictionary<TKey, TValue>.
Declaration
public int Count { get; }
Property Value
System.Int32
The number of elements contained in the T:System.Collections.ICollection. |
Implements
Item[TKey]
Gets or sets the value associated with the specified key.
Declaration
public TValue this[TKey key] { get; set; }
Parameters
TKey
key
The key associated with the value to get or set. |
Property Value
TValue
|
Implements
Item[Int32]
Gets or sets the value at the specified index.
Declaration
public TValue this[int index] { get; set; }
Parameters
System.Int32
index
The index of the value to get or set. |
Property Value
TValue
|
Implements
Keys
Gets an System.Collections.ICollection object containing the keys in the OrderedDictionary<TKey, TValue> object.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
System.Collections.Generic.ICollection<TKey>
An System.Collections.ICollection object containing the keys in the OrderedDictionary<TKey, TValue> object. |
Implements
Values
Gets an System.Collections.ICollection object containing the values in the OrderedDictionary<TKey, TValue> object.
Declaration
public ICollection<TValue> Values { get; }
Property Value
System.Collections.Generic.ICollection<TValue>
An System.Collections.ICollection object containing the values in the OrderedDictionary<TKey, TValue> object. |
Implements
Methods
Add(TKey, TValue)
Adds an element with the specified key and value into the OrderedDictionary<TKey, TValue>.
Declaration
public void Add(TKey key, TValue value)
Parameters
TKey
key
The key of the element to add. |
TValue
value
The value of the element to add. |
Implements
Clear()
Clears the contents of the OrderedDictionary<TKey, TValue> instance.
Declaration
public void Clear()
Implements
ContainsKey(TKey)
Determines whether the OrderedDictionary<TKey, TValue> contains a specific key.
Declaration
public bool ContainsKey(TKey key)
Parameters
TKey
key
The key to locate in the OrderedDictionary<TKey, TValue>. |
Returns
System.Boolean
True if the OrderedDictionary<TKey, TValue> contains an element with the specified key; otherwise, false. |
Implements
ContainsValue(TValue)
Determines whether the OrderedDictionary<TKey, TValue> contains a specific value.
Declaration
public bool ContainsValue(TValue value)
Parameters
TValue
value
The value to locate in the OrderedDictionary<TKey, TValue>. |
Returns
System.Boolean
True if the OrderedDictionary<TKey, TValue> contains an element with the specified value; otherwise, false. |
Implements
ContainsValue(TValue, IEqualityComparer<TValue>)
Determines whether the OrderedDictionary<TKey, TValue> contains a specific value.
Declaration
public bool ContainsValue(TValue value, IEqualityComparer<TValue> comparer)
Parameters
TValue
value
The value to locate in the OrderedDictionary<TKey, TValue>. |
System.Collections.Generic.IEqualityComparer<TValue>
comparer
The custom System.Collections.IEqualityComparer for this search |
Returns
System.Boolean
True if the OrderedDictionary<TKey, TValue> contains an element with the specified value; otherwise, false. |
Implements
GetEnumerator()
Returns an System.Collections.IEnumerator that iterates through the OrderedDictionary<TKey, TValue>.
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey, TValue>>
An System.Collections.IEnumerator for the OrderedDictionary<TKey, TValue>. |
Implements
GetItem(Int32)
Gets item at given index.
Declaration
public KeyValuePair<TKey, TValue> GetItem(int index)
Parameters
System.Int32
index
Requested key at index |
Returns
System.Collections.Generic.KeyValuePair<TKey, TValue>
|
Implements
Exceptions
System.ArgumentException
Thrown when the index specified does not refer to a KeyValuePair in this object |
GetValue(TKey)
Gets the value associated with the specified key.
Declaration
public TValue GetValue(TKey key)
Parameters
TKey
key
The key associated with the value to get. |
Returns
TValue
|
Implements
IndexOf(TKey)
Determines whether an element is in the OrderedDictionary<TKey, TValue>.
Declaration
public int IndexOf(TKey key)
Parameters
TKey
key
The object to locate in the current dictionary. The element to locate can be null for reference types. |
Returns
System.Int32
The index of the item. |
Implements
Insert(Int32, TKey, TValue)
Performs additional custom processes before inserting a new element into the OrderedDictionary<TKey, TValue> instance.
Declaration
public void Insert(int index, TKey key, TValue value)
Parameters
System.Int32
index
The index. |
TKey
key
The key of the element to insert. |
TValue
value
The value of the element to insert. |
Implements
Remove(TKey)
Performs additional custom processes before removing an element from the OrderedDictionary<TKey, TValue> instance.
Declaration
public bool Remove(TKey key)
Parameters
TKey
key
The key of the element to remove. |
Returns
System.Boolean
|
Implements
RemoveAt(Int32)
Removes the OrderedDictionary<TKey, TValue> item at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
System.Int32
index
The zero-based index of the item to remove. |
Implements
SetItem(Int32, TValue)
Sets the value at the index specified.
Declaration
public void SetItem(int index, TValue value)
Parameters
System.Int32
index
The index of the value desired |
TValue
value
The value to set |
Implements
Exceptions
System.ArgumentOutOfRangeException
Thrown when the index specified does not refer to a KeyValuePair in this object |
SetValue(TKey, TValue)
Sets the value associated with the specified key.
Declaration
public void SetValue(TKey key, TValue value)
Parameters
TKey
key
The key associated with the value to set. |
TValue
value
The the value to set. |
Implements
SortKeys()
Sorts the keys.
Declaration
public void SortKeys()
SortKeys(IComparer<TKey>)
Sorts the keys.
Declaration
public void SortKeys(IComparer<TKey> comparer)
Parameters
System.Collections.Generic.IComparer<TKey>
comparer
The comparer. |
SortKeys(Comparison<TKey>)
Sorts the keys.
Declaration
public void SortKeys(Comparison<TKey> comparison)
Parameters
System.Comparison<TKey>
comparison
The comparison. |
SortValues()
Sorts the values.
Declaration
public void SortValues()
SortValues(IComparer<TValue>)
Sorts the values.
Declaration
public void SortValues(IComparer<TValue> comparer)
Parameters
System.Collections.Generic.IComparer<TValue>
comparer
The comparer. |
SortValues(Comparison<TValue>)
Sorts the values.
Declaration
public void SortValues(Comparison<TValue> comparison)
Parameters
System.Comparison<TValue>
comparison
The comparison. |
TryGetValue(TKey, out TValue)
Tries to get value at specified key.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
TKey
key
The key associated with the value to find. |
TValue
value
Found value. |
Returns
System.Boolean
true if value existed, false if not |