Skip to main content

MemoizeOne<TInput, TOutput>

A class in Root.Township, the global namespace.

Caches the result of a function for the last input only. A new input reruns the function.

Constructors​

MemberWhat it is
MemoizeOne(Func<TInput, TOutput> evaluate, IEqualityComparer<TInput> comparer = null)Creates a MemoizeOne from evaluate and comparer.

Fields​

4 private and internal fields
MemberWhat it is
private IEqualityComparer<TInput> comparerComparer used to match inputs.
private Func<TInput, TOutput> evaluateThe function being cached.
private TInput lastInputThe last input evaluated.
private TOutput lastOutputThe result for lastInput.

Methods​

MemberWhat it is
void Forget()Clears the cached input and output.
TOutput Get(TInput input)Returns the cached output if the input matches the last one, otherwise evaluates and caches. A default input on first call returns default without evaluating.

Used in​

Members of other types that take, return or hold a MemoizeOne&lt;TInput, TOutput>: