Class IndexedList<K, V>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
Indexed list.
public class IndexedList<K, V> : ICollection<V>, IEnumerable<V>, IReadOnlyDictionary<K, V>, IReadOnlyCollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable where K : notnull
Type Parameters
KKey structure
VValue structure
- Inheritance
-
IndexedList<K, V>
- Implements
-
ICollection<V>IEnumerable<V>IReadOnlyDictionary<K, V>IReadOnlyCollection<KeyValuePair<K, V>>IEnumerable<KeyValuePair<K, V>>
- Inherited Members
- Extension Methods
Constructors
IndexedList(Func<V, K>)
Indexed list.
public IndexedList(Func<V, K> getKey)
Parameters
getKeyFunc<V, K>Key extraction function
IndexedList(Func<V, K>, IEnumerable<V>)
Indexed list.
public IndexedList(Func<V, K> getKey, IEnumerable<V> values)
Parameters
getKeyFunc<V, K>Key extraction function
valuesIEnumerable<V>Initial values
Properties
Count
Number of stored values.
public int Count { get; }
Property Value
IsReadOnly
Read/write.
public bool IsReadOnly { get; }
Property Value
this[K]
Retrieves a value.
public V this[K key] { get; }
Parameters
keyKKey
Property Value
- V
Corresponding value
Keys
Set of keys.
public IEnumerable<K> Keys { get; }
Property Value
- IEnumerable<K>
Values
Set of values.
public IEnumerable<V> Values { get; }
Property Value
- IEnumerable<V>
Methods
Add(V)
Adds a value.
public void Add(V item)
Parameters
itemVValue
Clear()
Removes all elements.
public void Clear()
Contains(V)
Indicates if the list contains the parameter value.
public bool Contains(V item)
Parameters
itemVValue
Returns
ContainsKey(K)
Indicates if the list contains the parameter key.
public bool ContainsKey(K key)
Parameters
keyKKey
Returns
CopyTo(V[], int)
Copies to an array.
public void CopyTo(V[] array, int arrayIndex)
Parameters
arrayV[]Target array
arrayIndexintStarting index
Remove(K)
Removes a value by its key.
public bool Remove(K key)
Parameters
keyKKey to remove
Returns
Remove(V)
Removes a value.
public bool Remove(V item)
Parameters
itemVValue to remove
Returns
TryGetValue(K, out V)
Tries to get a value.
public bool TryGetValue(K key, out V value)
Parameters
keyKKey
valueVOutput value