ConcurrentLruCache<TKey, TValue>.Enumerator Struct
Definition
- Namespace
- Bodu.Collections.Generic.Concurrent
- Assembly
- Bodu.Collections.Concurrent.dll
- Package
- Bodu.Collections.Concurrent 1.0.0
Enumerates a point-in-time snapshot of a ConcurrentLruCache<TKey, TValue>.
public struct ConcurrentLruCache<TKey, TValue>.Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>, IEnumerator, IDisposable
- Implements
-
IEnumerator<KeyValuePair<TKey, TValue>>
- Inherited Members
- Extension Methods
Remarks
The enumerator captures a snapshot of the cache's entries when it is created, by calling ToArray(). All iteration runs over that fixed copy and is unaffected by concurrent additions, removals, or evictions on the originating cache.
Because the snapshot is taken eagerly, creating the enumerator allocates an array proportional to the number of entries present at that moment. The enumerator never throws InvalidOperationException as a result of concurrent modification.
The order in which entries are yielded is unspecified and may differ between enumerators.
Properties
Current
Gets the entry at the current position of the enumerator.
public readonly KeyValuePair<TKey, TValue> Current { get; }
Property Value
- KeyValuePair<TKey, TValue>
The entry at the enumerator's current position.
Methods
Dispose()
Releases all resources used by the enumerator.
public readonly void Dispose()
Remarks
The enumerator holds no unmanaged or disposable resources; this method does nothing.
MoveNext()
Advances the enumerator to the next entry of the snapshot.
public bool MoveNext()
Returns
- bool
true if the enumerator advanced to a new entry; false if it has passed the end of the snapshot.
Remarks
A default-valued ConcurrentLruCache<TKey, TValue>.Enumerator - one produced by default rather than by
GetEnumerator() - holds no snapshot and is treated as an empty
sequence.
Reset()
Resets the enumerator to its initial position, before the first entry of the snapshot.
public void Reset()
Explicit Interface Implementations
IEnumerator.Current
Gets the entry at the current position of the enumerator.
readonly object IEnumerator.Current { get; }
Returns
- object
The entry at the enumerator's current position.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |