From 7d29468e376556606de469fae7a72e8fa9a71b5f Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 3 Jul 2012 20:42:59 +0400 Subject: [PATCH] Revert: Kolya's commit to JLangIterables.kt --- libraries/stdlib/src/kotlin/JLangIterables.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/stdlib/src/kotlin/JLangIterables.kt b/libraries/stdlib/src/kotlin/JLangIterables.kt index 2ae3c944b19..d6f75cc8247 100644 --- a/libraries/stdlib/src/kotlin/JLangIterables.kt +++ b/libraries/stdlib/src/kotlin/JLangIterables.kt @@ -174,21 +174,27 @@ public inline fun java.lang.Iterable.reduceRight(operation: (T, T) -> T): */ public inline fun java.lang.Iterable.groupBy(toKey: (T) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun java.lang.Iterable.groupByTo(result: Map>, toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun java.lang.Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder()