Class ReadOnlyMappedDictionary<K, V>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
List whose source is defined by accessors.
public class ReadOnlyMappedDictionary<K, V> : IReadOnlyDictionary<K, V>, IReadOnlyCollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable
Type Parameters
KType of the key
VType of elements
- Inheritance
-
ReadOnlyMappedDictionary<K, V>
- Implements
-
IReadOnlyDictionary<K, V>IReadOnlyCollection<KeyValuePair<K, V>>IEnumerable<KeyValuePair<K, V>>
- Derived
- Inherited Members
- Extension Methods
Constructors
ReadOnlyMappedDictionary(Func<K, V>, Func<IEnumerable<KeyValuePair<K, V>>>, Func<int>)
Creates an accessor.
public ReadOnlyMappedDictionary(Func<K, V> GetValue, Func<IEnumerable<KeyValuePair<K, V>>> GetValues, Func<int> GetCount = null)
Parameters
GetValueFunc<K, V>Accessor for retrieving a single value
GetValuesFunc<IEnumerable<KeyValuePair<K, V>>>Retrieving all values from the list
GetCountFunc<int>Retrieving the number of values in the list
ReadOnlyMappedDictionary(IReadOnlyDictionaryMap<K, V>)
Creates an accessor.
public ReadOnlyMappedDictionary(IReadOnlyDictionaryMap<K, V> map)
Parameters
mapIReadOnlyDictionaryMap<K, V>Class defining the accessors
Properties
Count
Gets the number of elements in the collection.
public int Count { get; }
Property Value
- int
The number of elements in the collection.
this[K]
Gets the element that has the specified key in the read-only dictionary.
public virtual V this[K key] { get; set; }
Parameters
keyKThe key to locate.
Property Value
- V
The element that has the specified key in the read-only dictionary.
Exceptions
- ArgumentNullException
keyis null.- KeyNotFoundException
The property is retrieved and
keyis not found.
Keys
Gets an enumerable collection that contains the keys in the read-only dictionary.
public IEnumerable<K> Keys { get; }
Property Value
- IEnumerable<K>
An enumerable collection that contains the keys in the read-only dictionary.
Values
Gets an enumerable collection that contains the values in the read-only dictionary.
public IEnumerable<V> Values { get; }
Property Value
- IEnumerable<V>
An enumerable collection that contains the values in the read-only dictionary.
Methods
ContainsKey(K)
Determines whether the read-only dictionary contains an element that has the specified key.
public bool ContainsKey(K key)
Parameters
keyKThe key to locate.
Returns
- bool
true if the read-only dictionary contains an element that has the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<K, V>>
An enumerator that can be used to iterate through the collection.
TryGetValue(K, out V)
Gets the value that is associated with the specified key.
public bool TryGetValue(K key, out V value)
Parameters
keyKThe key to locate.
valueVWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
valueparameter. This parameter is passed uninitialized.
Returns
- bool
true if the object that implements the IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.