Table of Contents

Class FlexDictionary<TKey, TValue>

Namespace
Garyon.DataStructures
Assembly
Garyon.dll

A dictionary that allows indexing or setting values on non-existing keys without throwing exceptions.

public class FlexDictionary<TKey, TValue> : BaseFlexDictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : notnull

Type Parameters

TKey

The type of the keys that are being added to the dictionary.

TValue

The type of the values that are being paired with the keys in the dictionary.

Inheritance
BaseFlexDictionary<TKey, TValue>
FlexDictionary<TKey, TValue>
Implements
IDictionary<TKey, TValue>
ICollection<KeyValuePair<TKey, TValue>>
IEnumerable<KeyValuePair<TKey, TValue>>
Derived
Inherited Members
Extension Methods

Constructors

FlexDictionary(FlexDictionary<TKey, TValue>)

Initializes a new instance of the FlexDictionary<TKey, TValue> class out of another FlexDictionary<TKey, TValue> instance.

public FlexDictionary(FlexDictionary<TKey, TValue> other)

Parameters

other FlexDictionary<TKey, TValue>

The other FlexDictionary<TKey, TValue> whose key-value pairs to copy.

FlexDictionary(IEnumerable<KeyValuePair<TKey, TValue>>, TValue)

Initializes a new instance of the FlexDictionary<TKey, TValue> class.

public FlexDictionary(IEnumerable<KeyValuePair<TKey, TValue>> kvps, TValue defaultValue)

Parameters

kvps IEnumerable<KeyValuePair<TKey, TValue>>

The collection of KeyValuePair<TKey, TValue> objects to initialize the dictionary from.

defaultValue TValue

FlexDictionary(IEnumerable<TKey>, TValue)

Initializes a new instance of the FlexDictionary<TKey, TValue> class. Each item in the provided collection is added as a key and is mapped to the specified value of the TValue type.

public FlexDictionary(IEnumerable<TKey> collection, TValue initialValue)

Parameters

collection IEnumerable<TKey>

The collection to initialize the dictionary from.

initialValue TValue

The initial value to map each key to.

FlexDictionary(int, TValue)

Initializes a new instance of the FlexDictionary<TKey, TValue> class.

public FlexDictionary(int capacity, TValue defaultValue)

Parameters

capacity int

The capacity of the dictionary.

defaultValue TValue

FlexDictionary(TValue)

Initializes a new instance of the FlexDictionary<TKey, TValue> class with the default initial capacity (16).

public FlexDictionary(TValue defaultValue)

Parameters

defaultValue TValue

Methods

Clone()

Clones this FlexDictionary<TKey, TValue> and adds all its keys to the resulting instance.

public override FlexDictionary<TKey, TValue> Clone()

Returns

FlexDictionary<TKey, TValue>

The cloned instance containing the same key-value pairs.

GetNewEntryInitializationValue()

Gets the value that will be stored by default upon creating a new entry through the this accessor. This does not affect the Add(TKey, TValue) function.

protected override TValue GetNewEntryInitializationValue()

Returns

TValue

The new value that will be stored in the new entry.