IterableExtensions<E> extension

Extension methods for any Iterable.

on

Properties

firstOrNull → E?
Returns the first element or null if this is empty.
no setter

Methods

avgOf(GetValue<E, int> getVal) double
Returns the average value of int values by elements.
avgOfDouble(GetValue<E, double> getVal) double
Returns the average value of double values by elements.
chunks(int size) Iterable<List<E>>
Splits into chunks of the specified size.
containsAll(Iterable<E> elements) bool
Returns true if the collection contains all elements from the elements.
countWhere(TestPredicate<E> test) int
Returns count of elements that satisfy the predicate test.
firstWhereOrNull(TestPredicate<E> test) → E?
Return the first element that satisfies the given predicate test or null if no element satisfies.
intersperse(E element) Iterable<E>
Adds element between elements of the iterable.
isUnorderedEquivalent(Iterable<E> other) bool
Check equality of the elements of this and other iterables without considering order.
joinOf(GetValue<E, String> getVal, [String separator = '']) String
Get string value for each element and concatenates it with separator.
mapIndex<T>(MapIndexedValue<E, T> toElement) Iterable<T>
Create a new iterable by passing each element and index to the callback.
maxOf<T extends num>(GetValue<E, T> getVal) → T
Returns the max value of int or double values by elements.
minOf<T extends num>(GetValue<E, T> getVal) → T
Returns the min value of int or double values by elements.
reduceValue<T>(T combine(T value, T elementVal), GetValue<E, T> getVal) → T
Reduces values of elements in a collection to a single value by iteratively combining its using the provided function.
sumOf(GetValue<E, int> getVal) int
Returns sum of int values by elements.
sumOfDouble(GetValue<E, double> getVal) double
Returns sum of double values by elements.
toMap<TKey, TVal>(GetValue<E, TKey> getKey, GetValue<E, TVal> getVal) Map<TKey, TVal>
Creates a Map instance from the iterable.
tryElementAt(int index, {E? orElse}) → E?
Returns the element at the index if exists or orElse if it is out of range.