Class TypeMap
Represents fast implementation of ITypeMap which is not thread safe.
Inherited Members
Namespace: DotNext.Collections.Specialized
Assembly: DotNext.dll
Syntax
public class TypeMap : ITypeMap, IReadOnlyTypeMap, IEnumerable<object>, IEnumerable
Constructors
| Edit this page View SourceTypeMap()
Initializes a new empty set.
Declaration
public TypeMap()
TypeMap(int)
Initializes a new empty set.
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<T>(T)
Adds a new value associated with type T
to this set.
Declaration
public void Add<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be added. |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
Exceptions
Type | Condition |
---|---|
GenericArgumentException | A value associated with |
Clear()
Removes all elements from this set.
Declaration
public void Clear()
Contains<T>()
Determines whether the set has the value of type T
.
Declaration
public bool Contains<T>()
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
GetEnumerator()
Gets an enumerator over values in this map.
Declaration
public TypeMap.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
TypeMap.Enumerator | The enumerator over values in this map. |
GetValueRefOrAddDefault<T>(out bool)
Gets the value associated with the specified type.
Declaration
public ref T GetValueRefOrAddDefault<T>(out bool exists) where T : struct
Parameters
Type | Name | Description |
---|---|---|
bool | exists | true if the association exists; false if the association is created. |
Returns
Type | Description |
---|---|
T | The reference to the value associated with the type. |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
Remove<T>()
Attempts to remove the value of type T
from this set.
Declaration
public bool Remove<T>()
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type which value should be removed. |
Remove<T>(out T?)
Attempts to remove the value of type T
from this set.
Declaration
public bool Remove<T>(out T? value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Removed value. |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T | The type which value should be removed. |
Set<T>(T)
Adds or overwrites the value associated with type T
.
Declaration
public void Set<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to set. |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
Set<T>(T, out T?)
Replaces the value associated with type T
.
Declaration
public bool Set<T>(T newValue, out T? oldValue)
Parameters
Type | Name | Description |
---|---|---|
T | newValue | The value to set. |
T | 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 |
---|---|
T | The type of the value. |
TryGetValue<T>(out T?)
Attempts to get the value of the specified type.
Declaration
public bool TryGetValue<T>(out T? value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value stored in the set. |
Returns
Type | Description |
---|---|
bool | true if the value of type |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |