Rename Stream<T> to Sequence<T> and provide migration path via deprecated types and functions.
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user