Class KeyedDictionary<K, V>
Inheritance
Implements
Inherited Members
Namespace: Experior.Interfaces.Collections
Assembly: Experior.Interfaces.dll
Syntax
public class KeyedDictionary<K, V> : IDictionary<K, V>, IList<KeyValuePair<K, V>>, ICollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable
Type Parameters
Name | Description |
---|---|
K | |
V |
Properties
Count
Returns the number of entries in the KeyedList.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsReadOnly
Returns false.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[K]
Get/Set the value associated with the specified key.
Declaration
public virtual V this[K key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
K | key | The key. |
Property Value
Type | Description |
---|---|
V | The associated value. |
Item[Int32]
Get/Set the value at the specified index.
Declaration
public KeyValuePair<K, V> this[int idx] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index. |
Property Value
Type | Description |
---|---|
System.Collections.Generic.KeyValuePair<K, V> | The value. |
Keys
Get an unordered list of keys. This collection refers back to the keys in the original Dictionary.
Declaration
public ICollection<K> Keys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<K> |
ObjectTable
Gets the Dictionary class backing the KeyedList.
Declaration
public Dictionary<K, V> ObjectTable { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<K, V> |
OrderedKeys
Get the ordered list of keys. This is a copy of the keys in the original Dictionary.
Declaration
public List<K> OrderedKeys { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<K> |
OrderedValues
Get the ordered list of values. This is a copy of the values in the original Dictionary.
Declaration
public List<V> OrderedValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<V> |
Values
Get an unordered list of values. This collection refers back to the values in the original Dictionary.
Declaration
public ICollection<V> Values { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<V> |
Methods
Add(K, V)
Adds a key-value pair to the KeyedList.
Declaration
public void Add(K key, V value)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key. |
V | value | The associated value. |
Add(KeyValuePair<K, V>)
Adds a key-value pair to the KeyedList.
Declaration
public void Add(KeyValuePair<K, V> kvp)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<K, V> | kvp | The KeyValuePair instance. |
Clear()
Clears all entries in the KeyedList.
Declaration
public void Clear()
Contains(KeyValuePair<K, V>)
Test if the KeyedList contains the key in the key-value pair.
Declaration
public bool Contains(KeyValuePair<K, V> kvp)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<K, V> | kvp | The key-value pair. |
Returns
Type | Description |
---|---|
System.Boolean | True if the key is found. |
ContainsKey(K)
Test if the KeyedList contains the key.
Declaration
public bool ContainsKey(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key. |
Returns
Type | Description |
---|---|
System.Boolean | True if the key is found. |
CopyTo(KeyValuePair<K, V>[], Int32)
Copy the entire key-value pairs to the KeyValuePair array, starting at the specified index of the target array. The array is populated as an ordered list.
Declaration
public void CopyTo(KeyValuePair<K, V>[] kvpa, int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<K, V>[] | kvpa | The KeyValuePair array. |
System.Int32 | idx | The position to start the copy. |
GetKey(Int32)
Returns the key at the specified index.
Declaration
public K GetKey(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index. |
Returns
Type | Description |
---|---|
K | The key at the index. |
GetValue(Int32)
Returns the value at the specified index.
Declaration
public V GetValue(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index. |
Returns
Type | Description |
---|---|
V | The value at the index. |
IndexOf(K)
Get the index of a particular key.
Declaration
public int IndexOf(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to find the index of. |
Returns
Type | Description |
---|---|
System.Int32 | The index of the key, or -1 if not found. |
IndexOf(KeyValuePair<K, V>)
Given the key-value pair, find the index.
Declaration
public int IndexOf(KeyValuePair<K, V> kvp)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<K, V> | kvp | The key-value pair. |
Returns
Type | Description |
---|---|
System.Int32 | The index, or -1 if not found. |
Insert(Int32, K, V)
Insert the key-value at the specified index.
Declaration
public void Insert(int idx, K key, V value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The zero-based insert point. |
K | key | The key. |
V | value | The value. |
Insert(Int32, KeyValuePair<K, V>)
Insert the key-value pair at the specified index location.
Declaration
public void Insert(int idx, KeyValuePair<K, V> kvp)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The key. |
System.Collections.Generic.KeyValuePair<K, V> | kvp | The value. |
Remove(K)
Remove the entry.
Declaration
public bool Remove(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key identifying the key-value pair. |
Returns
Type | Description |
---|---|
System.Boolean | True if removed. |
Remove(KeyValuePair<K, V>)
Remove the key in the specified KeyValuePair instance. The Value property is ignored.
Declaration
public bool Remove(KeyValuePair<K, V> kvp)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.KeyValuePair<K, V> | kvp | The key-value identifying the entry. |
Returns
Type | Description |
---|---|
System.Boolean | True if removed. |
RemoveAt(Int32)
Remove the entry at the specified index.
Declaration
public void RemoveAt(int idx)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | idx | The index to the entry to be removed. |
TryGetValue(K, out V)
Attempt to get the value, given the key, without throwing an exception if not found.
Declaration
public bool TryGetValue(K key, out V val)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key indentifying the entry. |
V | val | The value, if found. |
Returns
Type | Description |
---|---|
System.Boolean | True if found. |
Explicit Interface Implementations
IEnumerable<KeyValuePair<K, V>>.GetEnumerator()
Returns an ordered KeyValuePair enumerator.
Declaration
IEnumerator<KeyValuePair<K, V>> IEnumerable<KeyValuePair<K, V>>.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<K, V>> |
IEnumerable.GetEnumerator()
Returns an ordered System.Collections KeyValuePair objects.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |