Iterables<E> extension

Provides functions for transforming Iterables to other collections.

Functions that rely on the ordering of elements are non-deterministic if an iterable is unordered, i.e. HashSet.

on

Methods

associate<R>({required Select<E, R> by}) Map<R, E>
Returns a map that associates values returned by by with elements in this iterable.
distinct({required Select<E, Object?> by}) Iterable<E>
Returns a lazy iterable with only distinct elements.
indexed() Iterable<(int, E)>
Returns a lazy iterable with records that contain an iteration index and element.
toMap<K, V>((K, V) create(E element)) Map<K, V>
Returns a modifiable map using create to produce entries from elements in this iterable.
toUnmodifiableList() List<E>
Transforms this iterable into an unmodifiable List.
toUnmodifiableMap<K, V>((K, V) create(E element)) Map<K, V>
Returns an unmodifiable map using create to produce entries from elements in this iterable.
toUnmodifiableSet() Set<E>
Transforms this iterable into an unmodifiable Set.