|
@@ -11,27 +11,27 @@ namespace System.Linq
|
|
|
public static partial class EnumerableEx
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to all of the
|
|
|
- /// sequence's elements without causing multiple enumerations over the source.
|
|
|
+ /// Creates a buffer with a view over the source sequence, causing each enumerator to obtain access to all of the
|
|
|
+ /// sequence's elements without causing multiple enumerations over the source.
|
|
|
/// </summary>
|
|
|
/// <typeparam name="TSource">Source sequence element type.</typeparam>
|
|
|
/// <param name="source">Source sequence.</param>
|
|
|
/// <returns>
|
|
|
- /// Buffer enabling each enumerator to retrieve all elements from the shared source sequence, without duplicating
|
|
|
- /// source enumeration side-effects.
|
|
|
+ /// Buffer enabling each enumerator to retrieve all elements from the shared source sequence, without duplicating
|
|
|
+ /// source enumeration side-effects.
|
|
|
/// </returns>
|
|
|
/// <example>
|
|
|
- /// var rng = Enumerable.Range(0, 10).Do(x => Console.WriteLine(x)).Memoize();
|
|
|
- /// var e1 = rng.GetEnumerator();
|
|
|
- /// Assert.IsTrue(e1.MoveNext()); // Prints 0
|
|
|
- /// Assert.AreEqual(0, e1.Current);
|
|
|
- /// Assert.IsTrue(e1.MoveNext()); // Prints 1
|
|
|
- /// Assert.AreEqual(1, e1.Current);
|
|
|
- /// var e2 = rng.GetEnumerator();
|
|
|
- /// Assert.IsTrue(e2.MoveNext()); // Doesn't print anything; the side-effect of Do
|
|
|
- /// Assert.AreEqual(0, e2.Current); // has already taken place during e1's iteration.
|
|
|
- /// Assert.IsTrue(e1.MoveNext()); // Prints 2
|
|
|
- /// Assert.AreEqual(2, e1.Current);
|
|
|
+ /// var rng = Enumerable.Range(0, 10).Do(x => Console.WriteLine(x)).Memoize();
|
|
|
+ /// var e1 = rng.GetEnumerator();
|
|
|
+ /// Assert.IsTrue(e1.MoveNext()); // Prints 0
|
|
|
+ /// Assert.AreEqual(0, e1.Current);
|
|
|
+ /// Assert.IsTrue(e1.MoveNext()); // Prints 1
|
|
|
+ /// Assert.AreEqual(1, e1.Current);
|
|
|
+ /// var e2 = rng.GetEnumerator();
|
|
|
+ /// Assert.IsTrue(e2.MoveNext()); // Doesn't print anything; the side-effect of Do
|
|
|
+ /// Assert.AreEqual(0, e2.Current); // has already taken place during e1's iteration.
|
|
|
+ /// Assert.IsTrue(e1.MoveNext()); // Prints 2
|
|
|
+ /// Assert.AreEqual(2, e1.Current);
|
|
|
/// </example>
|
|
|
public static IBuffer<TSource> Memoize<TSource>(this IEnumerable<TSource> source)
|
|
|
{
|
|
@@ -42,8 +42,8 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the
|
|
|
- /// sequence's elements without causing multiple enumerations over the source.
|
|
|
+ /// Memoizes the source sequence within a selector function where each enumerator can get access to all of the
|
|
|
+ /// sequence's elements without causing multiple enumerations over the source.
|
|
|
/// </summary>
|
|
|
/// <typeparam name="TSource">Source sequence element type.</typeparam>
|
|
|
/// <typeparam name="TResult">Result sequence element type.</typeparam>
|
|
@@ -61,18 +61,18 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Creates a buffer with a view over the source sequence, causing a specified number of enumerators to obtain access
|
|
|
- /// to all of the sequence's elements without causing multiple enumerations over the source.
|
|
|
+ /// Creates a buffer with a view over the source sequence, causing a specified number of enumerators to obtain access
|
|
|
+ /// to all of the sequence's elements without causing multiple enumerations over the source.
|
|
|
/// </summary>
|
|
|
/// <typeparam name="TSource">Source sequence element type.</typeparam>
|
|
|
/// <param name="source">Source sequence.</param>
|
|
|
/// <param name="readerCount">
|
|
|
- /// Number of enumerators that can access the underlying buffer. Once every enumerator has
|
|
|
- /// obtained an element from the buffer, the element is removed from the buffer.
|
|
|
+ /// Number of enumerators that can access the underlying buffer. Once every enumerator has
|
|
|
+ /// obtained an element from the buffer, the element is removed from the buffer.
|
|
|
/// </param>
|
|
|
/// <returns>
|
|
|
- /// Buffer enabling a specified number of enumerators to retrieve all elements from the shared source sequence,
|
|
|
- /// without duplicating source enumeration side-effects.
|
|
|
+ /// Buffer enabling a specified number of enumerators to retrieve all elements from the shared source sequence,
|
|
|
+ /// without duplicating source enumeration side-effects.
|
|
|
/// </returns>
|
|
|
public static IBuffer<TSource> Memoize<TSource>(this IEnumerable<TSource> source, int readerCount)
|
|
|
{
|
|
@@ -85,19 +85,19 @@ namespace System.Linq
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to
|
|
|
- /// all of the sequence's elements without causing multiple enumerations over the source.
|
|
|
+ /// Memoizes the source sequence within a selector function where a specified number of enumerators can get access to
|
|
|
+ /// all of the sequence's elements without causing multiple enumerations over the source.
|
|
|
/// </summary>
|
|
|
/// <typeparam name="TSource">Source sequence element type.</typeparam>
|
|
|
/// <typeparam name="TResult">Result sequence element type.</typeparam>
|
|
|
/// <param name="source">Source sequence.</param>
|
|
|
/// <param name="readerCount">
|
|
|
- /// Number of enumerators that can access the underlying buffer. Once every enumerator has
|
|
|
- /// obtained an element from the buffer, the element is removed from the buffer.
|
|
|
+ /// Number of enumerators that can access the underlying buffer. Once every enumerator has
|
|
|
+ /// obtained an element from the buffer, the element is removed from the buffer.
|
|
|
/// </param>
|
|
|
/// <param name="selector">
|
|
|
- /// Selector function with memoized access to the source sequence for a specified number of
|
|
|
- /// enumerators.
|
|
|
+ /// Selector function with memoized access to the source sequence for a specified number of
|
|
|
+ /// enumerators.
|
|
|
/// </param>
|
|
|
/// <returns>Sequence resulting from applying the selector function to the memoized view over the source sequence.</returns>
|
|
|
public static IEnumerable<TResult> Memoize<TSource, TResult>(this IEnumerable<TSource> source, int readerCount, Func<IEnumerable<TSource>, IEnumerable<TResult>> selector)
|