EnumerableExtensions Type

Extensions to the IEnumerable interface.

Static members

Static member Description

EnumerableExtensions.AreStructurallyEqual(e1, e2)

Full Usage: EnumerableExtensions.AreStructurallyEqual(e1, e2)

Parameters:
Returns: bool true if the two enumerations are structural equivalent; otherwise, false.

Determines whether two enumerations are structural equivalent. They are structurally equivalent if i) both enumerations are null, ii) both enumerations are empty, or c) both enumerations have the same number of elements and contain the same elements in the same order. Please not that if one enumeration is null and the other is empty, they are not considered equivalent.

e1 : IEnumerable<'T>

The first enumeration.

e2 : IEnumerable<'T>

The second enumeration.

Returns: bool

true if the two enumerations are structural equivalent; otherwise, false.

EnumerableExtensions.AreStructurallyEqual(e1, e2, equalityComparer)

Full Usage: EnumerableExtensions.AreStructurallyEqual(e1, e2, equalityComparer)

Parameters:
    e1 : IEnumerable<'T> - The first enumeration.
    e2 : IEnumerable<'T> - The second enumeration.
    equalityComparer : IEqualityComparer<'T> - The equality comparer to compare the elements of the enumeration.

Returns: bool true if the two enumerations are structural equivalent; otherwise, false.

Determines whether two enumerations are structural equivalent. They are structural equivalent if i) both enumerations are null, ii) both enumerations are empty, or c) both enumerations have the same number of elements and contain the same elements in the same order. Please not that if one enumeration is null and the other is empty, they are not considered equivalent.

e1 : IEnumerable<'T>

The first enumeration.

e2 : IEnumerable<'T>

The second enumeration.

equalityComparer : IEqualityComparer<'T>

The equality comparer to compare the elements of the enumeration.

Returns: bool

true if the two enumerations are structural equivalent; otherwise, false.

EnumerableExtensions.FirstOr(org, otherValue)

Full Usage: EnumerableExtensions.FirstOr(org, otherValue)

Parameters:
    org : IEnumerable<'T> - The enumeration.
    otherValue : 'T - The other value.

Returns: 'T First value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

Returns the first value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

org : IEnumerable<'T>

The enumeration.

otherValue : 'T

The other value.

Returns: 'T

First value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

EnumerableExtensions.FlattenFromRootToLeaves(root, recursion)

Full Usage: EnumerableExtensions.FlattenFromRootToLeaves(root, recursion)

Parameters:
    root : 'T - The root element of the recursive data structure.
    recursion : Func<'T, IEnumerable<'T>> - The function that gets the children of an element. If no children of an element exist, the function is allowed to return null.

Returns: IEnumerable<'T> Iterator that enumerates the tree structure in preorder.

Converts a recursive data structure into a flat list. The root element is enumerated before its corresponding child element(s).

root : 'T

The root element of the recursive data structure.

recursion : Func<'T, IEnumerable<'T>>

The function that gets the children of an element. If no children of an element exist, the function is allowed to return null.

Returns: IEnumerable<'T>

Iterator that enumerates the tree structure in preorder.

EnumerableExtensions.ForEachDo(seq, action)

Full Usage: EnumerableExtensions.ForEachDo(seq, action)

Parameters:
    seq : IEnumerable<'T> - The element sequence.
    action : Action<'T> - The action to execute for each element.

Executes an action for each element of the sequence.

seq : IEnumerable<'T>

The element sequence.

action : Action<'T>

The action to execute for each element.

EnumerableExtensions.HasSingleElement(org)

Full Usage: EnumerableExtensions.HasSingleElement(org)

Parameters:
Returns: bool true if the specified enumeration contains excactly one element; otherwise, false.

Determines whether the specified enumeration has exactly one element.

org : IEnumerable<'T>

The enumeration to test.

Returns: bool

true if the specified enumeration contains excactly one element; otherwise, false.

ArgumentNullException The enumeration to test is null.

EnumerableExtensions.IsEmpty(org)

Full Usage: EnumerableExtensions.IsEmpty(org)

Parameters:
Returns: bool true if the specified org is empty; otherwise, false.

Determines whether the specified enumeration is empty.

org : IEnumerable<'T>

The enumeration to test.

Returns: bool

true if the specified org is empty; otherwise, false.

ArgumentNullException The enumeration to test is null.

EnumerableExtensions.LastOr(org, otherValue)

Full Usage: EnumerableExtensions.LastOr(org, otherValue)

Parameters:
    org : IEnumerable<'T> - The enumeration.
    otherValue : 'T - The other value.

Returns: 'T Last value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

Returns the last value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

org : IEnumerable<'T>

The enumeration.

otherValue : 'T

The other value.

Returns: 'T

Last value of the enumeration, or, if the enumeration is empty, the other value provided in the arguments.

EnumerableExtensions.MaxElement(org, conversion)

Full Usage: EnumerableExtensions.MaxElement(org, conversion)

