A structure that memoizes the result of some computation for later reuse.
Namespace:
Gallio.CommonAssembly: Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.459.0)
Syntax
| C# |
|---|
public struct Memoizer<T> |
| Visual Basic (Declaration) |
|---|
Public Structure Memoizer(Of T) |
Type Parameters
- T
- The value type.
Remarks
Not thread safe.
Examples
public class MyClass { // Do NOT put the "readonly" keyword on this field. // Otherwise we will not be able to modify the contents of the structure and memoization will not occur. private Memoizer<int> valueMemoizer = new Memoizer<int>(); public int GetValue() { return valueMemoizer.Memoize(() => { // Expensive calculation here. return 42; }); } }
