ExperimentalEnumerableMemoizeT Method
Creates a sequence that lazily caches the source as it is iterated
for the first time, reusing the cache thereafter for future
re-iterations. If the source is already cached or buffered then it
is returned verbatim.
Namespace: MoreLinq.ExperimentalAssembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
public static IEnumerable<T> Memoize<T>(
this IEnumerable<T> source
)
<ExtensionAttribute>
Public Shared Function Memoize(Of T) (
source As IEnumerable(Of T)
) As IEnumerable(Of T)
public:
[ExtensionAttribute]
generic<typename T>
static IEnumerable<T>^ Memoize(
IEnumerable<T>^ source
)
[<ExtensionAttribute>]
static member Memoize :
source : IEnumerable<'T> -> IEnumerable<'T>
- source IEnumerableT
- The source sequence.
- T
-
Type of elements in source.
IEnumerableT
Returns a sequence that corresponds to a cached version of the input
sequence.
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. 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).
The returned
IEnumerableT will cache items from
source in a thread-safe manner. Each thread can
call its
GetEnumerator to acquire an
iterator but the same iterator should not be used simultaneously
from multiple threads. The sequence supplied in
source is not expected to be thread-safe but it is required
to be thread-agnostic because different threads (though never
simultaneously) may iterate over the sequence.