Skip to content

M_CodeJam_Algorithms_Memoize__2_2

Andrew Koryavchenko edited this page Jun 17, 2018 · 2 revisions

Algorithms.Memoize(TArg, TResult) Method (Func(TArg, TResult), IEqualityComparer(TArg), LazyThreadSafetyMode)

Caches function value for specific argument.

Namespace: CodeJam
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static Func<TArg, TResult> Memoize<TArg, TResult>(
	this Func<TArg, TResult> func,
	IEqualityComparer<TArg> comparer,
	LazyThreadSafetyMode threadSafety
)

VB

<ExtensionAttribute>
Public Shared Function Memoize(Of TArg, TResult) ( 
	func As Func(Of TArg, TResult),
	comparer As IEqualityComparer(Of TArg),
	threadSafety As LazyThreadSafetyMode
) As Func(Of TArg, TResult)

F#

[<ExtensionAttribute>]
static member Memoize : 
        func : Func<'TArg, 'TResult> * 
        comparer : IEqualityComparer<'TArg> * 
        threadSafety : LazyThreadSafetyMode -> Func<'TArg, 'TResult> 

Parameters

 

func
Type: System.Func(TArg, TResult)
Function to memoize.
comparer
Type: System.Collections.Generic.IEqualityComparer(TArg)
Argument comparer
threadSafety
Type: System.Threading.LazyThreadSafetyMode
One of the enumeration values that specifies the thread safety mode.

Type Parameters

 

TArg
Type of argument
TResult
Type of result

Return Value

Type: Func(TArg, TResult)
Memoized function

Usage Note

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).

See Also

Reference

Algorithms Class
Memoize Overload
CodeJam Namespace

Clone this wiki locally