diff --git a/libraries/stdlib/src/kotlin/collections/iterators/Iterators.kt b/libraries/stdlib/src/kotlin/collections/iterators/Iterators.kt index f5e48357b57..474d6c8e1e6 100644 --- a/libraries/stdlib/src/kotlin/collections/iterators/Iterators.kt +++ b/libraries/stdlib/src/kotlin/collections/iterators/Iterators.kt @@ -7,7 +7,7 @@ import kotlin.test.assertTrue /** * Returns an iterator which invokes the function to calculate the next value on each iteration until the function returns *null* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Use stream(...) function to make lazy stream of values.") public fun iterate(nextFunction: () -> T?) : Iterator { return FunctionIterator(nextFunction) } @@ -16,23 +16,23 @@ public fun iterate(nextFunction: () -> T?) : Iterator { * Returns an iterator which invokes the function to calculate the next value based on the previous one on each iteration * until the function returns *null* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Use stream(...) function to make lazy stream of values.") public /*inline*/ fun iterate(initialValue: T, nextFunction: (T) -> T?): Iterator = iterate(nextFunction.toGenerator(initialValue)) /** * Returns an iterator whose values are pairs composed of values produced by given pair of iterators */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.zip(iterator: Iterator): Iterator> = PairIterator(this, iterator) /** * Returns an iterator shifted to right by the given number of elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.skip(n: Int): Iterator = SkippingIterator(this, n) -deprecated("Use streams for lazy collection operations.") +deprecated("Use FilteringStream instead") class FilterIterator(val iterator : Iterator, val predicate: (T)-> Boolean) : AbstractIterator() { override protected fun computeNext(): Unit { while (iterator.hasNext()) { @@ -46,7 +46,7 @@ class FilterIterator(val iterator : Iterator, val predicate: (T)-> Boolean } } -deprecated("Use streams for lazy collection operations.") +deprecated("Use FilteringStream instead") class FilterNotNullIterator(val iterator : Iterator?) : AbstractIterator() { override protected fun computeNext(): Unit { if (iterator != null) { @@ -62,7 +62,7 @@ class FilterNotNullIterator(val iterator : Iterator?) : AbstractItera } } -deprecated("Use streams for lazy collection operations.") +deprecated("Use TransformingStream instead") class MapIterator(val iterator : Iterator, val transform: (T) -> R) : AbstractIterator() { override protected fun computeNext() : Unit { if (iterator.hasNext()) { @@ -73,7 +73,7 @@ class MapIterator(val iterator : Iterator, val transform: (T) -> R) : A } } -deprecated("Use streams for lazy collection operations.") +deprecated("Use FlatteningStream instead") class FlatMapIterator(val iterator : Iterator, val transform: (T) -> Iterator) : AbstractIterator() { var transformed: Iterator = iterate { null } @@ -93,7 +93,7 @@ class FlatMapIterator(val iterator : Iterator, val transform: (T) -> It } } -deprecated("Use streams for lazy collection operations.") +deprecated("Use LimitedStream instead") class TakeWhileIterator(val iterator: Iterator, val predicate: (T) -> Boolean) : AbstractIterator() { override protected fun computeNext() : Unit { if (iterator.hasNext()) { @@ -108,7 +108,7 @@ class TakeWhileIterator(val iterator: Iterator, val predicate: (T) -> Bool } /** An [[Iterator]] which invokes a function to calculate the next value in the iteration until the function returns *null* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Use FunctionStream instead") class FunctionIterator(val nextFunction: () -> T?): AbstractIterator() { override protected fun computeNext(): Unit { @@ -122,10 +122,10 @@ class FunctionIterator(val nextFunction: () -> T?): AbstractIterator() } /** An [[Iterator]] which iterates over a number of iterators in sequence */ -deprecated("Use streams for lazy collection operations.") +deprecated("Use Multistream instead") fun CompositeIterator(vararg iterators: Iterator): CompositeIterator = CompositeIterator(iterators.iterator()) -deprecated("Use streams for lazy collection operations.") +deprecated("Use Multistream instead") class CompositeIterator(val iterators: Iterator>): AbstractIterator() { var currentIter: Iterator? = null @@ -181,7 +181,7 @@ class IndexIterator(val iterator : Iterator): Iterator> { } } -deprecated("Use streams for lazy collection operations.") +deprecated("Use ZippingStream instead.") public class PairIterator( val iterator1 : Iterator, val iterator2 : Iterator ): AbstractIterator>() { diff --git a/libraries/stdlib/src/kotlin/collections/iterators/_Iterators.kt b/libraries/stdlib/src/kotlin/collections/iterators/_Iterators.kt index bda28d89fc5..05599493c93 100644 --- a/libraries/stdlib/src/kotlin/collections/iterators/_Iterators.kt +++ b/libraries/stdlib/src/kotlin/collections/iterators/_Iterators.kt @@ -10,7 +10,7 @@ import java.util.* /** * Returns *true* if all elements match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.all(predicate: (T) -> Boolean) : Boolean { for (element in this) if (!predicate(element)) return false return true @@ -19,7 +19,7 @@ public inline fun Iterator.all(predicate: (T) -> Boolean) : Boolean { /** * Returns *true* if any elements match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.any(predicate: (T) -> Boolean) : Boolean { for (element in this) if (predicate(element)) return true return false @@ -30,7 +30,7 @@ public inline fun Iterator.any(predicate: (T) -> Boolean) : Boolean { * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { buffer.append(prefix) var count = 0 @@ -48,7 +48,7 @@ public fun Iterator.appendString(buffer: Appendable, separator: String = /** * Returns the number of elements which match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.count(predicate: (T) -> Boolean) : Int { var count = 0 for (element in this) if (predicate(element)) count++ @@ -58,7 +58,7 @@ public inline fun Iterator.count(predicate: (T) -> Boolean) : Int { /** * Returns a list containing everything but the first *n* elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.drop(n: Int) : List { return dropWhile(countTo(n)) } @@ -66,7 +66,7 @@ public fun Iterator.drop(n: Int) : List { /** * Returns a list containing the everything but the first elements that satisfy the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.dropWhile(predicate: (T) -> Boolean) : List { return dropWhileTo(ArrayList(), predicate) } @@ -74,7 +74,7 @@ public inline fun Iterator.dropWhile(predicate: (T) -> Boolean) : List /** * Returns a list containing the everything but the first elements that satisfy the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { var start = true for (element in this) { @@ -91,7 +91,7 @@ public inline fun > Iterator.dropWhileTo(result: L, p /** * Returns an iterator over elements which match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.filter(predicate: (T) -> Boolean) : Iterator { return FilterIterator(this, predicate) } @@ -99,7 +99,7 @@ public fun Iterator.filter(predicate: (T) -> Boolean) : Iterator { /** * Returns an iterator over elements which don't match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.filterNot(predicate: (T) -> Boolean) : Iterator { return filter {!predicate(it)} } @@ -107,7 +107,7 @@ public inline fun Iterator.filterNot(predicate: (T) -> Boolean) : Iterato /** * Returns an iterator over non-*null* elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.filterNotNull() : Iterator { return FilterNotNullIterator(this) } @@ -115,7 +115,7 @@ public fun Iterator.filterNotNull() : Iterator { /** * Filters all non-*null* elements into the given list */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun > Iterator.filterNotNullTo(result: C) : C { for (element in this) if (element != null) result.add(element) return result @@ -124,7 +124,7 @@ public fun > Iterator.filterNotNullTo(resu /** * Returns a list containing all elements which do not match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.filterNotTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (!predicate(element)) result.add(element) return result @@ -133,7 +133,7 @@ public inline fun > Iterator.filterNotTo(result /** * Filters all elements which match the given predicate into the given list */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.filterTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) return result @@ -142,7 +142,7 @@ public inline fun > Iterator.filterTo(result: C /** * Returns the first element which matches the given *predicate* or *null* if none matched */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.find(predicate: (T) -> Boolean) : T? { for (element in this) if (predicate(element)) return element return null @@ -151,7 +151,7 @@ public inline fun Iterator.find(predicate: (T) -> Boolean) : T? { /** * Returns an iterator over the concatenated results of transforming each element to one or more values */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.flatMap(transform: (T) -> Iterator) : Iterator { return FlatMapIterator(this, transform) } @@ -159,7 +159,7 @@ public fun Iterator.flatMap(transform: (T) -> Iterator) : Iterator< /** * Returns the result of transforming each element to one or more values which are concatenated together into a single collection */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.flatMapTo(result: C, transform: (T) -> Iterable) : C { for (element in this) { val list = transform(element) @@ -171,7 +171,7 @@ public inline fun > Iterator.flatMapTo(resul /** * Folds all elements from from left to right with the *initial* value to perform the operation on sequential pairs of elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.fold(initial: R, operation: (R, T) -> R) : R { var answer = initial for (element in this) answer = operation(answer, element) @@ -181,7 +181,7 @@ public inline fun Iterator.fold(initial: R, operation: (R, T) -> R) : /** * Performs the given *operation* on each element */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.forEach(operation: (T) -> Unit) : Unit { for (element in this) operation(element) } @@ -189,12 +189,12 @@ public inline fun Iterator.forEach(operation: (T) -> Unit) : Unit { /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.groupBy(toKey: (T) -> K) : Map> { return groupByTo(HashMap>(), toKey) } -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.groupByTo(result: MutableMap>, toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) @@ -209,7 +209,7 @@ public inline fun Iterator.groupByTo(result: MutableMap with Stream by using stream() function instead of iterator()") public fun Iterator.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) @@ -221,7 +221,7 @@ public fun Iterator.makeString(separator: String = ", ", prefix: String = /** * Returns an iterator obtained by applying *transform*, a function transforming an object of type *T* into an object of type *R* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.map(transform : (T) -> R) : Iterator { return MapIterator(this, transform) } @@ -230,7 +230,7 @@ public fun Iterator.map(transform : (T) -> R) : Iterator { * Transforms each element of this collection with the given *transform* function and * adds each return value to the given *results* collection */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.mapTo(result: C, transform : (T) -> R) : C { for (item in this) result.add(transform(item)) @@ -240,7 +240,7 @@ public inline fun > Iterator.mapTo(result: C /** * Returns the largest element or null if there are no elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun > Iterator.max() : T? { if (!hasNext()) return null @@ -255,7 +255,7 @@ public fun > Iterator.max() : T? { /** * Returns the first element yielding the largest value of the given function or null if there are no elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun , T: Any> Iterator.maxBy(f: (T) -> R) : T? { if (!hasNext()) return null @@ -275,7 +275,7 @@ public inline fun , T: Any> Iterator.maxBy(f: (T) -> R) : T? /** * Returns the smallest element or null if there are no elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun > Iterator.min() : T? { if (!hasNext()) return null @@ -290,7 +290,7 @@ public fun > Iterator.min() : T? { /** * Returns the first element yielding the smallest value of the given function or null if there are no elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun , T: Any> Iterator.minBy(f: (T) -> R) : T? { if (!hasNext()) return null @@ -310,7 +310,7 @@ public inline fun , T: Any> Iterator.minBy(f: (T) -> R) : T? /** * Partitions this collection into a pair of collections */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.partition(predicate: (T) -> Boolean) : Pair, List> { val first = ArrayList() val second = ArrayList() @@ -327,7 +327,7 @@ public inline fun Iterator.partition(predicate: (T) -> Boolean) : Pair
  • with Stream by using stream() function instead of iterator()") public fun Iterator.plus(collection: Iterable) : Iterator { return plus(collection.iterator()) } @@ -335,7 +335,7 @@ public fun Iterator.plus(collection: Iterable) : Iterator { /** * Creates an [[Iterator]] which iterates over this iterator then the given element at the end */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.plus(element: T) : Iterator { return CompositeIterator(this, SingleIterator(element)) } @@ -343,7 +343,7 @@ public fun Iterator.plus(element: T) : Iterator { /** * Creates an [[Iterator]] which iterates over this iterator then the following iterator */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.plus(iterator: Iterator) : Iterator { return CompositeIterator(this, iterator) } @@ -352,7 +352,7 @@ public fun Iterator.plus(iterator: Iterator) : Iterator { * Applies binary operation to all elements of iterable, going from left to right. * Similar to fold function, but uses the first element as initial value */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun Iterator.reduce(operation: (T, T) -> T) : T { val iterator = this.iterator() if (!iterator.hasNext()) { @@ -370,7 +370,7 @@ public inline fun Iterator.reduce(operation: (T, T) -> T) : T { /** * Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.requireNoNulls() : Iterator { return map{ if (it == null) throw IllegalArgumentException("null element in iterator $this") else it @@ -380,7 +380,7 @@ public fun Iterator.requireNoNulls() : Iterator { /** * Reverses the order the elements into a list */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.reverse() : List { val list = toCollection(ArrayList()) Collections.reverse(list) @@ -391,7 +391,7 @@ public fun Iterator.reverse() : List { * Copies all elements into a [[List]] and sorts it by value of compare_function(element) * E.g. arrayList("two" to 2, "one" to 1).sortBy({it.second}) returns list sorted by second element of pair */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.sortBy(f: (T) -> R) : List { val sortedList = toCollection(ArrayList()) val sortBy: Comparator = comparator {(x: T, y: T) -> @@ -406,7 +406,7 @@ public inline fun > Iterator.sortBy(f: (T) -> R) : List with Stream by using stream() function instead of iterator()") public fun Iterator.take(n: Int) : Iterator { var count = n return takeWhile{ --count >= 0 } @@ -415,7 +415,7 @@ public fun Iterator.take(n: Int) : Iterator { /** * Returns an iterator restricted to the first elements that match the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.takeWhile(predicate: (T) -> Boolean) : Iterator { return TakeWhileIterator(this, predicate) } @@ -423,7 +423,7 @@ public fun Iterator.takeWhile(predicate: (T) -> Boolean) : Iterator { /** * Returns a list containing the first elements that satisfy the given *predicate* */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public inline fun > Iterator.takeWhileTo(result: C, predicate: (T) -> Boolean) : C { for (element in this) if (predicate(element)) result.add(element) else break return result @@ -432,7 +432,7 @@ public inline fun > Iterator.takeWhileTo(result /** * Copies all elements into the given collection */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun > Iterator.toCollection(result: C) : C { for (element in this) result.add(element) return result @@ -441,7 +441,7 @@ public fun > Iterator.toCollection(result: C) : /** * Copies all elements into a [[LinkedList]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toLinkedList() : LinkedList { return toCollection(LinkedList()) } @@ -449,7 +449,7 @@ public fun Iterator.toLinkedList() : LinkedList { /** * Copies all elements into a [[List]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toList() : List { return toCollection(ArrayList()) } @@ -457,7 +457,7 @@ public fun Iterator.toList() : List { /** * Copies all elements into a [[ArrayList]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toArrayList() : ArrayList { return toCollection(ArrayList()) } @@ -465,7 +465,7 @@ public fun Iterator.toArrayList() : ArrayList { /** * Copies all elements into a [[Set]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toSet() : Set { return toCollection(LinkedHashSet()) } @@ -473,7 +473,7 @@ public fun Iterator.toSet() : Set { /** * Copies all elements into a [[HashSet]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toHashSet() : HashSet { return toCollection(HashSet()) } @@ -481,7 +481,7 @@ public fun Iterator.toHashSet() : HashSet { /** * Copies all elements into a [[SortedSet]] */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.toSortedSet() : SortedSet { return toCollection(TreeSet()) } @@ -489,7 +489,7 @@ public fun Iterator.toSortedSet() : SortedSet { /** * Returns an iterator of Pairs(index, data) */ -deprecated("Use streams for lazy collection operations.") +deprecated("Replace Iterator with Stream by using stream() function instead of iterator()") public fun Iterator.withIndices() : Iterator> { return IndexIterator(iterator()) }