Make stream plus operation actually streaming (lazy).
This commit is contained in:
committed by
Andrey Breslav
parent
c5b0351aa7
commit
108fdc0097
@@ -420,9 +420,7 @@ public fun <T> Iterable<T>.plus(collection: Iterable<T>) : List<T> {
|
||||
* Returns a stream containing all elements of original stream and then all elements of the given *collection*
|
||||
*/
|
||||
public fun <T> Stream<T>.plus(collection: Iterable<T>) : Stream<T> {
|
||||
val answer = toArrayList()
|
||||
answer.addAll(collection)
|
||||
return answer.stream()
|
||||
return Multistream(streamOf(this, collection.stream()))
|
||||
|
||||
}
|
||||
|
||||
@@ -530,9 +528,7 @@ public fun <T> Iterable<T>.plus(element: T) : List<T> {
|
||||
* Returns a stream containing all elements of original stream and then the given element
|
||||
*/
|
||||
public fun <T> Stream<T>.plus(element: T) : Stream<T> {
|
||||
val answer = toArrayList()
|
||||
answer.add(element)
|
||||
return answer.stream()
|
||||
return Multistream(streamOf(this, streamOf(element)))
|
||||
|
||||
}
|
||||
|
||||
@@ -540,9 +536,7 @@ public fun <T> Stream<T>.plus(element: T) : Stream<T> {
|
||||
* Returns a stream containing all elements of original stream and then all elements of the given *stream*
|
||||
*/
|
||||
public fun <T> Stream<T>.plus(stream: Stream<T>) : Stream<T> {
|
||||
val answer = toArrayList()
|
||||
answer.addAll(stream)
|
||||
return answer.stream()
|
||||
return Multistream(streamOf(this, stream))
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package kotlin
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Array<out T>.stream() : Stream<T> {
|
||||
return object : Stream<T> { override fun iterator() : Iterator<T> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun BooleanArray.stream() : Stream<Boolean> {
|
||||
return object : Stream<Boolean> { override fun iterator() : Iterator<Boolean> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun ByteArray.stream() : Stream<Byte> {
|
||||
return object : Stream<Byte> { override fun iterator() : Iterator<Byte> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun CharArray.stream() : Stream<Char> {
|
||||
return object : Stream<Char> { override fun iterator() : Iterator<Char> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun DoubleArray.stream() : Stream<Double> {
|
||||
return object : Stream<Double> { override fun iterator() : Iterator<Double> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun FloatArray.stream() : Stream<Float> {
|
||||
return object : Stream<Float> { override fun iterator() : Iterator<Float> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun IntArray.stream() : Stream<Int> {
|
||||
return object : Stream<Int> { override fun iterator() : Iterator<Int> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun LongArray.stream() : Stream<Long> {
|
||||
return object : Stream<Long> { override fun iterator() : Iterator<Long> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun ShortArray.stream() : Stream<Short> {
|
||||
return object : Stream<Short> { override fun iterator() : Iterator<Short> { return this@stream.iterator() } }
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Iterable<T>.stream() : Stream<T> {
|
||||
return object : Stream<T> { override fun iterator() : Iterator<T> { return this@stream.iterator() } }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream from the given collection
|
||||
*/
|
||||
public fun <T> Stream<T>.stream() : Stream<T> {
|
||||
return this
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user