Struct ImmutableOrderedDictionary<TKey, TValue>
An immutable dictionary that iterates over elements in the order they were added.
Implements
Inherited Members
Namespace: Flame.Collections
Assembly: Flame.Compiler.dll
Syntax
public struct ImmutableOrderedDictionary<TKey, TValue> : IImmutableDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable
Type Parameters
| Name | Description |
|---|---|
| TKey | |
| TValue |
Fields
| Edit this page View SourceEmpty
An empty immutable ordered dictionary.
Declaration
public static readonly ImmutableOrderedDictionary<TKey, TValue> Empty
Field Value
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> |
Properties
| Edit this page View SourceCount
Gets the number of elements in this dictionary.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
this[TKey]
Gets the value for a particular key.
Declaration
public TValue this[TKey key] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to look up. |
Property Value
| Type | Description |
|---|---|
| TValue |
Keys
Gets a sequence of all keys in this dictionary.
Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TKey> |
Values
Gets a sequence of all values in this dictionary.
Declaration
public IEnumerable<TValue> Values { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TValue> |
Methods
| Edit this page View SourceAdd(TKey, TValue)
Adds a key-value pair to this ordered dictionary.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> Add(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to add to the dictionary. |
| TValue | value | The value to associate with |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | A new dictionary that includes the key-value pair. |
AddRange(IEnumerable<KeyValuePair<TKey, TValue>>)
Adds a sequence of key-value pairs to this ordered dictionary.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<KeyValuePair<TKey, TValue>> | pairs | The key-value pairs to add to the dictionary. |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | A new dictionary that includes the key-value pairs. |
Clear()
Creates an immutable ordered dictionary that does not contain any elements.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> Clear()
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | A new immutable ordered dictionary. |
Contains(KeyValuePair<TKey, TValue>)
Tests if this dictionary contains a particular key-value pair.
Declaration
public bool Contains(KeyValuePair<TKey, TValue> pair)
Parameters
| Type | Name | Description |
|---|---|---|
| KeyValuePair<TKey, TValue> | pair | The key-value pair to look for. |
Returns
| Type | Description |
|---|---|
| bool |
|
ContainsKey(TKey)
Tests if this dictionary contains a particular key.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to look for. |
Returns
| Type | Description |
|---|---|
| bool |
|
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<KeyValuePair<TKey, TValue>> | An enumerator that can be used to iterate through the collection. |
Remove(TKey)
Removes a key-value pair from this immutable ordered dictionary.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> Remove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key of the key-value pair to remove. |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | An immutable ordered dictionary that does not contain the |
RemoveRange(IEnumerable<TKey>)
Removes a sequence of key-value pairs from this immutable ordered dictionary.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> RemoveRange(IEnumerable<TKey> keys)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TKey> | keys | The keys of the key-value pairs to remove. |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | An immutable ordered dictionary that does not contain |
SetItem(TKey, TValue)
Assigns a value to a particular key.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> SetItem(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to assign a value to. |
| TValue | value | The value to assign to the key. |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | An immutable ordered dictionary that associates |
SetItems(IEnumerable<KeyValuePair<TKey, TValue>>)
Assigns values to keys.
Declaration
public ImmutableOrderedDictionary<TKey, TValue> SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<KeyValuePair<TKey, TValue>> | items | The key-value pairs to add or update. |
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue> | An immutable ordered dictionary that contains |
ToBuilder()
Creates a mutable version of this immutable ordered dictionary.
Declaration
public ImmutableOrderedDictionary<TKey, TValue>.Builder ToBuilder()
Returns
| Type | Description |
|---|---|
| ImmutableOrderedDictionary<TKey, TValue>.Builder | An ordered dictionary builder. |
TryGetKey(TKey, out TKey)
Determines whether this dictionary contains a specified key.
Declaration
public bool TryGetKey(TKey equalKey, out TKey actualKey)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | equalKey | The key to search for. |
| TKey | actualKey | The matching key located in the dictionary if found, or |
Returns
| Type | Description |
|---|---|
| bool |
TryGetValue(TKey, out TValue)
Gets the value that is associated with the specified key.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | The key to locate. |
| TValue | value | When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the |
Returns
| Type | Description |
|---|---|
| bool | true if the object that implements the IReadOnlyDictionary<TKey, TValue> interface contains an element that has the specified key; otherwise, false. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|