Show / Hide Table of Contents

Class EnumerableExtensions

Useful extension methods for IEnumerable<T>.

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

Methods

AddRange<T>(ICollection<T>, IEnumerable<T>)

Adds the elements of the specified values to the end of the System.Collections.Generic.ICollection<T>.

Declaration
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> values)
Parameters
System.Collections.Generic.ICollection<T> collection

The collection to added values to.

IEnumerable<T> values

The values that should be added to the end of the ICollection{T}. The values itself cannot be null, but it can contain elements that are null, if type T is a reference type.

Type Parameters
T

The type of elements in the collection.

Each<T>(IEnumerable<T>, Action<T>)

Iterates all items and performs an action.

Declaration
public static void Each<T>(this IEnumerable<T> items, Action<T> action)
Parameters
IEnumerable<T> items

The collection of items to iterate.

System.Action<T> action

The action to perform for each item.

Type Parameters
T

The type of item.

FindMissingNumbersInSequence<T>(IEnumerable<T>, Boolean)

Take a sequence of numbers and report the missing numbers.

Declaration
public static IEnumerable<T> FindMissingNumbersInSequence<T>(this IEnumerable<T> sequence, bool autoOrder = true)
    where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
Parameters
IEnumerable<T> sequence

Set of numbers

Boolean autoOrder

True to autorder the sequence; otherwise false, the default value is true.

Returns
IEnumerable<T>

Returns any missing numbers in the sequence.

Type Parameters
T

FindMissingNumbersInSequence<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>, Boolean)

Takes a collection of items and report the missing numbers in the collection.

Declaration
public static IEnumerable<TResult> FindMissingNumbersInSequence<TSource, TResult>(this IEnumerable<TSource> sequence, Func<TSource, TResult> selector, bool autoOrder = true)
    where TSource : class where TResult : struct, IComparable, IComparable<TResult>, IConvertible, IEquatable<TResult>, IFormattable
Parameters
IEnumerable<TSource> sequence

A collection of items.

System.Func<TSource, TResult> selector

A function used to transform a numeric property from each item in the collection.

Boolean autoOrder

True to autorder the items; otherwise false, the default value is true.

Returns
IEnumerable<TResult>

Returns any missing numbers in the collection.

Type Parameters
TSource

TResult

FindNumbersBeforeNumbersOutOfSequence<T>(IEnumerable<T>, Boolean)

Finds the last number in sequence before numbers that are out of sequence.

Declaration
public static IEnumerable<T> FindNumbersBeforeNumbersOutOfSequence<T>(this IEnumerable<T> sequence, bool autoOrder = true)
    where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
Parameters
IEnumerable<T> sequence

Set of numbers

Boolean autoOrder

True to autorder the sequence; otherwise false, the default value is true.

Returns
IEnumerable<T>

The list of break numbers which exist before the missing numbers.

Type Parameters
T

FindNumbersBeforeNumbersOutOfSequence<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>, Boolean)

Finds the last number in a collection of items before numbers that are out of sequence.

Declaration
public static IEnumerable<TSource> FindNumbersBeforeNumbersOutOfSequence<TSource, TResult>(this IEnumerable<TSource> sequence, Func<TSource, TResult> selector, bool autoOrder = true)
    where TSource : class where TResult : struct, IComparable, IComparable<TResult>, IConvertible, IEquatable<TResult>, IFormattable
Parameters
IEnumerable<TSource> sequence

A collection of items.

System.Func<TSource, TResult> selector

A function used to transform a numeric property from each item in the collection.

Boolean autoOrder

True to autorder the items; otherwise false, the default value is true.

Returns
IEnumerable<TSource>

The list of items which exist before the missing numbers.

Type Parameters
TSource

TResult

FindNumbersOutOfSequence<T>(IEnumerable<T>, Boolean)

Find the numbers that is out of sequence.

Declaration
public static IEnumerable<T> FindNumbersOutOfSequence<T>(this IEnumerable<T> sequence, bool autoOrder = true)
    where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
Parameters
IEnumerable<T> sequence

Set of numbers

Boolean autoOrder

True to autorder the sequence; otherwise false, the default value is true.

Returns
IEnumerable<T>

The list of numbers that is out of sequence.

Type Parameters
T

FindNumbersOutOfSequence<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>, Boolean)

Finds the items that is out of sequence in a collection of items.

Declaration
public static IEnumerable<TSource> FindNumbersOutOfSequence<TSource, TResult>(this IEnumerable<TSource> sequence, Func<TSource, TResult> selector, bool autoOrder = true)
    where TSource : class where TResult : struct, IComparable, IComparable<TResult>, IConvertible, IEquatable<TResult>, IFormattable
Parameters
IEnumerable<TSource> sequence

A collection of items.

System.Func<TSource, TResult> selector

A function used to transform a numeric property from each item in the collection.

Boolean autoOrder

True to autorder the items; otherwise false, the default value is true.

Returns
IEnumerable<TSource>

The items that is out of sequence in a collection of items

Type Parameters
TSource

TResult

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

Group adjacent units Make sure to order to list before on the right property before...

Declaration
public static IEnumerable<IEnumerable<T>> GroupAdjacentBy<T>(this IEnumerable<T> source, Func<T, T, bool> predicate)
Parameters
IEnumerable<T> source

System.Func<T, T, Boolean> predicate

Function som avgör vad som är efter varandra

Returns
IEnumerable<IEnumerable<T>>

Type Parameters
T

IsSequenceBroken<T>(IEnumerable<T>, Boolean)

Take a sequence of numbers and if there are any gaps greater than 1 between the numbers, report true.

Declaration
public static bool IsSequenceBroken<T>(this IEnumerable<T> sequence, bool autoOrder = true)
    where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
Parameters
IEnumerable<T> sequence

A set of numbers.

Boolean autoOrder

True to autorder the sequence; otherwise false, the default value is true.

Returns
Boolean

True if the there is a break in the sequence of numbers.

Type Parameters
T

IsSequenceBroken<TSource, TResult>(IEnumerable<TSource>, Func<TSource, TResult>, Boolean)

Takes a collection of items and return true if there are any gaps greater than 1 between the items, report true.

Declaration
public static bool IsSequenceBroken<TSource, TResult>(this IEnumerable<TSource> sequence, Func<TSource, TResult> selector, bool autoOrder = true)
    where TSource : class where TResult : struct, IComparable, IComparable<TResult>, IConvertible, IEquatable<TResult>, IFormattable
Parameters
IEnumerable<TSource> sequence

A collection of items.

System.Func<TSource, TResult> selector

A function used to transform a numeric property from each item in the collection.

Boolean autoOrder

True to autorder the items; otherwise false, the default value is true.

Returns
Boolean

True true if there are any gaps greater than 1 between the items, otherwise false.

Type Parameters
TSource

TResult

Back to top Generated by DocFX