Class DictionaryMap<K, V>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
Implementation of IDictionaryMap<K, V> that wraps custom handlers for dictionary operations.
public class DictionaryMap<K, V> : ReadOnlyDictionaryMap<K, V>, IDictionaryMap<K, V>, IReadOnlyDictionaryMap<K, V>
Type Parameters
KV
- Inheritance
-
ReadOnlyDictionaryMap<K, V>DictionaryMap<K, V>
- Implements
-
IDictionaryMap<K, V>IReadOnlyDictionaryMap<K, V>
- Inherited Members
- Extension Methods
Constructors
DictionaryMap(IDictionary<K, V>, Action<K, V>, Action<K, V>, Func<K, bool>, Action)
Initializes a new instance of the DictionaryMap<K, V> class that wraps an existing dictionary with custom handlers.
public DictionaryMap(IDictionary<K, V> baseDictionary, Action<K, V> addValue, Action<K, V> setValue, Func<K, bool> removeValue, Action clear)
Parameters
baseDictionaryIDictionary<K, V>The base dictionary to wrap.
addValueAction<K, V>Action to add a key-value pair to the dictionary.
setValueAction<K, V>Action to set the value for a key in the dictionary.
removeValueFunc<K, bool>Function to remove a key from the dictionary.
clearActionAction to clear the dictionary.
DictionaryMap(Func<KeyValuePair<K, V>, bool>, Action<K, V>, Func<K, V>, Action<K, V>, Func<K, bool>, Func<IEnumerable<KeyValuePair<K, V>>>, Func<int>, Action, Func<IEnumerable<K>>, Func<IEnumerable<V>>)
Initializes a new instance of the DictionaryMap<K, V> class with custom handlers.
public DictionaryMap(Func<KeyValuePair<K, V>, bool> containsKeyValue, Action<K, V> addValue, Func<K, V> getValue, Action<K, V> setValue, Func<K, bool> removeValue, Func<IEnumerable<KeyValuePair<K, V>>> getItems, Func<int> getCount, Action clear, Func<IEnumerable<K>> getKeys = null, Func<IEnumerable<V>> getValues = null)
Parameters
containsKeyValueFunc<KeyValuePair<K, V>, bool>Function to determine if a key-value pair exists in the dictionary.
addValueAction<K, V>Action to add a key-value pair to the dictionary.
getValueFunc<K, V>Function to get the value associated with a key.
setValueAction<K, V>Action to set the value for a key in the dictionary.
removeValueFunc<K, bool>Function to remove a key from the dictionary.
getItemsFunc<IEnumerable<KeyValuePair<K, V>>>Function to get all key-value pairs in the dictionary.
getCountFunc<int>Function to get the count of key-value pairs in the dictionary.
clearActionAction to clear the dictionary.
getKeysFunc<IEnumerable<K>>Function to get all keys in the dictionary.
getValuesFunc<IEnumerable<V>>Function to get all values in the dictionary.
Methods
Add(K, V)
Adds the specified key and value to the dictionary.
public void Add(K key, V value)
Parameters
keyKvalueV
Clear()
Removes all keys and values from the dictionary.
public void Clear()
Contains(KeyValuePair<K, V>)
Determines whether the dictionary contains the specified key-value pair.
public bool Contains(KeyValuePair<K, V> kv)
Parameters
kvKeyValuePair<K, V>
Returns
Remove(K)
Removes the value with the specified key from the dictionary.
public bool Remove(K key)
Parameters
keyK
Returns
Set(K, V)
Sets the value associated with the specified key in the dictionary.
public void Set(K key, V value)
Parameters
keyKvalueV