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
TKeyThe type of the keys that are being added to the dictionary.
TValueThe 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
otherFlexDictionary<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
kvpsIEnumerable<KeyValuePair<TKey, TValue>>The collection of KeyValuePair<TKey, TValue> objects to initialize the dictionary from.
defaultValueTValue
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
collectionIEnumerable<TKey>The collection to initialize the dictionary from.
initialValueTValueThe 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
capacityintThe capacity of the dictionary.
defaultValueTValue
FlexDictionary(TValue)
Initializes a new instance of the FlexDictionary<TKey, TValue> class with the default initial capacity (16).
public FlexDictionary(TValue defaultValue)
Parameters
defaultValueTValue
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.