Add samples for groupingBy operations
This commit is contained in:
committed by
Ilya Gorbunov
parent
d89947bd5a
commit
039d41679e
@@ -44,6 +44,7 @@ public interface Grouping<T, out K> {
|
||||
* - `first`: indicates whether it's the first `element` encountered in the group.
|
||||
*
|
||||
* @return a [Map] associating the key of each group with the result of aggregation of the group elements.
|
||||
* @sample samples.collections.Grouping.aggregateEvenAndOdd
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R> Grouping<T, K>.aggregate(
|
||||
@@ -69,6 +70,7 @@ public inline fun <T, K, R> Grouping<T, K>.aggregate(
|
||||
* then the elements being aggregated for that key are never considered as `first`.
|
||||
*
|
||||
* @return the [destination] map associating the key of each group with the result of aggregation of the group elements.
|
||||
* @sample samples.collections.Grouping.aggregateEvenAndOddTo
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(
|
||||
@@ -99,6 +101,7 @@ public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.aggregateTo(
|
||||
* - `element`: the element from the source being accumulated.
|
||||
*
|
||||
* @return a [Map] associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.foldByEvenLengthWithComputedInitialValue
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R> Grouping<T, K>.fold(
|
||||
@@ -128,6 +131,7 @@ public inline fun <T, K, R> Grouping<T, K>.fold(
|
||||
* - `element`: the element from the source being accumulated.
|
||||
*
|
||||
* @return the [destination] map associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.foldByEvenLengthWithComputedInitialValueTo
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
|
||||
@@ -149,6 +153,7 @@ public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
|
||||
* - `element`: the element from the source being accumulated.
|
||||
*
|
||||
* @return a [Map] associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.foldByEvenLengthWithConstantInitialValue
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R> Grouping<T, K>.fold(
|
||||
@@ -172,6 +177,7 @@ public inline fun <T, K, R> Grouping<T, K>.fold(
|
||||
* - `element`: the element from the source being accumulated.
|
||||
*
|
||||
* @return the [destination] map associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.foldByEvenLengthWithConstantInitialValueTo
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
|
||||
@@ -196,6 +202,7 @@ public inline fun <T, K, R, M : MutableMap<in K, R>> Grouping<T, K>.foldTo(
|
||||
* - `element`: the element from the source being accumulated.
|
||||
*
|
||||
* @return a [Map] associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.reduceByMaxOfContainsVowels
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <S, T : S, K> Grouping<T, K>.reduce(
|
||||
@@ -222,6 +229,7 @@ public inline fun <S, T : S, K> Grouping<T, K>.reduce(
|
||||
* - `element`: the element from the source being folded;
|
||||
*
|
||||
* @return the [destination] map associating the key of each group with the result of accumulating the group elements.
|
||||
* @sample samples.collections.Grouping.reduceByMaxOfContainsVowelsTo
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <S, T : S, K, M : MutableMap<in K, S>> Grouping<T, K>.reduceTo(
|
||||
|
||||
Reference in New Issue
Block a user