Table of Contents

Class FlexInitDictionary<TKey, TValue>

Namespace
Garyon.DataStructures
Assembly
Garyon.dll

Represents a flexible dictionary where the newly added keys will map to a new initialized value of TValue.

public class FlexInitDictionary<TKey, TValue> : BaseFlexDictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : notnull where TValue : new()

Type Parameters

TKey

The type of the key to index the dictionary contents by.

TValue

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

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

Constructors

FlexInitDictionary()

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

public FlexInitDictionary()

FlexInitDictionary(FlexInitDictionary<TKey, TValue>)

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

public FlexInitDictionary(FlexInitDictionary<TKey, TValue> other)

Parameters

other FlexInitDictionary<TKey, TValue>

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

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

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

public FlexInitDictionary(IEnumerable<KeyValuePair<TKey, TValue>> kvps)

Parameters

kvps IEnumerable<KeyValuePair<TKey, TValue>>

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

FlexInitDictionary(IEnumerable<TKey>)

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

public FlexInitDictionary(IEnumerable<TKey> collection)

Parameters

collection IEnumerable<TKey>

The collection to initialize the dictionary from. Each item in the provided collection is added as a key and is mapped to the default value of the TValue type.

FlexInitDictionary(int)

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

public FlexInitDictionary(int capacity)

Parameters

capacity int

The capacity of the dictionary.

Methods

Clone()

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

public override FlexInitDictionary<TKey, TValue> Clone()

Returns

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