IterableBasics<E> extension

Utility extension methods for the native Iterable class.

on

Methods

all(bool test(E)) bool
Alias for Iterable.every.
average(num value(E)) num?
Returns the average of all the values in this iterable, as defined by value.
containsAll(Iterable<E> other, {bool collapseDuplicates = true}) bool
Returns true if every element in other also exists in this.
containsAny(Iterable<E> other) bool
Returns true if this contains at least one element also contained in other.
getRandom({int? seed}) → E?
Returns a random element of this, or null if this is empty.
getRange(int start, int end) Iterable<E>
Returns an Iterable containing the first end elements of this, excluding the first start elements.
max(Comparator<E> compare) → E?
Returns the greatest element of this as ordered by compare, or null if this is empty.
maxBy(Comparable sortKey(E)) → E?
Returns the element of this with the greatest value for sortKey, or null if this is empty.
min(Comparator<E> compare) → E?
Returns the smallest element of this as ordered by compare, or null if this is empty.
minBy(Comparable sortKey(E)) → E?
Returns the element of this with the least value for sortKey, or null if this is empty.
none(bool test(E)) bool
Returns true if no element of this satisfies test.
one(bool test(E)) bool
Returns true if there is exactly one element of this which satisfies test.
sum(num addend(E)) num
Returns the sum of all the values in this iterable, as defined by addend.