Method Filter
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Collections.dll
Filter<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Func<TIdentity, TState, bool>)
Narrows the view and keeps the upstream order.
public static ReactiveCollection<TKey, TIdentity, TState> Filter<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Func<TIdentity, TState, bool> predicate) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to narrow.
predicateFunc<TIdentity, TState, bool>True when an item is in the view.
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.
Filter<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, Cell<Func<TIdentity, TState, bool>>)
Narrows the view with a predicate 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> Filter<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Cell<Func<TIdentity, TState, bool>> predicateCell) where TKey : notnull where TIdentity : notnull
Parameters
upstreamReactiveCollection<TKey, TIdentity, TState>The collection or view to narrow.
predicateCellCell<Func<TIdentity, TState, 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
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.
Filter<TKey, TIdentity, TState, TCriteria>(ReactiveCollection<TKey, TIdentity, TState>, Cell<TCriteria>, Func<TCriteria, TIdentity, TState, bool>)
Narrows the view with a predicate 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> Filter<TKey, TIdentity, TState, TCriteria>(this ReactiveCollection<TKey, TIdentity, TState> upstream, Cell<TCriteria> criteriaCell, Func<TCriteria, TIdentity, TState, 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, TState, bool>Whether an item belongs in the view, given the criteria.
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
A change to the criteria reports the keys that entered and left as inserts
and removals, not as a reset. 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.