Table of Contents

Class MemoizationDictionary<TInput, TOutput>

Namespace
Garyon.Objects
Assembly
Garyon.dll

Encapsulates a memoization dictionary for caching outputs of a function that could be expensive to compute.

public sealed class MemoizationDictionary<TInput, TOutput> where TInput : notnull

Type Parameters

TInput
TOutput
Inheritance
MemoizationDictionary<TInput, TOutput>
Inherited Members
Extension Methods

Constructors

MemoizationDictionary(Func<TInput, TOutput>, int)

Encapsulates a memoization dictionary for caching outputs of a function that could be expensive to compute.

public MemoizationDictionary(Func<TInput, TOutput> func, int capacity = 64)

Parameters

func Func<TInput, TOutput>

The function that computes the outputs.

capacity int

The initial capacity of the dictionary.

Methods

Clear()

Clears the cache.

public void Clear()

Get(TInput)

Gets the value of the given input. If the value has not been computed before, it is computed and stored into the dictionary for future retrievals. Otherwise, it's fetched directly from the dictionary.

public TOutput Get(TInput input)

Parameters

input TInput

The input to the function.

Returns

TOutput

The output of the function that was initialized, either cached or computed.