Skip to main content

MemoizeHashset<TIn, TOut>

A class in Root.Township, the global namespace.

A cache that runs an evaluate function once per input and keeps only the inputs it accepted, with their results.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private MemoizeHashset<TIn, TOut> evaluateThe function that decides if an input is kept and works out its result.
private Dictionary<TIn, TOut> lookupThe stored inputs and their results, using the comparer passed to the constructor.

Methods​

MemberWhat it is
bool Add(TIn input, out TOut result)Runs the evaluate function for a new input and stores the result if it returns true. Returns false for inputs already stored or rejected.
void Clear()Empties the cache.
bool Get(TIn input, out TOut result)Looks up a stored result without running the evaluate function.
bool Remove(TIn input, out TOut result)Takes an input out of the cache and returns its stored result.

Used in​

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