ktx<T> extension
- on
-
- Iterable<
T>
- Iterable<
Methods
-
associateBy<
K> (K keySelector(T)) → Map< K, T> -
Available on Iterable<
Returns a Map containing the values provided byT> , provided by the ktx extensionvalueTransformand indexed bykeySelectorfunctions applied to elements of the given collection. -
associateByTo<
K> (Map< K, T> destination, K keySelector(T)) → Map<K, T> -
Available on Iterable<
Populates and returns theT> , provided by the ktx extensiondestinationmutable map with key-value pairs, where key is provided by thekeySelectorfunction applied to each element of the given collection and value is the element itself. -
groupBy<
K> (K keySelector(T)) → Map< K, List< T> > -
Available on Iterable<
Groups elements of the original collection by the key returned by the givenT> , provided by the ktx extensionkeySelectorfunction 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(T)) → Map<T> >K, List< T> > -
Available on Iterable<
Groups elements of the original collection by the key returned by the givenT> , provided by the ktx extensionkeySelectorfunction applied to each element and puts to thedestinationmap each group key associated with a list of corresponding elements. -
mapIndexed<
R> (R transform(int, T)) → List< R> -
Available on Iterable<
Returns a list containing the results of applying the givenT> , provided by the ktx extensiontransformfunction to each element and its index in the original collection. @paramtransformfunction that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapIndexedTo<
R> (List< R> destination, R transform(int, T)) → List<R> -
Available on Iterable<
Applies the givenT> , provided by the ktx extensiontransformfunction to each element and its index in the original collection and appends the results to the givendestination. @paramtransformfunction that takes the index of an element and the element itself and returns the result of the transform applied to the element. -
mapNotNull<
R> (R? transform(T)) → List< R> -
Available on Iterable<
Returns a list containing only the non-null results of applying the givenT> , provided by the ktx extensiontransformfunction to each element in the original collection. -
mapNotNullTo<
R> (List< R> destination, R? transform(T)) → List<R> -
Available on Iterable<
Applies the givenT> , provided by the ktx extensiontransformfunction to each element in the original collection and appends only the non-null results to the givendestination. -
sortBy<
R extends Comparable< (Object> >R selector(T)) → List< T> -
Available on Iterable<
Sorts elements in the list in-place according to natural sort order of the value returned by specifiedT> , provided by the ktx extensionselectorfunction. -
sortByDescending<
R extends Comparable< (Object> >R selector(T)) → List< T> -
Available on Iterable<
Sorts elements in the list in-place descending according to natural sort order of the value returned by specifiedT> , provided by the ktx extensionselectorfunction. -
sortTo(
List< T> destination, Comparator<T> comparator) → List<T> -
sumBy(
int selector(T)) → int -
Available on Iterable<
Returns the sum of all values produced byT> , provided by the ktx extensionselectorfunction applied to each element in the collection. -
zip<
R, V> (Iterable< R> other, V transform(T, R)) → List<V> -
Available on Iterable<
Returns a list of values built from the elements ofT> , provided by the ktx extensionthiscollection and theothercollection with the same index using the providedtransformfunction applied to each pair of elements. The returned list has length of the shortest collection.