IterableExtension<T> extension
Extensions that apply to all iterables.
These extensions provide direct access to some of the algorithms expose by this package, as well as some generally useful convenience methods.
More specialized extension methods that only apply to iterables with specific element types include those of IterableComparableExtension and IterableNullableExtension.
- on
-
- Iterable<
T>
- Iterable<
Properties
- firstOrNull → T?
-
Available on Iterable<
The first element, orT> , provided by the IterableExtension extensionnull
if the iterable is empty.no setter - lastOrNull → T?
-
Available on Iterable<
The last element, orT> , provided by the IterableExtension extensionnull
if the iterable is empty.no setter - singleOrNull → T?
-
Available on Iterable<
The single element of the iterable, orT> , provided by the IterableExtension extensionnull
.no setter
Methods
-
elementAtOrNull(
int index) → T? -
Available on Iterable<
TheT> , provided by the IterableExtension extensionindex
th element, ornull
if there is no such element. -
expandIndexed<
R> (Iterable< R> expand(int index, T element)) → Iterable<R> -
Available on Iterable<
Expands each element and index to a number of elements in a new iterable.T> , provided by the IterableExtension extension -
firstWhereIndexedOrNull(
bool test(int index, T element)) → T? -
Available on Iterable<
The first element whose value and index satisfiesT> , provided by the IterableExtension extensiontest
. -
firstWhereOrNull(
bool test(T element)) → T? -
Available on Iterable<
The first element satisfyingT> , provided by the IterableExtension extensiontest
, ornull
if there are none. -
foldIndexed<
R> (R initialValue, R combine(int index, R previous, T element)) → R -
Available on Iterable<
Combine the elements with a value and the current index.T> , provided by the IterableExtension extension -
forEachIndexed(
void action(int index, T element)) → void -
Available on Iterable<
Takes an action for each element.T> , provided by the IterableExtension extension -
forEachIndexedWhile(
bool action(int index, T element)) → void -
Available on Iterable<
Takes an action for each element and index as long as desired.T> , provided by the IterableExtension extension -
forEachWhile(
bool action(T element)) → void -
Available on Iterable<
Takes an action for each element as long as desired.T> , provided by the IterableExtension extension -
groupFoldBy<
K, G> (K keyOf(T element), G combine(G? previous, T element)) → Map< K, G> -
Available on Iterable<
Groups elements byT> , provided by the IterableExtension extensionkeyOf
then folds the elements in each group. -
groupListsBy<
K> (K keyOf(T element)) → Map< K, List< T> > -
Available on Iterable<
Groups elements into lists byT> , provided by the IterableExtension extensionkeyOf
. -
groupSetsBy<
K> (K keyOf(T element)) → Map< K, Set< T> > -
Available on Iterable<
Groups elements into sets byT> , provided by the IterableExtension extensionkeyOf
. -
isSorted(
Comparator< T> compare) → bool -
Available on Iterable<
Whether the elements are sorted by theT> , provided by the IterableExtension extensioncompare
ordering. -
isSortedBy<
K extends Comparable< (K> >K keyOf(T element)) → bool -
Available on Iterable<
Whether the elements are sorted by theirT> , provided by the IterableExtension extensionkeyOf
property. -
isSortedByCompare<
K> (K keyOf(T element), Comparator< K> compare) → bool -
Available on Iterable<
Whether the elements areT> , provided by the IterableExtension extensioncompare
-sorted by theirkeyOf
property. -
lastBy<
K> (K key(T)) → Map< K, T> -
Available on Iterable<
Associates the elements inT> , provided by the IterableExtension extensionthis
by the value returned bykey
. -
lastWhereIndexedOrNull(
bool test(int index, T element)) → T? -
Available on Iterable<
The last element whose index and value satisfiesT> , provided by the IterableExtension extensiontest
. -
lastWhereOrNull(
bool test(T element)) → T? -
Available on Iterable<
The last element satisfyingT> , provided by the IterableExtension extensiontest
, ornull
if there are none. -
mapIndexed<
R> (R convert(int index, T element)) → Iterable< R> -
Available on Iterable<
Maps each element and its index to a new value.T> , provided by the IterableExtension extension -
none(
bool test(T)) → bool -
Available on Iterable<
Whether no element satisfiesT> , provided by the IterableExtension extensiontest
. -
reduceIndexed(
T combine(int index, T previous, T element)) → T -
Available on Iterable<
Combine the elements with each other and the current index.T> , provided by the IterableExtension extension -
sample(
int count, [Random? random]) → List< T> -
Available on Iterable<
SelectsT> , provided by the IterableExtension extensioncount
elements at random from this iterable. -
shuffled(
[Random? random]) → List< T> -
Available on Iterable<
Creates a shuffled list of the elements of the iterable.T> , provided by the IterableExtension extension -
singleWhereIndexedOrNull(
bool test(int index, T element)) → T? -
Available on Iterable<
The single element satisfyingT> , provided by the IterableExtension extensiontest
. -
singleWhereOrNull(
bool test(T element)) → T? -
Available on Iterable<
The single element satisfyingT> , provided by the IterableExtension extensiontest
. -
slices(
int length) → Iterable< List< T> > -
Available on Iterable<
Contiguous slices ofT> , provided by the IterableExtension extensionthis
with the givenlength
. -
sorted(
Comparator< T> compare) → List<T> -
Available on Iterable<
Creates a sorted list of the elements of the iterable.T> , provided by the IterableExtension extension -
sortedBy<
K extends Comparable< (K> >K keyOf(T element)) → List< T> -
Available on Iterable<
Creates a sorted list of the elements of the iterable.T> , provided by the IterableExtension extension -
sortedByCompare<
K> (K keyOf(T element), Comparator< K> compare) → List<T> -
Available on Iterable<
Creates a sorted list of the elements of the iterable.T> , provided by the IterableExtension extension -
splitAfter(
bool test(T element)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks after some elements.T> , provided by the IterableExtension extension -
splitAfterIndexed(
bool test(int index, T element)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks after some elements and indices.T> , provided by the IterableExtension extension -
splitBefore(
bool test(T element)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks before some elements.T> , provided by the IterableExtension extension -
splitBeforeIndexed(
bool test(int index, T element)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks before some elements and indices.T> , provided by the IterableExtension extension -
splitBetween(
bool test(T first, T second)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks between some elements.T> , provided by the IterableExtension extension -
splitBetweenIndexed(
bool test(int index, T first, T second)) → Iterable< List< T> > -
Available on Iterable<
Splits the elements into chunks between some elements and indices.T> , provided by the IterableExtension extension -
whereIndexed(
bool test(int index, T element)) → Iterable< T> -
Available on Iterable<
The elements whose value and index satisfiesT> , provided by the IterableExtension extensiontest
. -
whereNot(
bool test(T element)) → Iterable< T> -
Available on Iterable<
The elements that do not satisfyT> , provided by the IterableExtension extensiontest
. -
whereNotIndexed(
bool test(int index, T element)) → Iterable< T> -
Available on Iterable<
The elements whose value and index do not satisfyT> , provided by the IterableExtension extensiontest
.