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 extensionvalueTransform
and indexed bykeySelector
functions 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 extensiondestination
mutable map with key-value pairs, where key is provided by thekeySelector
function 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 extensionkeySelector
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(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 extensionkeySelector
function applied to each element and puts to thedestination
map 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 extensiontransform
function to each element and its index in the original collection. @paramtransform
function 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 extensiontransform
function to each element and its index in the original collection and appends the results to the givendestination
. @paramtransform
function 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 extensiontransform
function 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 extensiontransform
function 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 extensionselector
function. -
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 extensionselector
function. -
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 extensionselector
function 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 extensionthis
collection and theother
collection with the same index using the providedtransform
function applied to each pair of elements. The returned list has length of the shortest collection.