diff --git a/js/js.libraries/src/core/generated/_SequencesJs.kt b/js/js.libraries/src/core/generated/_SequencesJs.kt index f09ab663dd9..a0c7e8fb5b1 100644 --- a/js/js.libraries/src/core/generated/_SequencesJs.kt +++ b/js/js.libraries/src/core/generated/_SequencesJs.kt @@ -329,7 +329,7 @@ public inline fun Sequence.singleOrNull(predicate: (T) -> Boolean): T? { /** * Returns a sequence containing all elements except first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.drop(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -363,7 +363,7 @@ public fun Sequence.filter(predicate: (T) -> Boolean): Sequence { * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence { // TODO: Rewrite with generalized MapFilterIndexingSequence @@ -375,7 +375,7 @@ public fun Sequence.filterIndexed(predicate: (index: Int, T) -> Boolean): * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C { forEachIndexed { index, element -> @@ -397,7 +397,7 @@ public inline fun Sequence<*>.filterIsInstance(): Sequence<@kotlin.i /** * Appends all elements that are instances of specified type parameter R to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence<*>.filterIsInstanceTo(destination: C): C { for (element in this) if (element is R) destination.add(element) @@ -426,7 +426,7 @@ public fun Sequence.filterNotNull(): Sequence { /** * Appends all elements that are not `null` to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public fun , T : Any> Sequence.filterNotNullTo(destination: C): C { for (element in this) if (element != null) destination.add(element) @@ -436,7 +436,7 @@ public fun , T : Any> Sequence.filterNotNullTo(d /** * Appends all elements not matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterNotTo(destination: C, predicate: (T) -> Boolean): C { for (element in this) if (!predicate(element)) destination.add(element) @@ -446,7 +446,7 @@ public inline fun > Sequence.filterNotTo(desti /** * Appends all elements matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterTo(destination: C, predicate: (T) -> Boolean): C { for (element in this) if (predicate(element)) destination.add(element) @@ -456,7 +456,7 @@ public inline fun > Sequence.filterTo(destinat /** * Returns a sequence containing first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.take(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -683,7 +683,7 @@ public fun Sequence.flatMap(transform: (T) -> Sequence): Sequence> Sequence.flatMapTo(destination: C, transform: (T) -> Sequence): C { for (element in this) { @@ -701,7 +701,7 @@ public inline fun > Sequence.flatMapTo(dest * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map> { return groupByTo(LinkedHashMap>(), keySelector) @@ -716,7 +716,7 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map Sequence.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map> { return groupByTo(LinkedHashMap>(), keySelector, valueTransform) @@ -730,7 +730,7 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K, valueTran * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K): M { for (element in this) { @@ -750,7 +750,7 @@ public inline fun >> Sequence.group * * @sample samples.collections.Collections.Transformations.groupByKeysAndValues * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M { for (element in this) { @@ -793,7 +793,7 @@ public fun Sequence.map(transform: (T) -> R): Sequence { * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.mapIndexed(transform: (index: Int, T) -> R): Sequence { return TransformingIndexedSequence(this, transform) @@ -805,7 +805,7 @@ public fun Sequence.mapIndexed(transform: (index: Int, T) -> R): Seque * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence { return TransformingIndexedSequence(this, transform).filterNotNull() @@ -817,7 +817,7 @@ public fun Sequence.mapIndexedNotNull(transform: (index: Int, T) * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -830,7 +830,7 @@ public inline fun > Sequence.mapIndex * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C { var index = 0 @@ -853,7 +853,7 @@ public fun Sequence.mapNotNull(transform: (T) -> R?): Sequence> Sequence.mapNotNullTo(destination: C, transform: (T) -> R?): C { forEach { element -> transform(element)?.let { destination.add(it) } } @@ -864,7 +864,7 @@ public inline fun > Sequence.mapNotNu * Applies the given [transform] function to each element of the original sequence * and appends the results to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapTo(destination: C, transform: (T) -> R): C { for (item in this) @@ -875,7 +875,7 @@ public inline fun > Sequence.mapTo(destinat /** * Returns a sequence of [IndexedValue] for each element of the original sequence. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.withIndex(): Sequence> { return IndexingSequence(this) @@ -1311,7 +1311,7 @@ public fun Sequence.requireNoNulls(): Sequence { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public operator fun Sequence.minus(element: T): Sequence { return object: Sequence { @@ -1383,7 +1383,7 @@ public operator fun Sequence.minus(elements: Sequence): Sequence { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ @kotlin.internal.InlineOnly public inline fun Sequence.minusElement(element: T): Sequence { diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index b5534366b03..68e5d07e5a7 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -173,7 +173,7 @@ public header inline fun Sequence.singleOrNull(predicate: (T) -> Boolean) /** * Returns a sequence containing all elements except first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.drop(n: Int): Sequence @@ -196,7 +196,7 @@ public header fun Sequence.filter(predicate: (T) -> Boolean): Sequence * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence @@ -205,7 +205,7 @@ public header fun Sequence.filterIndexed(predicate: (index: Int, T) -> Bo * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C @@ -219,7 +219,7 @@ public header inline fun Sequence<*>.filterIsInstance(): Sequence<@k /** * Appends all elements that are instances of specified type parameter R to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence<*>.filterIsInstanceTo(destination: C): C @@ -240,28 +240,28 @@ public header fun Sequence.filterNotNull(): Sequence /** * Appends all elements that are not `null` to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header fun , T : Any> Sequence.filterNotNullTo(destination: C): C /** * Appends all elements not matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.filterNotTo(destination: C, predicate: (T) -> Boolean): C /** * Appends all elements matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.filterTo(destination: C, predicate: (T) -> Boolean): C /** * Returns a sequence containing first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.take(n: Int): Sequence @@ -421,7 +421,7 @@ public header fun Sequence.flatMap(transform: (T) -> Sequence): Seq /** * Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.flatMapTo(destination: C, transform: (T) -> Sequence): C @@ -433,7 +433,7 @@ public header inline fun > Sequence.flatMap * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public header inline fun Sequence.groupBy(keySelector: (T) -> K): Map> @@ -446,7 +446,7 @@ public header inline fun Sequence.groupBy(keySelector: (T) -> K): Map< * * @sample samples.collections.Collections.Transformations.groupByKeysAndValues * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public header inline fun Sequence.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map> @@ -458,7 +458,7 @@ public header inline fun Sequence.groupBy(keySelector: (T) -> K, va * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public header inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K): M @@ -471,7 +471,7 @@ public header inline fun >> Sequence>> Sequence.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M @@ -500,7 +500,7 @@ public header fun Sequence.map(transform: (T) -> R): Sequence * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.mapIndexed(transform: (index: Int, T) -> R): Sequence @@ -510,7 +510,7 @@ public header fun Sequence.mapIndexed(transform: (index: Int, T) -> R) * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence @@ -520,7 +520,7 @@ public header fun Sequence.mapIndexedNotNull(transform: (index: * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C @@ -530,7 +530,7 @@ public header inline fun > Sequence.m * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C @@ -546,7 +546,7 @@ public header fun Sequence.mapNotNull(transform: (T) -> R?): Seq * Applies the given [transform] function to each element in the original sequence * and appends only the non-null results to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.mapNotNullTo(destination: C, transform: (T) -> R?): C @@ -554,14 +554,14 @@ public header inline fun > Sequence.m * Applies the given [transform] function to each element of the original sequence * and appends the results to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public header inline fun > Sequence.mapTo(destination: C, transform: (T) -> R): C /** * Returns a sequence of [IndexedValue] for each element of the original sequence. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header fun Sequence.withIndex(): Sequence> @@ -806,7 +806,7 @@ public header fun Sequence.requireNoNulls(): Sequence /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public header operator fun Sequence.minus(element: T): Sequence @@ -843,7 +843,7 @@ public header operator fun Sequence.minus(elements: Sequence): Sequenc /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ @kotlin.internal.InlineOnly public header inline fun Sequence.minusElement(element: T): Sequence diff --git a/libraries/stdlib/src/Module.md b/libraries/stdlib/src/Module.md index 9f213f27def..d659828a773 100644 --- a/libraries/stdlib/src/Module.md +++ b/libraries/stdlib/src/Module.md @@ -93,8 +93,8 @@ and extension functions for sequences. The sequence operations can be classified into the following groups regarding their state requirements: - - _stateless_ – operations like [kotlin.sequences.Sequence.map], [kotlin.sequences.Sequence.filter], which process each element independently; - - _nearly stateless_ – operations which require a small constant amount of state to process an element, for example [kotlin.sequences.Sequence.take] or [kotlin.sequences.Sequence.drop]; + - _stateless_ – operations which require no state and process each element independently like [kotlin.sequences.Sequence.map], [kotlin.sequences.Sequence.filter], + or require a small constant amount of state to process an element, for example [kotlin.sequences.Sequence.take] or [kotlin.sequences.Sequence.drop]; - _stateful_ – operations which require a significant amount of state, usually proportional to the number of elements in a sequence. If the sequence operation returns another sequence, which is produced lazily, it's called _intermediate_, and otherwise the operation is _terminal_. diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 70c9792a464..1e7fa7cb9da 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -329,7 +329,7 @@ public inline fun Sequence.singleOrNull(predicate: (T) -> Boolean): T? { /** * Returns a sequence containing all elements except first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.drop(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -363,7 +363,7 @@ public fun Sequence.filter(predicate: (T) -> Boolean): Sequence { * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.filterIndexed(predicate: (index: Int, T) -> Boolean): Sequence { // TODO: Rewrite with generalized MapFilterIndexingSequence @@ -375,7 +375,7 @@ public fun Sequence.filterIndexed(predicate: (index: Int, T) -> Boolean): * @param [predicate] function that takes the index of an element and the element itself * and returns the result of predicate evaluation on the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean): C { forEachIndexed { index, element -> @@ -397,7 +397,7 @@ public inline fun Sequence<*>.filterIsInstance(): Sequence<@kotlin.i /** * Appends all elements that are instances of specified type parameter R to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence<*>.filterIsInstanceTo(destination: C): C { for (element in this) if (element is R) destination.add(element) @@ -426,7 +426,7 @@ public fun Sequence.filterNotNull(): Sequence { /** * Appends all elements that are not `null` to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public fun , T : Any> Sequence.filterNotNullTo(destination: C): C { for (element in this) if (element != null) destination.add(element) @@ -436,7 +436,7 @@ public fun , T : Any> Sequence.filterNotNullTo(d /** * Appends all elements not matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterNotTo(destination: C, predicate: (T) -> Boolean): C { for (element in this) if (!predicate(element)) destination.add(element) @@ -446,7 +446,7 @@ public inline fun > Sequence.filterNotTo(desti /** * Appends all elements matching the given [predicate] to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.filterTo(destination: C, predicate: (T) -> Boolean): C { for (element in this) if (predicate(element)) destination.add(element) @@ -456,7 +456,7 @@ public inline fun > Sequence.filterTo(destinat /** * Returns a sequence containing first [n] elements. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.take(n: Int): Sequence { require(n >= 0) { "Requested element count $n is less than zero." } @@ -705,7 +705,7 @@ public fun Sequence.flatMap(transform: (T) -> Sequence): Sequence> Sequence.flatMapTo(destination: C, transform: (T) -> Sequence): C { for (element in this) { @@ -723,7 +723,7 @@ public inline fun > Sequence.flatMapTo(dest * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map> { return groupByTo(LinkedHashMap>(), keySelector) @@ -738,7 +738,7 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K): Map Sequence.groupBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map> { return groupByTo(LinkedHashMap>(), keySelector, valueTransform) @@ -752,7 +752,7 @@ public inline fun Sequence.groupBy(keySelector: (T) -> K, valueTran * * @sample samples.collections.Collections.Transformations.groupBy * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K): M { for (element in this) { @@ -772,7 +772,7 @@ public inline fun >> Sequence.group * * @sample samples.collections.Collections.Transformations.groupByKeysAndValues * - * The operation is _terminal_ and _stateful_. + * The operation is _terminal_. */ public inline fun >> Sequence.groupByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M { for (element in this) { @@ -815,7 +815,7 @@ public fun Sequence.map(transform: (T) -> R): Sequence { * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.mapIndexed(transform: (index: Int, T) -> R): Sequence { return TransformingIndexedSequence(this, transform) @@ -827,7 +827,7 @@ public fun Sequence.mapIndexed(transform: (index: Int, T) -> R): Seque * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.mapIndexedNotNull(transform: (index: Int, T) -> R?): Sequence { return TransformingIndexedSequence(this, transform).filterNotNull() @@ -839,7 +839,7 @@ public fun Sequence.mapIndexedNotNull(transform: (index: Int, T) * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapIndexedNotNullTo(destination: C, transform: (index: Int, T) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -852,7 +852,7 @@ public inline fun > Sequence.mapIndex * @param [transform] function that takes the index of an element and the element itself * and returns the result of the transform applied to the element. * - * The operation is _terminal_ and _nearly stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapIndexedTo(destination: C, transform: (index: Int, T) -> R): C { var index = 0 @@ -875,7 +875,7 @@ public fun Sequence.mapNotNull(transform: (T) -> R?): Sequence> Sequence.mapNotNullTo(destination: C, transform: (T) -> R?): C { forEach { element -> transform(element)?.let { destination.add(it) } } @@ -886,7 +886,7 @@ public inline fun > Sequence.mapNotNu * Applies the given [transform] function to each element of the original sequence * and appends the results to the given [destination]. * - * The operation is _terminal_ and _stateless_. + * The operation is _terminal_. */ public inline fun > Sequence.mapTo(destination: C, transform: (T) -> R): C { for (item in this) @@ -897,7 +897,7 @@ public inline fun > Sequence.mapTo(destinat /** * Returns a sequence of [IndexedValue] for each element of the original sequence. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public fun Sequence.withIndex(): Sequence> { return IndexingSequence(this) @@ -1333,7 +1333,7 @@ public fun Sequence.requireNoNulls(): Sequence { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ public operator fun Sequence.minus(element: T): Sequence { return object: Sequence { @@ -1405,7 +1405,7 @@ public operator fun Sequence.minus(elements: Sequence): Sequence { /** * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]. * - * The operation is _intermediate_ and _nearly stateless_. + * The operation is _intermediate_ and _stateless_. */ @kotlin.internal.InlineOnly public inline fun Sequence.minusElement(element: T): Sequence { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index 42fa46fb8d2..ee945792814 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -37,7 +37,6 @@ fun filtering(): List { templates add f("drop(n: Int)") { val n = "\$n" doc { "Returns a list containing all elements except first [n] elements." } - sequenceClassification(nearly_stateless) returns("List") body { """ @@ -108,7 +107,6 @@ fun filtering(): List { templates add f("take(n: Int)") { val n = "\$n" doc { "Returns a list containing first [n] elements." } - sequenceClassification(nearly_stateless) returns("List") body { """ @@ -769,10 +767,10 @@ fun filtering(): List { val terminalOperationPattern = Regex("^\\w+To") templates.forEach { with (it) { - if (sequenceClassification.isEmpty()) { - sequenceClassification(if (signature.contains("index", ignoreCase = true)) nearly_stateless else stateless) - } - sequenceClassification.add(0, if (terminalOperationPattern in signature) terminal else intermediate) + if (terminalOperationPattern in signature) + sequenceClassification(terminal) + else + sequenceClassification(intermediate, stateless) } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index da82e28ffbd..fc788323751 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -269,7 +269,7 @@ fun generators(): List { """ } doc(Sequences) { "Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]." } - sequenceClassification(intermediate, nearly_stateless) + sequenceClassification(intermediate, stateless) returns("List") returns("SELF", Sets, Sequences) @@ -308,7 +308,7 @@ fun generators(): List { doc(Sequences) { "Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element]." } - sequenceClassification(intermediate, nearly_stateless) + sequenceClassification(intermediate, stateless) body(Sequences) { """ return object: Sequence { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index 1c6f37a9d3d..8c452db9c7b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -301,7 +301,7 @@ fun mapping(): List { @sample samples.collections.Collections.Transformations.groupBy """ } - sequenceClassification(terminal, stateful) + sequenceClassification(terminal) typeParam("K") returns("Map>") body { "return groupByTo(LinkedHashMap>(), keySelector)" } @@ -323,7 +323,7 @@ fun mapping(): List { @sample samples.collections.Collections.Transformations.groupBy """ } - sequenceClassification(terminal, stateful) + sequenceClassification(terminal) returns("M") body { """ @@ -352,7 +352,7 @@ fun mapping(): List { @sample samples.collections.Collections.Transformations.groupByKeysAndValues """ } - sequenceClassification(terminal, stateful) + sequenceClassification(terminal) typeParam("K") typeParam("V") returns("Map>") @@ -379,7 +379,7 @@ fun mapping(): List { @sample samples.collections.Collections.Transformations.groupByKeysAndValues """ } - sequenceClassification(terminal, stateful) + sequenceClassification(terminal) returns("M") body { """ @@ -425,8 +425,10 @@ fun mapping(): List { val terminalOperationPattern = Regex("^\\w+To") templates.forEach { with (it) { if (sequenceClassification.isEmpty()) { - sequenceClassification(if (terminalOperationPattern in signature) terminal else intermediate) - sequenceClassification(if (signature.contains("index", ignoreCase = true)) nearly_stateless else stateless) + if (terminalOperationPattern in signature) + sequenceClassification(terminal) + else + sequenceClassification(intermediate, stateless) } } } return templates diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt index abe375bfc49..401d624d794 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt @@ -1,8 +1,7 @@ package templates import templates.Family.* -import templates.SequenceClass.intermediate -import templates.SequenceClass.stateful +import templates.SequenceClass.* fun ordering(): List { val templates = arrayListOf() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt index 463e4d5ea9b..d2248b9ab53 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt @@ -80,7 +80,6 @@ enum class SequenceClass { terminal, intermediate, stateless, - nearly_stateless, stateful } @@ -457,7 +456,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") { } if (f == Sequences && sequenceClassification.isNotEmpty()) { builder.append(" *\n") - builder.append(" * The operation is ${sequenceClassification.joinToString(" and ") { "_${it.toString().replace('_', ' ')}_" }}.\n") + builder.append(" * The operation is ${sequenceClassification.joinToString(" and ") { "_${it}_" }}.\n") } builder.append(" */\n") }