Skip to main content

MemoizeHashsetCountTracker<TIn, TOut>

A class in Root.Township, the global namespace.

A set of inputs mapped to outputs through a cached function, with a reference count per output. Raises events when an output first appears and when its last input goes.

Constructors​

MemberWhat it is
MemoizeHashsetCountTracker(MemoizeHashset<TIn, TOut> evaluate, IEqualityComparer<TIn> inputComparer = null, IEqualityComparer<TOut> outputComparer = null)Creates a MemoizeHashsetCountTracker from evaluate, inputComparer and outputComparer.

Fields​

2 private and internal fields
MemberWhat it is
private CountTracker<TOut> counterReference count per output.
private MemoizeHashset<TIn, TOut> hashsetInputs and their cached outputs.

Properties​

MemberWhat it is
int Count { get; }Number of distinct outputs.

Events​

MemberWhat it is
event Action<TOut> FirstAddedRaised when an output gets its first input.
event Action<TOut> LastRemovedRaised when an output loses its last input.

Methods​

MemberWhat it is
bool Add(TIn input, out TOut result)Adds an input and gives its output. True, and FirstAdded raised, only if the output is new.
void Clear()Empties the set without raising events.
bool Remove(TIn input, out TOut result)Removes an input. True, and LastRemoved raised, only if its output has no inputs left.
void RemoveAndClear()Raises LastRemoved for every output, then empties the set.
1 private and internal method
MemberWhat it is
private IEnumerator System.Collections.IEnumerable.GetEnumerator()Enumerates the distinct outputs.

Used in​

Members of other types that take, return or hold a MemoizeHashsetCountTracker&lt;TIn, TOut>: