Provide dropLast and takeLastWhile methods. Optimize special cases of drop/take/dropLast/takeLast (when n is equal to zero or size of collection).

This commit is contained in:
Ilya Gorbunov
2015-06-01 22:23:59 +03:00
parent 9f85fa9720
commit a1d8e9d633
5 changed files with 481 additions and 73 deletions
@@ -70,6 +70,9 @@ public fun <T> sequenceOf(progression: Progression<T>): Sequence<T> = object : S
*/
public fun <T> emptySequence(): Sequence<T> = EmptySequence
deprecated("Remove in M13 with streams.")
private fun <T> emptyStream(): Stream<T> = EmptySequence
private object EmptySequence : Sequence<Nothing> {
override fun iterator(): Iterator<Nothing> = EmptyIterator
}