Avoids multiple enumeration.
EnumerationQuest library allows the evaluation of multiple properties of an IEnumerable
in a single enumeration.
It's as simple as that:
var (min, max) = enumerable.GetMin().AndMax();
EnumerationQuest provides the same methods as LINQ to Objects
to evaluate properties of IEnumerable
.
But unlike LINQ, EnumerationQuest allows the evaluation of several properties at once; that's it, in a single enumeration.
To achieve this, EnumerationQuest uses fluent pattern to construct an EnumerationRequests
object.
- The first method is called on the
IEnumerable
source object with theGet
prefix. - The following ones are called on
EnumerationRequests
object with theAnd
prefix. - The enumeration and the evaluations are performed at the deconstruction of the
EnumerationRequests
object.
Et voilà:
var (min, avg, max, count, evenValues) = e.GetMin()
.AndAverage()
.AndMax()
.AndCount()
.And(o => o.Select(i => i % 2 == 0).ToList());
- Aggregate: applies an accumulator function over a sequence.
- All: determines whether all elements of a sequence satisfy a condition.
- Any: determines whether any element of a sequence exists or satisfies a condition.
- Average: computes the average of a sequence of numeric values.
- Contains: determines whether a sequence contains a specified element.
- Count: returns the number of elements in a sequence; or the number of elements that satisfy a condition.
- DelimitedString (aka
String.Join
): concatenates the elements of a sequence, inserting the specified separator between each element. - ElementAt: returns the element at a specified index in a sequence.
- ElementsAt: returns the elements at the specified indices in a sequence.
- ElementAtOrDefault: returns the element at a specified index in a sequence or a default value if the index is out of range.
- First: returns the first element of a sequence; or the first element that satisfies a condition.
- FirstOrDefault: returns the first element of a sequence; or the first element that satisfies a condition; or a default value if such an element does not exist .
- Get/And: transform the sequence into an
IObservable
and allow to use react extensions methods. - HasDuplicates: determines whether a sequence contains a duplicate element.
- IndexOf (from
List<T>
andArray
): returns the zero-based index of the first occurrence of a value in a sequence. - IndicesOf: returns the zero-based indices of all occurrences of a value in a sequence.
- Last: returns the last element of a sequence; or the last element that satisfies a condition.
- LastOrDefault: returns the last element of a sequence; or the last element that satisfies a condition; or a default value if such an element does not exist .
- LongCount: returns a long that represent the number of elements in a sequence; or the number of elements that satisfy a condition.
- Max: returns the maximum value in a sequence of value; or a sequence of transformed values.
- MaxBy: returns the maximum value in a sequence according to a specified key.
- MaximumsBy: returns the maximums values in a sequence according to a specified key.
- Min: returns the minimum value in a sequence of value; or a sequence of transformed values.
- MinBy: returns the minimum value in a sequence according to a specified key.
- MinimumsBy: returns the minimums value in a sequence according to a specified key.
- SequenceEqual: determines whether two sequences are equal according to an equality comparer.
- Single: returns the single element of a sequence; or the single element that satisfies a condition.
- SingleOrDefault: returns the single element of a sequence; or the single element that satisfies a condition; or a default value if such an element does not exist .
- Slice (replace
Skip
,SkipLast
,Take
andTakeLast
): takes a specified range of contiguous elements from a sequence. - Sum: computes the sum of a sequence of numeric values.
- ToDictionary:
creates a
Dictionary<TKey,TValue>
from a sequence. - ToHashSet:
creates a
HashSet<TValue>
from a sequence. - ToLookup:
creates a
ILookup<TKey,TValue>
from a sequence.
See the todo.md file to see the current status of the library.