Class CollectionSnapshot<TKey, TIdentity, TState>
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Core.Collections.dll
A collection at one version: the identity map, which changes only at a structural edit, and the state map. A view reads them through its own scope.
[PublicAPI]
public sealed class CollectionSnapshot<TKey, TIdentity, TState> where TKey : notnull where TIdentity : notnull
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
- Inheritance
-
CollectionSnapshot<TKey, TIdentity, TState>
- Inherited Members
- Extension Methods
Remarks
The snapshot of the root is the full store. The snapshot of a view is the same two maps behind a set of keys that the view holds. Thus, a stage costs one small object for each change and copies nothing, and a key that the view does not hold is missing from it. Count counts the view, ContainsKey(TKey) answers for the view, and a lookup of a key out of the view finds nothing. For that cause there is no path from a view to the store below it. The scope is the snapshot, and it is not a wrapper that a caller can remove.
Properties
- Count
The number of items.
- Identities
The immutable part of each item. This code replaces this object only at a structural edit, thus a test of the two references is a correct test for a change of the shape.
- States
The mutable part of each item.
Methods
- ContainsKey(TKey)
True when this snapshot has a key.
- TryGetItem(TKey, out Item<TIdentity, TState>?)
Returns the two parts of the item for a key, when there is one.