Show / Hide Table of Contents

Class EnumerableHelpers

Extension methods for IEnumerable collections

Inheritance
System.Object
EnumerableHelpers
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:numl.Utils
Assembly:numl.dll
Syntax
public static class EnumerableHelpers

Methods

View Source

Batch<T>(IEnumerable<T>, Int32, Action<Int32, IEnumerable<T>>, Boolean, Int32)

Executes a batch operation on the source collection, optionally running in parallel.

Declaration
public static void Batch<T>(this IEnumerable<T> source, int batchSize, Action<int, IEnumerable<T>> batchCommand, bool asParallel = false, int threads = 1)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Enumerable to batch.

System.Int32 batchSize

Size of each batch.

System.Action<System.Int32, System.Collections.Generic.IEnumerable<T>> batchCommand

Action to apply on each batch, with batch index and corresponding items.

System.Boolean asParallel

If True, each batch is run asynchronously.

System.Int32 threads

Number of worker threads.

Type Parameters
Name Description
T

Type.

View Source

ForEach<T, R>(IEnumerable<T>, Func<T, R>)

Performs the specified action and returns the result.

Declaration
public static IEnumerable<R> ForEach<T, R>(this IEnumerable<T> source, Func<T, R> fnTransform)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source array

System.Func<T, R> fnTransform

Function to apply to each element

Returns
Type Description
System.Collections.Generic.IEnumerable<R>
Type Parameters
Name Description
T
R
View Source

Head<T, R>(IEnumerable<T>, Func<T, R>)

Returns the first element in a sequence applying the transform function.

Declaration
public static R Head<T, R>(this IEnumerable<T> source, Func<T, R> fnSelector)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source.

System.Func<T, R> fnSelector

Selector.

Returns
Type Description
R
Type Parameters
Name Description
T
R
View Source

Head<T, R>(IEnumerable<T>, Int32, Func<T, R>)

Returns the first element in a sequence applying the transform function.

Declaration
public static IEnumerable<R> Head<T, R>(IEnumerable<T> source, int count, Func<T, R> fnSelector)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source.

System.Int32 count

Number of items from the top to return.

System.Func<T, R> fnSelector

Selector.

Returns
Type Description
System.Collections.Generic.IEnumerable<R>
Type Parameters
Name Description
T
R
View Source

IndexOf<T>(IEnumerable<T>, T)

Gets the index of the specified item in the source array.

Declaration
public static int IndexOf<T>(this IEnumerable<T> source, T item)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source array

T item

Object to test for.

Returns
Type Description
System.Int32
Type Parameters
Name Description
T
View Source

IndexOf<T>(IEnumerable<T>, Func<T, Boolean>)

Gets the index of the specified item in the source array using the specified test function.

Declaration
public static int IndexOf<T>(this IEnumerable<T> source, Func<T, bool> fnPredicate)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source array

System.Func<T, System.Boolean> fnPredicate

Predicate to test for.

Returns
Type Description
System.Int32

Int.

Type Parameters
Name Description
T
View Source

IsAscending(IEnumerable<Double>)

Calculates the slope of the source array and returns True if the values are increasing.

Declaration
public static bool IsAscending(this IEnumerable<double> source)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Double> source
Returns
Type Description
System.Boolean
View Source

Random<T>(IEnumerable<T>)

Returns a random element from the sequence.

Declaration
public static T Random<T>(this IEnumerable<T> source)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source sequence.

Returns
Type Description
T
Type Parameters
Name Description
T
View Source

Shuffle<T>(IEnumerable<T>)

Randomly shuffles the indexing of the source array.

Declaration
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source sequence.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T
View Source

Slice<T>(IEnumerable<T>, IEnumerable<Int32>)

Returns the slice of objects using the specified index arrays.

Declaration
public static IEnumerable<T> Slice<T>(this IEnumerable<T> source, IEnumerable<int> indices)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source
System.Collections.Generic.IEnumerable<System.Int32> indices
Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T
View Source

StandardDeviation<TSource>(IEnumerable<TSource>, Func<TSource, Double>, Boolean)

Calculates the standard deviation on the source collection

Declaration
public static double StandardDeviation<TSource>(this IEnumerable<TSource> source, Func<TSource, double> fnPropSelector, bool isSamplePopulation = false)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TSource> source
System.Func<TSource, System.Double> fnPropSelector
System.Boolean isSamplePopulation
Returns
Type Description
System.Double
Type Parameters
Name Description
TSource
View Source

Tail<T, R>(IEnumerable<T>, Func<T, R>)

Returns the last element in a sequence applying the transform function.

Declaration
public static R Tail<T, R>(this IEnumerable<T> source, Func<T, R> fnSelector)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source.

System.Func<T, R> fnSelector

Selector.

Returns
Type Description
R
Type Parameters
Name Description
T
R
View Source

Tail<T, R>(IEnumerable<T>, Int32, Func<T, R>)

Returns the last elements in a sequence applying the transform function.

Declaration
public static IEnumerable<R> Tail<T, R>(this IEnumerable<T> source, int count, Func<T, R> fnSelector)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T> source

Source.

System.Int32 count

Number of items from the end to return.

System.Func<T, R> fnSelector

Selector.

Returns
Type Description
System.Collections.Generic.IEnumerable<R>
Type Parameters
Name Description
T
R
View Source

Variance<TSource>(IEnumerable<TSource>, Func<TSource, Double>, Boolean)

Calculates the variance on the source collection

Declaration
public static double Variance<TSource>(this IEnumerable<TSource> source, Func<TSource, double> fnPropSelector, bool isSamplePopulation = false)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TSource> source
System.Func<TSource, System.Double> fnPropSelector
System.Boolean isSamplePopulation
Returns
Type Description
System.Double
Type Parameters
Name Description
TSource
  • View Source
©2017 — Seth Juarez
numl v0.9.20-beta
MIT License
docs by docfx