-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Algorithms_Memoize__2_1
Andrew Koryavchenko edited this page Jun 17, 2018
·
7 revisions
Caches function value for specific argument.
Namespace: CodeJam
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static Func<TArg, TResult> Memoize<TArg, TResult>(
this Func<TArg, TResult> func,
IEqualityComparer<TArg> comparer,
bool threadSafe = false
)
VB
<ExtensionAttribute>
Public Shared Function Memoize(Of TArg, TResult) (
func As Func(Of TArg, TResult),
comparer As IEqualityComparer(Of TArg),
Optional threadSafe As Boolean = false
) As Func(Of TArg, TResult)
F#
[<ExtensionAttribute>]
static member Memoize :
func : Func<'TArg, 'TResult> *
comparer : IEqualityComparer<'TArg> *
?threadSafe : bool
(* Defaults:
let _threadSafe = defaultArg threadSafe false
*)
-> Func<'TArg, 'TResult>
- func
- Type: System.Func(TArg, TResult)
Function to memoize. - comparer
- Type: System.Collections.Generic.IEqualityComparer(TArg)
Argument comparer - threadSafe (Optional)
- Type: System.Boolean
If true - returns thread safe implementation
- TArg
- Type of argument
- TResult
- Type of result
Type: Func(TArg, TResult)
Memoized function
In Visual Basic and C#, you can call this method as an instance method on any object of type Func(TArg, TResult). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).