Class TransientMap<TK, TV>
- Namespace
- Map
- Assembly
- Map.dll
A mutable, transient version of a Map<TK, TV> that can be efficiently modified before being converted back to an immutable map.
public sealed class TransientMap<TK, TV>
Type Parameters
TKTV
- Inheritance
-
TransientMap<TK, TV>
- Inherited Members
Methods
Add(TK, TV)
Adds an element with the provided key and value to the map. If the key already exists, the existing value is updated.
public void Add(TK key, TV value)
Parameters
keyTKThe object to use as the key of the element to add.
valueTVThe object to use as the value of the element to add.
Remove(TK)
Removes the element with the specified key from the map.
public void Remove(TK key)
Parameters
keyTKThe key of the element to remove.
ToImmutable()
Creates an immutable Map<TK, TV> from the contents of this transient map. This operation is an O(1) operation and does not involve copying the data.
public Map<TK, TV> ToImmutable()
Returns
- Map<TK, TV>
An immutable map.
TryGetValue(TK, out TV)
Attempts to get the value associated with the specified key.
public bool TryGetValue(TK key, out TV value)
Parameters
keyTKThe key of the value to get.
valueTVWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
valueparameter.
Returns
- bool
trueif the key was found; otherwise,false.