Compiler&plugin deprecations cleanup: replace streams with sequences.

This commit is contained in:
Ilya Gorbunov
2015-06-25 21:09:30 +03:00
parent 5779b89ff0
commit 86f4a1b6e4
18 changed files with 34 additions and 34 deletions
@@ -27,7 +27,7 @@ public fun <T> T.singletonList(): List<T> = Collections.singletonList(this)
public fun <T: Any> T?.singletonOrEmptySet(): Set<T> = if (this != null) Collections.singleton(this) else Collections.emptySet()
public inline fun <reified T : Any> Stream<*>.firstIsInstanceOrNull(): T? {
public inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
@@ -42,7 +42,7 @@ public inline fun <reified T : Any> Array<*>.firstIsInstanceOrNull(): T? {
return null
}
public inline fun <reified T> Stream<*>.firstIsInstance(): T {
public inline fun <reified T> Sequence<*>.firstIsInstance(): T {
for (element in this) if (element is T) return element
throw NoSuchElementException("No element of given type found")
}
@@ -73,7 +73,7 @@ public inline fun <reified T : Any> Iterable<*>.lastIsInstanceOrNull(): T? {
}
}
public fun <T> streamOfLazyValues(vararg elements: () -> T): Stream<T> = elements.stream().map { it() }
public fun <T> sequenceOfLazyValues(vararg elements: () -> T): Sequence<T> = elements.asSequence().map { it() }
public fun <T1, T2> Pair<T1, T2>.swap(): Pair<T2, T1> = Pair(second, first)
@@ -23,7 +23,7 @@ import java.util.HashSet
import java.util.Collections
import java.util.LinkedHashSet
public fun <K, V> Stream<V>.valuesToMap(key: (V) -> K): Map<K, V> {
public fun <K, V> Sequence<V>.valuesToMap(key: (V) -> K): Map<K, V> {
val map = LinkedHashMap<K, V>()
for (v in this) {
map[key(v)] = v
@@ -31,7 +31,7 @@ public fun <K, V> Stream<V>.valuesToMap(key: (V) -> K): Map<K, V> {
return map
}
public fun <K, V> Stream<K>.keysToMap(value: (K) -> V): Map<K, V> {
public fun <K, V> Sequence<K>.keysToMap(value: (K) -> V): Map<K, V> {
val map = LinkedHashMap<K, V>()
for (k in this) {
map[k] = value(k)
@@ -39,7 +39,7 @@ public fun <K, V> Stream<K>.keysToMap(value: (K) -> V): Map<K, V> {
return map
}
public fun <K, V: Any> Stream<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K, V> {
public fun <K, V: Any> Sequence<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K, V> {
val map = LinkedHashMap<K, V>()
for (k in this) {
val v = value(k)