Table of Contents

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

K
V
Inheritance
DictionaryMap<K, V>
Implements
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

baseDictionary IDictionary<K, V>

The base dictionary to wrap.

addValue Action<K, V>

Action to add a key-value pair to the dictionary.

setValue Action<K, V>

Action to set the value for a key in the dictionary.

removeValue Func<K, bool>

Function to remove a key from the dictionary.

clear Action

Action 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

containsKeyValue Func<KeyValuePair<K, V>, bool>

Function to determine if a key-value pair exists in the dictionary.

addValue Action<K, V>

Action to add a key-value pair to the dictionary.

getValue Func<K, V>

Function to get the value associated with a key.

setValue Action<K, V>

Action to set the value for a key in the dictionary.

removeValue Func<K, bool>

Function to remove a key from the dictionary.

getItems Func<IEnumerable<KeyValuePair<K, V>>>

Function to get all key-value pairs in the dictionary.

getCount Func<int>

Function to get the count of key-value pairs in the dictionary.

clear Action

Action to clear the dictionary.

getKeys Func<IEnumerable<K>>

Function to get all keys in the dictionary.

getValues Func<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

key K
value V

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

kv KeyValuePair<K, V>

Returns

bool

Remove(K)

Removes the value with the specified key from the dictionary.

public bool Remove(K key)

Parameters

key K

Returns

bool

Set(K, V)

Sets the value associated with the specified key in the dictionary.

public void Set(K key, V value)

Parameters

key K
value V