Rename Stream<T> to Sequence<T> and provide migration path via deprecated types and functions.

This commit is contained in:
Ilya Ryzhenkov
2015-03-10 18:10:57 +03:00
parent 9684d217b3
commit e448f40756
47 changed files with 1906 additions and 556 deletions
@@ -21,6 +21,20 @@ public fun Iterable<Int>.sum(): Int {
return sum
}
/**
* Returns the sum of all elements in the collection
*/
public fun Sequence<Int>.sum(): Int {
val iterator = iterator()
var sum: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Returns the sum of all elements in the collection
*/
@@ -45,6 +59,20 @@ public fun Iterable<Long>.sum(): Long {
return sum
}
/**
* Returns the sum of all elements in the collection
*/
public fun Sequence<Long>.sum(): Long {
val iterator = iterator()
var sum: Long = 0
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Returns the sum of all elements in the collection
*/
@@ -69,6 +97,20 @@ public fun Iterable<Double>.sum(): Double {
return sum
}
/**
* Returns the sum of all elements in the collection
*/
public fun Sequence<Double>.sum(): Double {
val iterator = iterator()
var sum: Double = 0.0
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Returns the sum of all elements in the collection
*/
@@ -93,6 +135,20 @@ public fun Iterable<Float>.sum(): Float {
return sum
}
/**
* Returns the sum of all elements in the collection
*/
public fun Sequence<Float>.sum(): Float {
val iterator = iterator()
var sum: Float = 0.0f
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
deprecated("Migrate to using Sequence<T> and respective functions")
/**
* Returns the sum of all elements in the collection
*/