Class EnumerableHelpers
Extension methods for IEnumerable collections
Inheritance
Inherited Members
Namespace:numl.Utils
Assembly:numl.dll
Syntax
public static class EnumerableHelpers
              Methods
View SourceBatch<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   | 
                  
| System.Int32 | threads | Number of worker threads.  | 
                  
Type Parameters
| Name | Description | 
|---|---|
| T | Type.  | 
                  
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 | 
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 |