Deprecate sequence implementations in favor of sequence operations.
This commit is contained in:
@@ -579,7 +579,7 @@ public fun <T : Any> Iterable<T?>.filterNotNull(): List<T> {
|
||||
* Returns a sequence containing all elements that are not null
|
||||
*/
|
||||
public fun <T : Any> Sequence<T?>.filterNotNull(): Sequence<T> {
|
||||
return FilteringSequence(this, false, { it == null }) as Sequence<T>
|
||||
return filterNot { it == null } as Sequence<T>
|
||||
}
|
||||
|
||||
|
||||
@@ -588,7 +588,7 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* Returns a stream containing all elements that are not null
|
||||
*/
|
||||
public fun <T : Any> Stream<T?>.filterNotNull(): Stream<T> {
|
||||
return FilteringStream(this, false, { it == null }) as Stream<T>
|
||||
return filterNot { it == null } as Stream<T>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -705,7 +705,7 @@ public fun <T> Iterable<T>.plus(collection: Iterable<T>): List<T> {
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [collection]
|
||||
*/
|
||||
public fun <T> Sequence<T>.plus(collection: Iterable<T>): Sequence<T> {
|
||||
return MultiSequence(sequenceOf(this, collection.sequence()))
|
||||
return sequenceOf(this, collection.sequence()).flatten()
|
||||
}
|
||||
|
||||
|
||||
@@ -714,7 +714,7 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* 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> {
|
||||
return Multistream(streamOf(this, collection.stream()))
|
||||
return streamOf(this, collection.stream()).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -811,7 +811,7 @@ public fun <T> Iterable<T>.plus(element: T): List<T> {
|
||||
* Returns a sequence containing all elements of original sequence and then the given element
|
||||
*/
|
||||
public fun <T> Sequence<T>.plus(element: T): Sequence<T> {
|
||||
return MultiSequence(sequenceOf(this, sequenceOf(element)))
|
||||
return sequenceOf(this, sequenceOf(element)).flatten()
|
||||
}
|
||||
|
||||
|
||||
@@ -820,14 +820,14 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* Returns a stream containing all elements of original stream and then the given element
|
||||
*/
|
||||
public fun <T> Stream<T>.plus(element: T): Stream<T> {
|
||||
return Multistream(streamOf(this, streamOf(element)))
|
||||
return streamOf(this, streamOf(element)).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]
|
||||
*/
|
||||
public fun <T> Sequence<T>.plus(sequence: Sequence<T>): Sequence<T> {
|
||||
return MultiSequence(sequenceOf(this, sequence))
|
||||
return sequenceOf(this, sequence).flatten()
|
||||
}
|
||||
|
||||
|
||||
@@ -836,7 +836,7 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* 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> {
|
||||
return Multistream(streamOf(this, stream))
|
||||
return streamOf(this, stream).flatten()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,12 +49,7 @@ public fun <T : Any> List<T?>.requireNoNulls(): List<T> {
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T : Any> Sequence<T?>.requireNoNulls(): Sequence<T> {
|
||||
return FilteringSequence(this) {
|
||||
if (it == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
true
|
||||
} as Sequence<T>
|
||||
return map { it ?: throw IllegalArgumentException("null element found in $this") }
|
||||
}
|
||||
|
||||
|
||||
@@ -63,11 +58,6 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements
|
||||
*/
|
||||
public fun <T : Any> Stream<T?>.requireNoNulls(): Stream<T> {
|
||||
return FilteringStream(this) {
|
||||
if (it == null) {
|
||||
throw IllegalArgumentException("null element found in $this")
|
||||
}
|
||||
true
|
||||
} as Stream<T>
|
||||
return map { it ?: throw IllegalArgumentException("null element found in $this") }
|
||||
}
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ public inline fun <reified R> Iterable<*>.filterIsInstance(): List<R> {
|
||||
* Returns a sequence containing all elements that are instances of specified type parameter R
|
||||
*/
|
||||
public inline fun <reified R> Sequence<*>.filterIsInstance(): Sequence<R> {
|
||||
return FilteringSequence(this, true, { it is R }) as Sequence<R>
|
||||
return filter { it is R } as Sequence<R>
|
||||
}
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* Returns a stream containing all elements that are instances of specified type parameter R
|
||||
*/
|
||||
public inline fun <reified R> Stream<*>.filterIsInstance(): Stream<R> {
|
||||
return FilteringStream(this, true, { it is R }) as Stream<R>
|
||||
return filter { it is R } as Stream<R>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -501,7 +501,7 @@ public fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R> {
|
||||
* Returns a sequence containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <R> Sequence<*>.filterIsInstance(klass: Class<R>): Sequence<R> {
|
||||
return FilteringSequence(this, true, { klass.isInstance(it) }) as Sequence<R>
|
||||
return filter { klass.isInstance(it) } as Sequence<R>
|
||||
}
|
||||
|
||||
|
||||
@@ -510,7 +510,7 @@ deprecated("Migrate to using Sequence<T> and respective functions")
|
||||
* Returns a stream containing all elements that are instances of specified class
|
||||
*/
|
||||
public fun <R> Stream<*>.filterIsInstance(klass: Class<R>): Stream<R> {
|
||||
return FilteringStream(this, true, { klass.isInstance(it) }) as Stream<R>
|
||||
return filter { klass.isInstance(it) } as Stream<R>
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user