StdLib cleanup: drop deprecated iterators and streams.

This commit is contained in:
Ilya Gorbunov
2015-06-26 00:09:38 +03:00
parent 6d4e48ab9a
commit 4660b07687
23 changed files with 7 additions and 2320 deletions
@@ -230,28 +230,6 @@ public fun <T, A : Appendable> Sequence<T>.joinTo(buffer: A, separator: String =
return buffer
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
* elements will be appended, followed by the [truncated] string (which defaults to "...").
*/
public fun <T, A : Appendable> Stream<T>.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): A {
buffer.append(prefix)
var count = 0
for (element in this) {
if (++count > 1) buffer.append(separator)
if (limit < 0 || count <= limit) {
val text = if (transform != null) transform(element) else if (element == null) "null" else element.toString()
buffer.append(text)
} else break
}
if (limit >= 0 && count > limit) buffer.append(truncated)
buffer.append(postfix)
return buffer
}
/**
* Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
@@ -351,14 +329,3 @@ public fun <T> Sequence<T>.joinToString(separator: String = ", ", prefix: String
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
* elements will be appended, followed by the [truncated] string (which defaults to "...").
*/
public fun <T> Stream<T>.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String {
return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString()
}