IterableScrewDriver<E> extension
provides extensions for Iterable
- on
-
- Iterable<
E>
- Iterable<
Properties
- hasOnlyOneElement → bool
-
Returns true if the collection only has 1 element.
no setter
- lastIndex → int
-
Returns the index of the last element in the collection.
no setter
-
records
→ Iterable<
(int, E)> -
Returns an iterable containing the items with their respective indices
in form of records.
no setter
- secondOrNull → E?
-
Returns the second element in the iterable or
returns null if iterable is empty or has only 1 element.
no setter
- thirdOrNull → E?
-
Returns the third element in the iterable or
returns null if iterable is empty or has less than 3 elements.
no setter
Methods
-
all(
bool test(E element)) → bool - alias for Iterable.every
-
associate<
K, V> ((K, V) transform(E element)) → Map< K, V> -
Returns a Map containing key-value pairs provided by
transform
function applied to elements of the given List. -
associateBy<
K> (K keySelector(E element)) → Map< K, E> -
Returns a Map containing the elements from the given List
indexed by the key returned from
keySelector
function applied to each element. -
associateByTo<
K> (Map< K, E> destination, K keySelector(E element)) → Map<K, E> -
Populates and returns the
destination
mutable map with key-value pairs, where key is provided by thekeySelector
function applied to each element of the given iterable and value is the element itself. -
associateTo<
K, V> (Map< K, V> destination, (K, V) transform(E element)) → Map<K, V> -
Populates and returns the
destination
map with key-value pairs provided bytransform
function applied to each element of the given iterable. -
associateWith<
V> (V valueSelector(E element)) → Map< E, V> -
Returns a Map where keys are elements from the given iterable
and values are produced by the
valueSelector
function applied to each element. -
associateWithTo<
V> (Map< E, V> destination, V valueSelector(E element)) → Map<E, V> -
Populates and returns the
destination
map with key-value pairs for each element of the given iterable, where key is the element itself and value is provided by thevalueSelector
function applied to that key. -
averageBy<
R extends num> (R selector(E element)) → double -
Returns the average of all values produced by
selector
function applied to each element in the collection. -
containsAll(
Iterable< E> other) → bool -
Returns true if the collection contains all the elements
present in
other
collection. -
containsNone(
Iterable< E> other) → bool -
Returns true if the collection doesn't contain any of the elements
present in
other
collection. -
count(
bool predicate(E element)) → int -
Returns the number of elements matching the given
predicate
. -
distinct(
) → Iterable< E> - Returns an iterable containing only distinct elements from the given iterable.
-
distinctBy<
K> (K selector(E element)) → Iterable< E> -
Returns an iterable containing only elements from the given iterable
having distinct keys returned by the given
selector
function. -
distinctByTo<
K> (List< E> destination, K selector(E element)) → Iterable<E> -
Populates and returns the
destination
list with containing only elements from the given iterable having distinct keys returned by the givenselector
function. -
drop(
int count) → Iterable< E> - alias for Iterable.skip
-
dropLast(
int count) → Iterable< E> - alias for Iterable.skip
-
dropWhile(
bool test(E element)) → Iterable< E> - alias for Iterable.skipWhile
-
except(
Iterable< E> other) → Iterable<E> - Alias for subtract.
-
filter(
bool predicate(E element)) → Iterable< E> - alias for Iterable.where
-
filterIndexed(
bool test(int index, E element)) → Iterable< E> -
alias for
whereIndexed
which returns a new lazy Iterable. -
filterTo(
List< E> destination, bool predicate(E element)) → Iterable<E> -
Appends all elements matching the given
predicate
to the givendestination
. -
findAllBy<
S> (S query, S selector(E item)) → Iterable< E> -
Finds all elements where the result of
selector
matches thequery
. Returns empty collection if no element is found. -
findBy<
S> (S query, S selector(E item)) → E -
Finds an element where the result of
selector
matches thequery
. Throws StateError if no element is found. -
findByOrNull<
C> (C query, C selector(E item)) → E? -
Finds an element where the result of
selector
matches thequery
. Returns null if no element is found. -
flatMap<
R> (R transform(E element)) → Iterable< R> - alias for Iterable.map
-
foldRight<
R> (R initialValue, R operation(R previousValue, E element)) → R -
Accumulates value starting with
initialValue
value and applyingoperation
from right to left to each element and current accumulator value. -
foldRightIndexed<
R> (R initialValue, R operation(int index, R previousValue, E element)) → R -
Accumulates value starting with
initialValue
value and applyingoperation
from right to left to each element with its index in the original list and current accumulator value. -
groupBy<
K> (K keySelector(E element)) → Map< K, List< E> > -
Groups elements of the original iterable by the key returned by
the given
keySelector
function applied to each element and returns a map where each group key is associated with a list of corresponding elements. -
groupByTo<
K> (Map< K, List< destination, K keySelector(E element)) → Map<E> >K, List< E> > -
Groups elements of the original iterable by the key returned by
the given
keySelector
function applied to each element and puts to thedestination
map each group key associated with a list of corresponding elements. -
intersect(
Iterable< E> other) → Iterable<E> -
Returns a set containing all elements that are contained by both
this iterable and the
other
iterable. -
maxBy<
R extends Comparable> (R selector(E element)) → E - Returns the first element yielding the largest value of the given function. Throws StateError if there are no elements in the collection.
-
maxByLast<
R extends Comparable> (R selector(E element)) → E - Returns the last element yielding the largest value of the given function. Throws StateError if there are no elements in the collection.
-
maxByLastOrNull<
R extends Comparable> (R selector(E element)) → E? -
Returns the last element yielding the largest value of the given
function or
null
if there are no elements. -
maxByOrNull<
R extends Comparable> (R selector(E element)) → E? -
Returns the first element yielding the largest value of the given
function or
null
if there are no elements. -
minBy<
R extends Comparable> (R selector(E element)) → E - Returns the first element yielding the smallest value of the given function. Throws StateError if there are no elements in the collection.
-
minByLast<
R extends Comparable> (R selector(E element)) → E - Returns the last element yielding the smallest value of the given function. Throws StateError if there are no elements in the collection.
-
minByLastOrNull<
R extends Comparable> (R selector(E element)) → E? -
Returns the last element yielding the smallest value of the given
function or
null
if there are no elements. -
minByOrNull<
R extends Comparable> (R selector(E element)) → E? -
Returns the first element yielding the smallest value of the given
function or
null
if there are no elements. -
onEach(
void action(E element)) → Iterable< E> -
Performs the given
action
on each element and returns the iterable itself afterwards. -
random(
[Random? random]) → E - Returns a random element from this. Throws StateError if there are no elements in the collection.
-
randomOrNull(
[Random? random]) → E? - Returns a random element from this. Returns null if no elements are present.
-
subtract(
Iterable< E> other) → Iterable<E> -
Returns a set containing all elements that are contained by this
iterable and not contained by the
other
iterable. -
sumBy<
R extends num> (R selector(E element)) → R -
Returns the sum of all values produced by
selector
function applied to each element in the collection. -
takeLast(
int count) → Iterable< E> - alias for Iterable.skip
-
union(
Iterable< E> other) → Iterable<E> - Returns an iterable containing all distinct elements from both iterables.