EnumerableExtensions

Namespace: SnowBank.Linq · class

Provides a set of static methods for querying objects that implement IEnumerable.

Methods

Buffered

static IEnumerable<List<T>> Buffered<T>(IEnumerable<T> source, int batchSize)

Split a sequence of items into several batches

  • source — Source sequence
  • batchSize — Maximum size of each batch

Returns: Sequence of batches, whose size will always we batchSize, except for the last batch that will only hold the remaining items. If the source is empty, an empty sequence is returned.

None

static bool None<T>(IEnumerable<T> source)

Determines whether a sequence contains no elements at all.

This is the logical equivalent to "source.Count() == 0" or "!source.Any()" but can be better optimized by some providers

static bool None<T>(IEnumerable<T> source, Func<T, bool> predicate)

Determines whether none of the elements of a sequence satisfies a condition.

Observe

static IEnumerable<TSource> Observe<TSource>(IEnumerable<TSource> source, Action<TSource> handler)

Execute an action on each item passing through the sequence, without modifying the original sequence

The is executed inline before passing the item down the line, and should not block

WithCountStatistics

static IEnumerable<TSource> WithCountStatistics<TSource>(IEnumerable<TSource> source, out QueryStatistics<int> counter)

Measure the number of items that pass through this point of the query

The values returned in are only safe to read once the query has ended

WithSizeStatistics

static IEnumerable<KeyValuePair<Slice, Slice>> WithSizeStatistics(IEnumerable<KeyValuePair<Slice, Slice>> source, out QueryStatistics<KeyValueSizeStatistics> statistics)

Measure the number and size of slices that pass through this point of the query

The values returned in are only safe to read once the query has ended

static IEnumerable<Slice> WithSizeStatistics(IEnumerable<Slice> source, out QueryStatistics<DataSizeStatistics> statistics)

Measure the number and sizes of the keys and values that pass through this point of the query

The values returned in are only safe to read once the query has ended