Class ReadOnlyDictionaryMap<K, V>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
Default implementation of IReadOnlyDictionaryMap<K, V> that relies on delegate accessors.
public class ReadOnlyDictionaryMap<K, V> : IReadOnlyDictionaryMap<K, V>
Type Parameters
KType of the keys used by the dictionary.
VType of the values stored in the dictionary.
- Inheritance
-
ReadOnlyDictionaryMap<K, V>
- Implements
-
IReadOnlyDictionaryMap<K, V>
- Derived
- Inherited Members
- Extension Methods
Constructors
ReadOnlyDictionaryMap(Func<K, V>, Func<IEnumerable<KeyValuePair<K, V>>>, Func<int>)
Initializes a new instance of the ReadOnlyDictionaryMap<K, V> class using delegate-based accessors.
public ReadOnlyDictionaryMap(Func<K, V> getValue, Func<IEnumerable<KeyValuePair<K, V>>> getItems, Func<int> getCount)
Parameters
getValueFunc<K, V>Delegate that retrieves a value for a given key.
getItemsFunc<IEnumerable<KeyValuePair<K, V>>>Delegate that returns all key/value pairs.
getCountFunc<int>Delegate that provides the item count when available.
Properties
CanCount
Gets a value indicating whether GetCount() can be called without enumerating the dictionary.
public bool CanCount { get; }
Property Value
Methods
GetCount()
Retrieves the count of the key/value pairs when available.
public int GetCount()
Returns
GetValue(K)
Retrieves a value using the provided key.
public V GetValue(K key)
Parameters
keyKThe key that identifies the value.
Returns
- V
The value associated with
key.
GetValues()
Returns the key/value pairs contained in the dictionary.
public IEnumerable<KeyValuePair<K, V>> GetValues()
Returns
- IEnumerable<KeyValuePair<K, V>>