Table of Contents

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

K

The type of keys in the dictionary.

V

The type of values in the dictionary.

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

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.

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

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.

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

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

map IDictionaryMap<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

bool

this[K]

Gets or sets the value associated with the specified key.

public override V this[K key] { get; set; }

Parameters

key K

The 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

item KeyValuePair<K, V>

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> item)

Parameters

item KeyValuePair<K, V>

Returns

bool

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

array KeyValuePair<K, V>[]
arrayIndex int

Remove(KeyValuePair<K, V>)

Removes the specified key-value pair from the dictionary.

public bool Remove(KeyValuePair<K, V> item)

Parameters

item 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