Class EnhancedKeyedCollection<T1, T2>
Hastable based collection which can be accessed by index or key. Derive and override GetKeyForItem() to use. If serialization is required use KeyedCollectionConverter.
Namespace: DaggerfallWorkshop.Utility
Assembly: Assembly-CSharp.dll
Syntax
public abstract class EnhancedKeyedCollection<T1, T2> : KeyedCollection<T1, T2>, IList<T2>, ICollection<T2>, IReadOnlyList<T2>, IReadOnlyCollection<T2>, IEnumerable<T2>, IList, ICollection, IEnumerable where T2 : class
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
Constructors
| Improve this Doc View SourceEnhancedKeyedCollection()
Make a new collection whose keys are embedded in the values. Lookup dictionary is created immediately.
Declaration
public EnhancedKeyedCollection()
EnhancedKeyedCollection(IEqualityComparer<T1>)
Make a new collection whose keys are embedded in the values. Lookup dictionary is created immediately.
Declaration
public EnhancedKeyedCollection(IEqualityComparer<T1> comparer)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T1> | comparer | Equality comparer (null to use default). |
EnhancedKeyedCollection(IEqualityComparer<T1>, Int32)
Make a new collection whose keys are embedded in the values.
Declaration
public EnhancedKeyedCollection(IEqualityComparer<T1> comparer, int dictionaryCreationThreshold)
Parameters
Type | Name | Description |
---|---|---|
IEqualityComparer<T1> | comparer | Equality comparer (null to used default). |
Int32 | dictionaryCreationThreshold | Lookup dictionary is created when Count is this number. |
Methods
| Improve this Doc View SourceGetValueOrDefault(T1)
Gets a value from the collection or null. This is O(1) if lookup dictionary is created, otherwise is O(n).
Declaration
public virtual T2 GetValueOrDefault(T1 key)
Parameters
Type | Name | Description |
---|---|---|
T1 | key |
Returns
Type | Description |
---|---|
T2 |
SetItem(Int32, T2)
Declaration
protected override void SetItem(int index, T2 item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | |
T2 | item |
Overrides
TryGetValue(T1, out T2)
Seeks a value from the collection. This is O(1) if lookup dictionary is created, otherwise is O(n).
Declaration
public virtual bool TryGetValue(T1 key, out T2 item)
Parameters
Type | Name | Description |
---|---|---|
T1 | key | |
T2 | item |
Returns
Type | Description |
---|---|
Boolean |