Parameters:
    org : IEnumerable<'T> - The enumeration to consider.
    conversion : Func<'T, 'M> - Conversion function that converts each element (type: ) of the sequence to a value (of type that is comparable.

Returns: 'T This element of the sequence, which by the provided conversion function evaluates to the maximum value.

Gets the element of a IEnumerabe that evaluates by means of a conversion function to the maximal value. This is different from Select(x => conversion(x)).Max() insofar as it not returns the maximum value, but the original element x which converts to the maximum value.

org : IEnumerable<'T>

The enumeration to consider.

conversion : Func<'T, 'M>

Conversion function that converts each element (type: ) of the sequence to a value (of type that is comparable.

Returns: 'T

This element of the sequence, which by the provided conversion function evaluates to the maximum value.

InvalidOperationException The provided enumeration is empty. Thus it is not possible to evaluate the maximum.

EnumerableExtensions.MaxOrDefault(seq, defaultValue)

Full Usage: EnumerableExtensions.MaxOrDefault(seq, defaultValue)

Parameters:
    seq : IEnumerable<'T> - The enumeration.
    defaultValue : 'T - The default value that is returned if the enumeration is empty.

Returns: 'T The maximum of of all elements, or the defaultValue if the series is empty.

Evaluates the maximum of a enumeration of elements, or returns a default value if the series is empty.

seq : IEnumerable<'T>

The enumeration.

defaultValue : 'T

The default value that is returned if the enumeration is empty.

Returns: 'T

The maximum of of all elements, or the defaultValue if the series is empty.

EnumerableExtensions.MaxOrDefault(seq, conversion, defaultValue)

Full Usage: EnumerableExtensions.MaxOrDefault(seq, conversion, defaultValue)

Parameters:
    seq : IEnumerable<'T> - The enumeration of elements.
    conversion : Func<'T, 'M> - Conversion function which converts the type of the original sequence into a type which is used to determine the maximum value.
    defaultValue : 'M - The default value that is returned if the enumeration is empty.

Returns: 'M The maximum of of all comparison values of the elements, or the defaultValue if the series is empty.

Evaluates the maximum of a enumeration of elements, or returns a default value if the series is empty.

seq : IEnumerable<'T>

The enumeration of elements.

conversion : Func<'T, 'M>

Conversion function which converts the type of the original sequence into a type which is used to determine the maximum value.

defaultValue : 'M

The default value that is returned if the enumeration is empty.

Returns: 'M

The maximum of of all comparison values of the elements, or the defaultValue if the series is empty.

EnumerableExtensions.MinOrDefault(seq, defaultValue)

Full Usage: EnumerableExtensions.MinOrDefault(seq, defaultValue)

Parameters:
    seq : IEnumerable<'T> - The enumeration.
    defaultValue : 'T - The default value that is returned if the enumeration is empty.

Returns: 'T The minimum of of all elements, or the defaultValue if the series is empty.

Evaluates the minimum of a enumeration of elements, or returns a default value if the series is empty.

seq : IEnumerable<'T>

The enumeration.

defaultValue : 'T

The default value that is returned if the enumeration is empty.

Returns: 'T

The minimum of of all elements, or the defaultValue if the series is empty.

EnumerableExtensions.ThisOrEmpty(org)

Full Usage: EnumerableExtensions.ThisOrEmpty(org)

Parameters:
    org : IEnumerable<'T> - The orginal enumeration (may be null)

Returns: IEnumerable<'T> Either the original enumeration (if it is not null); otherwise, an empty enumeration.

Returns either the provided enumeration, or if it is null, an empty enumeration.

org : IEnumerable<'T>

The orginal enumeration (may be null)

Returns: IEnumerable<'T>

Either the original enumeration (if it is not null); otherwise, an empty enumeration.

EnumerableExtensions.TryGetFirstAndLast(org, first, last)

Full Usage: EnumerableExtensions.TryGetFirstAndLast(org, first, last)

Parameters:
    org : IEnumerable<'T> - The enumeration.
    first : byref<'T> - if successful, the first value of the enumeration.
    last : byref<'T> - If successful, the last value of the enumeration.

Returns: bool True if successful; otherwise false.

Returns true and the first and last value of the enumeration, or, if the enumeration is empty, returns false.

org : IEnumerable<'T>

The enumeration.

first : byref<'T>

if successful, the first value of the enumeration.

last : byref<'T>

If successful, the last value of the enumeration.

Returns: bool

True if successful; otherwise false.

EnumerableExtensions.TryGetSingleElement(org, singleElement)

Full Usage: EnumerableExtensions.TryGetSingleElement(org, singleElement)

Parameters:
    org : IEnumerable<'T> - The enumeration.
    singleElement : byref<'T> - If the enumeration contains exactly one element, this parameter contains the element. Otherwise, the parameter contains the default for this type.

Returns: bool true if the specified enumeration contains excactly one element; otherwise, false.

Try to get the one and only element of the collection.

org : IEnumerable<'T>

The enumeration.

singleElement : byref<'T>

If the enumeration contains exactly one element, this parameter contains the element. Otherwise, the parameter contains the default for this type.

Returns: bool

true if the specified enumeration contains excactly one element; otherwise, false.

ArgumentNullException org