Method FilterByIdentity
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Collections.dll
FilterByIdentity<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, bool>)
Narrows the view with a predicate on the immutable part of each item, which is its identity. A state edit cannot change that part.
public static ReactiveCollection<TKey, TIdentity, TState> FilterByIdentity<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, bool> predicate) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to narrow.
predicateFunc<TIdentity, bool>Whether an item belongs in the view, given its identity.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view with the items that the predicate accepts.
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.
Remarks
This gives the same members as Filter for the same answers, and it
costs less to keep. A state edit cannot move a key into this filter or out
of it, thus the stage does not test the predicate again and does not read
the previous membership of the key. It sends the update on.
This is not a statement that a reader must accept. The predicate receives
the identity and not the state, thus it cannot read the state that it says
it does not read.
FilterByIdentity<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Cell<Func<TIdentity, bool>>)
Narrows the view with a predicate on the identity of each item that can change. Each change to the predicate tests each item of the upstream again, and reports the keys that entered and left as inserts and removals, not as a reset.
public static ReactiveCollection<TKey, TIdentity, TState> FilterByIdentity<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Cell<Func<TIdentity, bool>> predicateCell) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to narrow.
predicateCellCell<Func<TIdentity, bool>>The predicate in force.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view with the items that the predicate accepts.
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.
Remarks
See
FilterByIdentity<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, bool>)
. A state edit still does not test the predicate. When a change to the
predicate moves more keys than a list of them is worth, this stage builds
again, at a cost of O(m log m) in the size of the upstream, and
reports a reset.
FilterByIdentity<TKey, TIdentity, TState, TCriteria>(ReactiveCollection<TKey, TIdentity, TState>, Cell<TCriteria>, Func<TCriteria, TIdentity, bool>)
Narrows the view with a predicate on the identity of each item from a different source, such as a search box or a toggle. Each change to the criteria tests each item of the upstream again, thus a criteria from a keystroke needs a Calm stage above this one.
public static ReactiveCollection<TKey, TIdentity, TState> FilterByIdentity<TKey, TIdentity, TState, TCriteria>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Cell<TCriteria> criteriaCell, Func<TCriteria, TIdentity, bool> predicate) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to narrow.
criteriaCellCell<TCriteria>The criteria in force.
predicateFunc<TCriteria, TIdentity, bool>Whether an item belongs in the view, given the criteria and its identity.
Returns
- ReactiveCollection<TKey, TIdentity, TState>
A view with the items that the predicate accepts.
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.
TCriteriaThe type of the criteria for the predicate.
Remarks
See
FilterByIdentity<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, bool>)
. A change to the criteria reports the keys that entered and left as
inserts and removals, not as a reset, and a state edit still does not test
the predicate. When more keys move than a list of them is worth, this stage
builds again, at a cost of O(m log m) in the size of the upstream,
and reports a reset.