Class TypeMap<TValue>
Represents fast implementation of ITypeMap<TValue> that is not thread safe.
Inherited Members
Namespace: DotNext.Collections.Specialized
Assembly: DotNext.dll
Syntax
public class TypeMap<TValue> : ITypeMap<TValue>, IReadOnlyTypeMap<TValue>, IEnumerable<TValue>, IEnumerable
Type Parameters
Name | Description |
---|---|
TValue | The type of the value. |
Constructors
| Edit this page View SourceTypeMap()
Initializes a new map of recommended capacity.
Declaration
public TypeMap()
TypeMap(int)
Initializes a new map.
Declaration
public TypeMap(int capacity)
Parameters
Type | Name | Description |
---|---|---|
int | capacity | The initial capacity of the map. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException |
|
Methods
| Edit this page View SourceAdd<TKey>(TValue)
Associates a new value with the type.
Declaration
public void Add<TKey>(TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value associated with the type. |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
Exceptions
Type | Condition |
---|---|
GenericArgumentException | A value associated with |
Clear()
Removes all elements from this map.
Declaration
public void Clear()
ContainsKey<TKey>()
Determines whether the map has association between the value and the specified type.
Declaration
public bool ContainsKey<TKey>()
Returns
Type | Description |
---|---|
bool | true if there is a value associated with |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
GetEnumerator()
Gets enumerator over the values.
Declaration
public TypeMap<TValue>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
TypeMap<TValue>.Enumerator | The enumerator over the values. |
GetValueRefOrAddDefault<TKey>(out bool)
Gets the value associated with the specified type.
Declaration
public ref TValue? GetValueRefOrAddDefault<TKey>(out bool exists)
Parameters
Type | Name | Description |
---|---|---|
bool | exists | true if the association exists; false if the association is created. |
Returns
Type | Description |
---|---|
TValue | The reference to the value associated with the type. |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
Remove<TKey>()
Attempts to remove the value from the map.
Declaration
public bool Remove<TKey>()
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
Remove<TKey>(out TValue)
Attempts to remove the value from the map.
Declaration
public bool Remove<TKey>(out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value of the removed element. |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
Set<TKey>(TValue)
Associates the value with the specified type.
Declaration
public void Set<TKey>(TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value to set. |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
Set<TKey>(TValue, out TValue)
Replaces the existing value with a new value.
Declaration
public bool Set<TKey>(TValue newValue, out TValue oldValue)
Parameters
Type | Name | Description |
---|---|---|
TValue | newValue | A new value. |
TValue | oldValue | The replaced value. |
Returns
Type | Description |
---|---|
bool | true if value is replaced; false if a new value is added without replacement. |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |
TryGetValue<TKey>(out TValue)
Attempts to get the value associated with the specified type.
Declaration
public bool TryGetValue<TKey>(out TValue value)
Parameters
Type | Name | Description |
---|---|---|
TValue | value | The value associated with the type. |
Returns
Type | Description |
---|---|
bool | true if there is a value associated with |
Type Parameters
Name | Description |
---|---|
TKey | The type acting as a key. |