Class MappedDictionary<K, V>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
A dictionary that uses a custom mapping for its operations. It allows customization of how the dictionary handles additions, removals, and value retrievals.
public class MappedDictionary<K, V> : ReadOnlyMappedDictionary<K, V>, IReadOnlyDictionary<K, V>, IReadOnlyCollection<KeyValuePair<K, V>>, IDictionary<K, V>, ICollection<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable
Type Parameters
KThe type of keys in the dictionary.
VThe type of values in the dictionary.
- Inheritance
-
ReadOnlyMappedDictionary<K, V>MappedDictionary<K, V>
- Implements
-
IReadOnlyDictionary<K, V>IReadOnlyCollection<KeyValuePair<K, V>>IDictionary<K, V>ICollection<KeyValuePair<K, V>>IEnumerable<KeyValuePair<K, V>>
- Inherited Members
- Extension Methods
Constructors
MappedDictionary(IDictionary<K, V>, Action<K, V>, Action<K, V>, Func<K, bool>, Action)
Initializes a new instance of the MappedDictionary<K, V> class with a base dictionary and custom handlers.
public MappedDictionary(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.
MappedDictionary(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)
Initializes a new instance of the MappedDictionary<K, V> class with custom handlers for dictionary operations.
public MappedDictionary(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>>> getValues, Func<int> getCount, Action clear)
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.
getValuesFunc<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.
MappedDictionary(IDictionaryMap<K, V>)
Initializes a new instance of the MappedDictionary<K, V> class using a custom dictionary map.
public MappedDictionary(IDictionaryMap<K, V> map)
Parameters
mapIDictionaryMap<K, V>The custom dictionary map that defines the behavior of the dictionary.
Properties
IsReadOnly
Gets a value indicating whether the dictionary is read-only (always false).
public bool IsReadOnly { get; }
Property Value
this[K]
Gets or sets the value associated with the specified key.
public override V this[K key] { get; set; }
Parameters
keyKThe key whose value to get or set.
Property Value
- V
The value associated with the specified key.
Methods
Add(KeyValuePair<K, V>)
Adds the specified key-value pair to the dictionary.
public void Add(KeyValuePair<K, V> item)
Parameters
itemKeyValuePair<K, V>
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> item)
Parameters
itemKeyValuePair<K, V>
Returns
CopyTo(KeyValuePair<K, V>[], int)
Copies the elements of the dictionary to an array, starting at a particular array index.
public void CopyTo(KeyValuePair<K, V>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<K, V>[]arrayIndexint
Remove(KeyValuePair<K, V>)
Removes the specified key-value pair from the dictionary.
public bool Remove(KeyValuePair<K, V> item)
Parameters
itemKeyValuePair<K, V>
Returns
Remove(K)
Removes the value with the specified key from the dictionary.
public bool Remove(K key)
Parameters
keyK