Class CollectionExtensions
Inheritance
System.Object
CollectionExtensions
Assembly: Edgar.dll
Syntax
public static class CollectionExtensions : Object
Methods
GetWeightedRandom<T>(IList<T>, Func<T, Double>, Random)
Returns a random number based on a given weight function.
Declaration
public static T GetWeightedRandom<T>(this IList<T> elements, Func<T, double> weightSelector, Random random)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IList<T> |
elements |
Collection of elements.
|
System.Func<T, System.Double> |
weightSelector |
A function that assigns weight to individual elements.
|
System.Random |
random |
Random number generator to be used.
|
Returns
Type Parameters
MaxBy<TElement, TResult>(IEnumerable<TElement>, Func<TElement, TResult>)
Computes an index of the first maximum element with respect to a given function.
Declaration
public static int MaxBy<TElement, TResult>(this IEnumerable<TElement> collection, Func<TElement, TResult> func)
where TResult : IComparable<TResult>
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<TElement> |
collection |
|
System.Func<TElement, TResult> |
func |
|
Returns
Type |
Description |
System.Int32 |
|
Type Parameters
Name |
Description |
TElement |
|
TResult |
|
MinBy<TElement, TResult>(IEnumerable<TElement>, Func<TElement, TResult>)
Computes an index of the first minimum element with respect to a given function.
Declaration
public static int MinBy<TElement, TResult>(this IEnumerable<TElement> collection, Func<TElement, TResult> func)
where TResult : IComparable<TResult>
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<TElement> |
collection |
|
System.Func<TElement, TResult> |
func |
|
Returns
Type |
Description |
System.Int32 |
|
Type Parameters
Name |
Description |
TElement |
|
TResult |
|
SequenceEqualWithoutOrder<T>(IEnumerable<T>, IEnumerable<T>)
Check if two collections are equal.
The order does not matter.
Declaration
public static bool SequenceEqualWithoutOrder<T>(this IEnumerable<T> firstEnumerable, IEnumerable<T> secondEnumerable)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<T> |
firstEnumerable |
|
System.Collections.Generic.IEnumerable<T> |
secondEnumerable |
|
Returns
Type |
Description |
System.Boolean |
|
Type Parameters