Move groupingByEachCount together with the new Grouping samples
This commit is contained in:
@@ -369,17 +369,7 @@ class Collections {
|
||||
assertTrue(mutableNamesByTeam == namesByTeam)
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun groupingByEachCount() {
|
||||
val words = "one two three four five six seven eight nine ten".split(' ')
|
||||
val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount()
|
||||
println("Counting first letters:")
|
||||
assertPrints(frequenciesByFirstChar, "{o=1, t=3, f=2, s=2, e=1, n=1}")
|
||||
|
||||
val moreWords = "eleven twelve".split(' ')
|
||||
val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap())
|
||||
assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}")
|
||||
}
|
||||
|
||||
@Sample
|
||||
fun joinTo() {
|
||||
|
||||
@@ -10,6 +10,20 @@ import java.util.stream.Collector
|
||||
import kotlin.test.*
|
||||
|
||||
class Grouping {
|
||||
|
||||
@Sample
|
||||
fun groupingByEachCount() {
|
||||
val words = "one two three four five six seven eight nine ten".split(' ')
|
||||
val frequenciesByFirstChar = words.groupingBy { it.first() }.eachCount()
|
||||
println("Counting first letters:")
|
||||
assertPrints(frequenciesByFirstChar, "{o=1, t=3, f=2, s=2, e=1, n=1}")
|
||||
|
||||
val moreWords = "eleven twelve".split(' ')
|
||||
val moreFrequencies = moreWords.groupingBy { it.first() }.eachCountTo(frequenciesByFirstChar.toMutableMap())
|
||||
assertPrints(moreFrequencies, "{o=1, t=4, f=2, s=2, e=2, n=1}")
|
||||
}
|
||||
|
||||
|
||||
@Sample
|
||||
fun aggregateEvenAndOdd() {
|
||||
val intList = listOf(0, 1, 2, 3, 4, 5, 6)
|
||||
|
||||
Reference in New Issue
Block a user