Struct ValueDictionary<TKey, TValue>.KeysEnumerator
- Namespace
- Badeend.ValueCollections
- Assembly
- Badeend.ValueCollections.dll
This type facilitates reading only the keys of a dictionary.
public struct ValueDictionary<TKey, TValue>.KeysEnumerator
- Inherited Members
Remarks
This is a stack-allocated enumerator over the keys in the dictionary.
To prevent accidental boxing, KeysEnumerator does not implement any interface. If you want to use the keys as a collection (e.g. IEnumerable<T>, IReadOnlyCollection<T>, etc.) you can still manually box it by calling AsCollection().
Properties
Current
Gets the element in the collection at the current position of the enumerator.
public readonly ref readonly TKey Current { get; }
Property Value
- TKey
Methods
AsCollection()
Create a new heap-allocated view over the keys in the dictionary.
public readonly ValueDictionary<TKey, TValue>.KeysCollection AsCollection()
Returns
- ValueDictionary<TKey, TValue>.KeysCollection
Remarks
This method is an O(1)
operation and allocates a new fixed-size
collection instance. The items are not copied.
GetEnumerator()
Returns a new KeysEnumerator.
Typically, you don't need to manually call this method, but instead use
the built-in foreach
syntax.
public readonly ValueDictionary<TKey, TValue>.KeysEnumerator GetEnumerator()
Returns
- ValueDictionary<TKey, TValue>.KeysEnumerator
MoveNext()
Advances the enumerator to the next element of the collection.
public bool MoveNext()