public inline fun < T , K , V > Sequence < T > . associateBy ( keySelector : ( T ) -> K , valueTransform : ( T ) -> V ) : Map < K , V >

{ <EOL> return associateByTo ( LinkedHashMap < K , V > ( ) , keySelector , valueTransform ) <EOL> }

/**
 * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given sequence.
 *
 * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
 *
 * The returned map preserves the entry iteration order of the original sequence.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateByWithValueTransform
 */


public inline fun < T , K , M : MutableMap < in K , in T > > Sequence < T > . associateByTo ( destination : M , keySelector : ( T ) -> K ) : M

{ <EOL> for ( element in this ) { <EOL> destination . put ( keySelector ( element ) , element ) <EOL> } <EOL> return destination <EOL> }

/**
 * Populates and returns the [destination] mutable map with key-value pairs,
 * where key is provided by the [keySelector] function applied to each element of the given sequence
 * and value is the element itself.
 *
 * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateByTo
 */


public inline fun < T , K , V , M : MutableMap < in K , in V > > Sequence < T > . associateByTo ( destination : M , keySelector : ( T ) -> K , valueTransform : ( T ) -> V ) : M

{ <EOL> for ( element in this ) { <EOL> destination . put ( keySelector ( element ) , valueTransform ( element ) ) <EOL> } <EOL> return destination <EOL> }

/**
 * Populates and returns the [destination] mutable map with key-value pairs,
 * where key is provided by the [keySelector] function and
 * and value is provided by the [valueTransform] function applied to elements of the given sequence.
 *
 * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform
 */


public inline fun < T , K , V , M : MutableMap < in K , in V > > Sequence < T > . associateTo ( destination : M , transform : ( T ) -> Pair < K , V > ) : M

{ <EOL> for ( element in this ) { <EOL> destination += transform ( element ) <EOL> } <EOL> return destination <EOL> }

/**
 * Populates and returns the [destination] mutable map with key-value pairs
 * provided by [transform] function applied to each element of the given sequence.
 *
 * If any of two pairs would have the same key the last one gets added to the map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateTo
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public inline fun < K , V > Sequence < K > . associateWith ( valueSelector : ( K ) -> V ) : Map < K , V >

{ <EOL> val result = LinkedHashMap < K , V > ( ) <EOL> return associateWithTo ( result , valueSelector ) <EOL> }

/**
 * Returns a [Map] where keys are elements from the given sequence and values are
 * produced by the [valueSelector] function applied to each element.
 *
 * If any two elements are equal, the last one gets added to the map.
 *
 * The returned map preserves the entry iteration order of the original sequence.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateWith
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public inline fun < K , V , M : MutableMap < in K , in V > > Sequence < K > . associateWithTo ( destination : M , valueSelector : ( K ) -> V ) : M

{ <EOL> for ( element in this ) { <EOL> destination . put ( element , valueSelector ( element ) ) <EOL> } <EOL> return destination <EOL> }

/**
 * Populates and returns the [destination] mutable map with key-value pairs for each element of the given sequence,
 * where key is the element itself and value is provided by the [valueSelector] function applied to that key.
 *
 * If any two elements are equal, the last one overwrites the former value in the map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.associateWithTo
 */


public fun < T , C : MutableCollection < in T > > Sequence < T > . toCollection ( destination : C ) : C

{ <EOL> for ( item in this ) { <EOL> destination . add ( item ) <EOL> } <EOL> return destination <EOL> }

/**
 * Appends all elements to the given [destination] collection.
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . toHashSet ( ) : HashSet < T >

{ <EOL> return toCollection ( HashSet < T > ( ) ) <EOL> }

/**
 * Returns a new [HashSet] of all elements.
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . toList ( ) : List < T >

{ <EOL> val it = iterator ( ) <EOL> if ( ! it . hasNext ( ) ) <EOL> return emptyList ( ) <EOL> val element = it . next ( ) <EOL> if ( ! it . hasNext ( ) ) <EOL> return listOf ( element ) <EOL> val dst = ArrayList < T > ( ) <EOL> dst . add ( element ) <EOL> while ( it . hasNext ( ) ) dst . add ( it . next ( ) ) <EOL> return dst <EOL> }

/**
 * Returns a [List] containing all elements.
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . toMutableList ( ) : MutableList < T >

{ <EOL> return toCollection ( ArrayList < T > ( ) ) <EOL> }

/**
 * Returns a new [MutableList] filled with all elements of this sequence.
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . toSet ( ) : Set < T >

{ <EOL> val it = iterator ( ) <EOL> if ( ! it . hasNext ( ) ) <EOL> return emptySet ( ) <EOL> val element = it . next ( ) <EOL> if ( ! it . hasNext ( ) ) <EOL> return setOf ( element ) <EOL> val dst = LinkedHashSet < T > ( ) <EOL> dst . add ( element ) <EOL> while ( it . hasNext ( ) ) dst . add ( it . next ( ) ) <EOL> return dst <EOL> }

/**
 * Returns a [Set] of all elements.
 *
 * The returned set preserves the element iteration order of the original sequence.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun < T , R > Sequence < T > . flatMap ( transform : ( T ) -> Iterable < R > ) : Sequence < R >

{ <EOL> return FlatteningSequence ( this , transform , Iterable < R > :: iterator ) <EOL> }

/**
 * Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.flatMap
 */


public fun < T , R > Sequence < T > . flatMap ( transform : ( T ) -> Sequence < R > ) : Sequence < R >

{ <EOL> return FlatteningSequence ( this , transform , Sequence < R > :: iterator ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun < T , R > Sequence < T > . flatMapIndexed ( transform : ( index : Int , T ) -> Iterable < R > ) : Sequence < R >

{ <EOL> return flatMapIndexed ( this , transform , Iterable < R > :: iterator ) <EOL> }

/**
 * Returns a single sequence of all elements yielded from results of [transform] function being invoked on each element
 * and its index in the original sequence.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.flatMapIndexed
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun < T , R > Sequence < T > . flatMapIndexed ( transform : ( index : Int , T ) -> Sequence < R > ) : Sequence < R >

{ <EOL> return flatMapIndexed ( this , transform , Sequence < R > :: iterator ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . flatMapIndexedTo ( destination : C , transform : ( index : Int , T ) -> Iterable < R > ) : C

{ <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) { <EOL> val list = transform ( checkIndexOverflow ( index ++ ) , element ) <EOL> destination . addAll ( list ) <EOL> } <EOL> return destination <EOL> }

/**
 * Appends all elements yielded from results of [transform] function being invoked on each element
 * and its index in the original sequence, to the given [destination].
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . flatMapIndexedTo ( destination : C , transform : ( index : Int , T ) -> Sequence < R > ) : C


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . flatMapTo ( destination : C , transform : ( T ) -> Iterable < R > ) : C

{ <EOL> for ( element in this ) { <EOL> val list = transform ( element ) <EOL> destination . addAll ( list ) <EOL> } <EOL> return destination <EOL> }

/**
 * 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_.
 */


public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . flatMapTo ( destination : C , transform : ( T ) -> Sequence < R > ) : C


public inline fun < T , K > Sequence < T > . groupBy ( keySelector : ( T ) -> K ) : Map < K , List < T > >

{ <EOL> return groupByTo ( LinkedHashMap < K , MutableList < T > > ( ) , keySelector ) <EOL> }

/**
 * Groups elements of the original sequence by the key returned by the given [keySelector] function
 * applied to each element and returns a map where each group key is associated with a list of corresponding elements.
 *
 * The returned map preserves the entry iteration order of the keys produced from the original sequence.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.groupBy
 */


public inline fun < T , K , V > Sequence < T > . groupBy ( keySelector : ( T ) -> K , valueTransform : ( T ) -> V ) : Map < K , List < V > >

{ <EOL> return groupByTo ( LinkedHashMap < K , MutableList < V > > ( ) , keySelector , valueTransform ) <EOL> }

/**
 * Groups values returned by the [valueTransform] function applied to each element of the original sequence
 * by the key returned by the given [keySelector] function applied to the element
 * and returns a map where each group key is associated with a list of corresponding values.
 *
 * The returned map preserves the entry iteration order of the keys produced from the original sequence.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.groupByKeysAndValues
 */


public inline fun < T , K , M : MutableMap < in K , MutableList < T > > > Sequence < T > . groupByTo ( destination : M , keySelector : ( T ) -> K ) : M

{ <EOL> for ( element in this ) { <EOL> val key = keySelector ( element ) <EOL> val list = destination . getOrPut ( key ) { ArrayList < T > ( ) } <EOL> list . add ( element ) <EOL> } <EOL> return destination <EOL> }

/**
 * Groups elements of the original sequence by the key returned by the given [keySelector] function
 * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.
 *
 * @return The [destination] map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.groupBy
 */


public inline fun < T , K , V , M : MutableMap < in K , MutableList < V > > > Sequence < T > . groupByTo ( destination : M , keySelector : ( T ) -> K , valueTransform : ( T ) -> V ) : M

{ <EOL> for ( element in this ) { <EOL> val key = keySelector ( element ) <EOL> val list = destination . getOrPut ( key ) { ArrayList < V > ( ) } <EOL> list . add ( valueTransform ( element ) ) <EOL> } <EOL> return destination <EOL> }

/**
 * Groups values returned by the [valueTransform] function applied to each element of the original sequence
 * by the key returned by the given [keySelector] function applied to the element
 * and puts to the [destination] map each group key associated with a list of corresponding values.
 *
 * @return The [destination] map.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.groupByKeysAndValues
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K > Sequence < T > . groupingBy ( crossinline keySelector : ( T ) -> K ) : Grouping < T , K >

{ <EOL> return object : Grouping < T , K > { <EOL> override fun sourceIterator ( ) : Iterator < T > = this@groupingBy . iterator ( ) <EOL> override fun keyOf ( element : T ) : K = keySelector ( element ) <EOL> } <EOL> }

/**
 * Creates a [Grouping] source from a sequence to be used later with one of group-and-fold operations
 * using the specified [keySelector] function to extract a key from each element.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Grouping.groupingByEachCount
 */


public fun < T , R > Sequence < T > . map ( transform : ( T ) -> R ) : Sequence < R >

{ <EOL> return TransformingSequence ( this , transform ) <EOL> }

/**
 * Returns a sequence containing the results of applying the given [transform] function
 * to each element in the original sequence.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.map
 */


public fun < T , R > Sequence < T > . mapIndexed ( transform : ( index : Int , T ) -> R ) : Sequence < R >

{ <EOL> return TransformingIndexedSequence ( this , transform ) <EOL> }

/**
 * Returns a sequence containing the results of applying the given [transform] function
 * to each element and its index in the original 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 _stateless_.
 */


public fun < T , R : Any > Sequence < T > . mapIndexedNotNull ( transform : ( index : Int , T ) -> R ? ) : Sequence < R >

{ <EOL> return TransformingIndexedSequence ( this , transform ) . filterNotNull ( ) <EOL> }

/**
 * Returns a sequence containing only the non-null results of applying the given [transform] function
 * to each element and its index in the original 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 _stateless_.
 */


public inline fun < T , R : Any , C : MutableCollection < in R > > Sequence < T > . mapIndexedNotNullTo ( destination : C , transform : ( index : Int , T ) -> R ? ) : C

{ <EOL> forEachIndexed { index , element -> transform ( index , element ) ? . let { destination . add ( it ) } } <EOL> return destination <EOL> }

/**
 * Applies the given [transform] function to each element and its index in the original sequence
 * and appends only the non-null results to the given [destination].
 * @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_.
 */


public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . mapIndexedTo ( destination : C , transform : ( index : Int , T ) -> R ) : C

{ <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) <EOL> destination . add ( transform ( checkIndexOverflow ( index ++ ) , item ) ) <EOL> return destination <EOL> }

/**
 * Applies the given [transform] function to each element and its index in the original sequence
 * and appends the results to the given [destination].
 * @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_.
 */


public fun < T , R : Any > Sequence < T > . mapNotNull ( transform : ( T ) -> R ? ) : Sequence < R >

{ <EOL> return TransformingSequence ( this , transform ) . filterNotNull ( ) <EOL> }

/**
 * Returns a sequence containing only the non-null results of applying the given [transform] function
 * to each element in the original sequence.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.mapNotNull
 */


public inline fun < T , R : Any , C : MutableCollection < in R > > Sequence < T > . mapNotNullTo ( destination : C , transform : ( T ) -> R ? ) : C

{ <EOL> forEach { element -> transform ( element ) ? . let { destination . add ( it ) } } <EOL> return destination <EOL> }

/**
 * 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_.
 */


public inline fun < T , R , C : MutableCollection < in R > > Sequence < T > . mapTo ( destination : C , transform : ( T ) -> R ) : C

{ <EOL> for ( item in this ) <EOL> destination . add ( transform ( item ) ) <EOL> return destination <EOL> }

/**
 * Applies the given [transform] function to each element of the original sequence
 * and appends the results to the given [destination].
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . withIndex ( ) : Sequence < IndexedValue < T > >

{ <EOL> return IndexingSequence ( this ) <EOL> }

/**
 * Returns a sequence that wraps each element of the original sequence
 * into an [IndexedValue] containing the index of that element and the element itself.
 *
 * The operation is _intermediate_ and _stateless_.
 */


public fun < T > Sequence < T > . distinct ( ) : Sequence < T >

{ <EOL> return this . distinctBy { it } <EOL> }

/**
 * Returns a sequence containing only distinct elements from the given sequence.
 *
 * Among equal elements of the given sequence, only the first one will be present in the resulting sequence.
 * The elements in the resulting sequence are in the same order as they were in the source sequence.
 *
 * The operation is _intermediate_ and _stateful_.
 *
 * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy
 */


public fun < T , K > Sequence < T > . distinctBy ( selector : ( T ) -> K ) : Sequence < T >

{ <EOL> return DistinctSequence ( this , selector ) <EOL> }

/**
 * Returns a sequence containing only elements from the given sequence
 * having distinct keys returned by the given [selector] function.
 *
 * Among elements of the given sequence with equal keys, only the first one will be present in the resulting sequence.
 * The elements in the resulting sequence are in the same order as they were in the source sequence.
 *
 * The operation is _intermediate_ and _stateful_.
 *
 * @sample samples.collections.Collections.Transformations.distinctAndDistinctBy
 */


public fun < T > Sequence < T > . toMutableSet ( ) : MutableSet < T >

{ <EOL> val set = LinkedHashSet < T > ( ) <EOL> for ( item in this ) set . add ( item ) <EOL> return set <EOL> }

/**
 * Returns a new [MutableSet] containing all distinct elements from the given sequence.
 *
 * The returned set preserves the element iteration order of the original sequence.
 *
 * The operation is _terminal_.
 */


public inline fun < T > Sequence < T > . all ( predicate : ( T ) -> Boolean ) : Boolean

{ <EOL> for ( element in this ) if ( ! predicate ( element ) ) return false <EOL> return true <EOL> }

/**
 * Returns `true` if all elements match the given [predicate].
 *
 * Note that if the sequence contains no elements, the function returns `true`
 * because there are no elements in it that _do not_ match the predicate.
 * See a more detailed explanation of this logic concept in ["Vacuous truth"](https://en.wikipedia.org/wiki/Vacuous_truth) article.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.all
 */


public fun < T > Sequence < T > . any ( ) : Boolean

{ <EOL> return iterator ( ) . hasNext ( ) <EOL> }

/**
 * Returns `true` if sequence has at least one element.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.any
 */


public inline fun < T > Sequence < T > . any ( predicate : ( T ) -> Boolean ) : Boolean

{ <EOL> for ( element in this ) if ( predicate ( element ) ) return true <EOL> return false <EOL> }

/**
 * Returns `true` if at least one element matches the given [predicate].
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.anyWithPredicate
 */


public fun < T > Sequence < T > . count ( ) : Int

{ <EOL> var count = <NUM_LIT:0> <EOL> for ( element in this ) checkCountOverflow ( ++ count ) <EOL> return count <EOL> }

/**
 * Returns the number of elements in this sequence.
 *
 * The operation is _terminal_.
 */


public inline fun < T > Sequence < T > . count ( predicate : ( T ) -> Boolean ) : Int

{ <EOL> var count = <NUM_LIT:0> <EOL> for ( element in this ) if ( predicate ( element ) ) checkCountOverflow ( ++ count ) <EOL> return count <EOL> }

/**
 * Returns the number of elements matching the given [predicate].
 *
 * The operation is _terminal_.
 */


public inline fun < T , R > Sequence < T > . fold ( initial : R , operation : ( acc : R , T ) -> R ) : R

{ <EOL> var accumulator = initial <EOL> for ( element in this ) accumulator = operation ( accumulator , element ) <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with [initial] value and applying [operation] from left to right
 * to current accumulator value and each element.
 *
 * Returns the specified [initial] value if the sequence is empty.
 *
 * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 */


public inline fun < T , R > Sequence < T > . foldIndexed ( initial : R , operation : ( index : Int , acc : R , T ) -> R ) : R

{ <EOL> var index = <NUM_LIT:0> <EOL> var accumulator = initial <EOL> for ( element in this ) accumulator = operation ( checkIndexOverflow ( index ++ ) , accumulator , element ) <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with [initial] value and applying [operation] from left to right
 * to current accumulator value and each element with its index in the original sequence.
 *
 * Returns the specified [initial] value if the sequence is empty.
 *
 * @param [operation] function that takes the index of an element, current accumulator value
 * and the element itself, and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 */


public inline fun < T > Sequence < T > . forEach ( action : ( T ) -> Unit ) : Unit

{ <EOL> for ( element in this ) action ( element ) <EOL> }

/**
 * Performs the given [action] on each element.
 *
 * The operation is _terminal_.
 */


public inline fun < T > Sequence < T > . forEachIndexed ( action : ( index : Int , T ) -> Unit ) : Unit

{ <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) action ( checkIndexOverflow ( index ++ ) , item ) <EOL> }

/**
 * Performs the given [action] on each element, providing sequential index with the element.
 * @param [action] function that takes the index of an element and the element itself
 * and performs the action on the element.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun Sequence < Double > . max ( ) : Double

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> max = maxOf ( max , e ) <EOL> } <EOL> return max <EOL> }

/**
 * Returns the largest element.
 *
 * If any of elements is `NaN` returns `NaN`.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun Sequence < Float > . max ( ) : Float


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun < T : Comparable < T > > Sequence < T > . max ( ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( max < e ) max = e <EOL> } <EOL> return max <EOL> }

/**
 * Returns the largest element.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . maxBy ( selector : ( T ) -> R ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var maxElem = iterator . next ( ) <EOL> if ( ! iterator . hasNext ( ) ) return maxElem <EOL> var maxValue = selector ( maxElem ) <EOL> do { <EOL> val e = iterator . next ( ) <EOL> val v = selector ( e ) <EOL> if ( maxValue < v ) { <EOL> maxElem = e <EOL> maxValue = v <EOL> } <EOL> } while ( iterator . hasNext ( ) ) <EOL> return maxElem <EOL> }

/**
 * Returns the first element yielding the largest value of the given function.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 *
 * @sample samples.collections.Collections.Aggregates.maxBy
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . maxByOrNull ( selector : ( T ) -> R ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var maxElem = iterator . next ( ) <EOL> if ( ! iterator . hasNext ( ) ) return maxElem <EOL> var maxValue = selector ( maxElem ) <EOL> do { <EOL> val e = iterator . next ( ) <EOL> val v = selector ( e ) <EOL> if ( maxValue < v ) { <EOL> maxElem = e <EOL> maxValue = v <EOL> } <EOL> } while ( iterator . hasNext ( ) ) <EOL> return maxElem <EOL> }

/**
 * Returns the first element yielding the largest value of the given function or `null` if there are no elements.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.maxByOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . maxOf ( selector : ( T ) -> Double ) : Double

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> maxValue = maxOf ( maxValue , v ) <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each element in the sequence.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . maxOf ( selector : ( T ) -> Float ) : Float


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . maxOf ( selector : ( T ) -> R ) : R

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( maxValue < v ) { <EOL> maxValue = v <EOL> } <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each element in the sequence.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . maxOfOrNull ( selector : ( T ) -> Double ) : Double ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> maxValue = maxOf ( maxValue , v ) <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each element in the sequence or `null` if there are no elements.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . maxOfOrNull ( selector : ( T ) -> Float ) : Float ?


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . maxOfOrNull ( selector : ( T ) -> R ) : R ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( maxValue < v ) { <EOL> maxValue = v <EOL> } <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each element in the sequence or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R > Sequence < T > . maxOfWith ( comparator : Comparator < in R > , selector : ( T ) -> R ) : R

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( comparator . compare ( maxValue , v ) < <NUM_LIT:0> ) { <EOL> maxValue = v <EOL> } <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each element in the sequence.
 *
 * @throws NoSuchElementException if the sequence is empty.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R > Sequence < T > . maxOfWithOrNull ( comparator : Comparator < in R > , selector : ( T ) -> R ) : R ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var maxValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( comparator . compare ( maxValue , v ) < <NUM_LIT:0> ) { <EOL> maxValue = v <EOL> } <EOL> } <EOL> return maxValue <EOL> }

/**
 * Returns the largest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Sequence < Double > . maxOrNull ( ) : Double ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> max = maxOf ( max , e ) <EOL> } <EOL> return max <EOL> }

/**
 * Returns the largest element or `null` if there are no elements.
 *
 * If any of elements is `NaN` returns `NaN`.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Sequence < Float > . maxOrNull ( ) : Float ?


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T : Comparable < T > > Sequence < T > . maxOrNull ( ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( max < e ) max = e <EOL> } <EOL> return max <EOL> }

/**
 * Returns the largest element or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun < T > Sequence < T > . maxWith ( comparator : Comparator < in T > ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( comparator . compare ( max , e ) < <NUM_LIT:0> ) max = e <EOL> } <EOL> return max <EOL> }

/**
 * Returns the first element having the largest value according to the provided [comparator].
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T > Sequence < T > . maxWithOrNull ( comparator : Comparator < in T > ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var max = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( comparator . compare ( max , e ) < <NUM_LIT:0> ) max = e <EOL> } <EOL> return max <EOL> }

/**
 * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun Sequence < Double > . min ( ) : Double

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> min = minOf ( min , e ) <EOL> } <EOL> return min <EOL> }

/**
 * Returns the smallest element.
 *
 * If any of elements is `NaN` returns `NaN`.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun Sequence < Float > . min ( ) : Float


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun < T : Comparable < T > > Sequence < T > . min ( ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( min > e ) min = e <EOL> } <EOL> return min <EOL> }

/**
 * Returns the smallest element.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . minBy ( selector : ( T ) -> R ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var minElem = iterator . next ( ) <EOL> if ( ! iterator . hasNext ( ) ) return minElem <EOL> var minValue = selector ( minElem ) <EOL> do { <EOL> val e = iterator . next ( ) <EOL> val v = selector ( e ) <EOL> if ( minValue > v ) { <EOL> minElem = e <EOL> minValue = v <EOL> } <EOL> } while ( iterator . hasNext ( ) ) <EOL> return minElem <EOL> }

/**
 * Returns the first element yielding the smallest value of the given function.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 *
 * @sample samples.collections.Collections.Aggregates.minBy
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . minByOrNull ( selector : ( T ) -> R ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var minElem = iterator . next ( ) <EOL> if ( ! iterator . hasNext ( ) ) return minElem <EOL> var minValue = selector ( minElem ) <EOL> do { <EOL> val e = iterator . next ( ) <EOL> val v = selector ( e ) <EOL> if ( minValue > v ) { <EOL> minElem = e <EOL> minValue = v <EOL> } <EOL> } while ( iterator . hasNext ( ) ) <EOL> return minElem <EOL> }

/**
 * Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.minByOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . minOf ( selector : ( T ) -> Double ) : Double

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> minValue = minOf ( minValue , v ) <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each element in the sequence.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . minOf ( selector : ( T ) -> Float ) : Float


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . minOf ( selector : ( T ) -> R ) : R

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( minValue > v ) { <EOL> minValue = v <EOL> } <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each element in the sequence.
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . minOfOrNull ( selector : ( T ) -> Double ) : Double ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> minValue = minOf ( minValue , v ) <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each element in the sequence or `null` if there are no elements.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . minOfOrNull ( selector : ( T ) -> Float ) : Float ?


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Comparable < R > > Sequence < T > . minOfOrNull ( selector : ( T ) -> R ) : R ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( minValue > v ) { <EOL> minValue = v <EOL> } <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each element in the sequence or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R > Sequence < T > . minOfWith ( comparator : Comparator < in R > , selector : ( T ) -> R ) : R

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( comparator . compare ( minValue , v ) > <NUM_LIT:0> ) { <EOL> minValue = v <EOL> } <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each element in the sequence.
 *
 * @throws NoSuchElementException if the sequence is empty.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R > Sequence < T > . minOfWithOrNull ( comparator : Comparator < in R > , selector : ( T ) -> R ) : R ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var minValue = selector ( iterator . next ( ) ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val v = selector ( iterator . next ( ) ) <EOL> if ( comparator . compare ( minValue , v ) > <NUM_LIT:0> ) { <EOL> minValue = v <EOL> } <EOL> } <EOL> return minValue <EOL> }

/**
 * Returns the smallest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each element in the sequence or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Sequence < Double > . minOrNull ( ) : Double ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> min = minOf ( min , e ) <EOL> } <EOL> return min <EOL> }

/**
 * Returns the smallest element or `null` if there are no elements.
 *
 * If any of elements is `NaN` returns `NaN`.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun Sequence < Float > . minOrNull ( ) : Float ?


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T : Comparable < T > > Sequence < T > . minOrNull ( ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( min > e ) min = e <EOL> } <EOL> return min <EOL> }

/**
 * Returns the smallest element or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public fun < T > Sequence < T > . minWith ( comparator : Comparator < in T > ) : T

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw NoSuchElementException ( ) <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( comparator . compare ( min , e ) > <NUM_LIT:0> ) min = e <EOL> } <EOL> return min <EOL> }

/**
 * Returns the first element having the smallest value according to the provided [comparator].
 *
 * The operation is _terminal_.
 *
 * @throws NoSuchElementException if the sequence is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T > Sequence < T > . minWithOrNull ( comparator : Comparator < in T > ) : T ?

{ <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var min = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val e = iterator . next ( ) <EOL> if ( comparator . compare ( min , e ) > <NUM_LIT:0> ) min = e <EOL> } <EOL> return min <EOL> }

/**
 * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.
 *
 * The operation is _terminal_.
 */


public fun < T > Sequence < T > . none ( ) : Boolean

{ <EOL> return ! iterator ( ) . hasNext ( ) <EOL> }

/**
 * Returns `true` if the sequence has no elements.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.none
 */


public inline fun < T > Sequence < T > . none ( predicate : ( T ) -> Boolean ) : Boolean

{ <EOL> for ( element in this ) if ( predicate ( element ) ) return false <EOL> return true <EOL> }

/**
 * Returns `true` if no elements match the given [predicate].
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.noneWithPredicate
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public fun < T > Sequence < T > . onEach ( action : ( T ) -> Unit ) : Sequence < T >

{ <EOL> return map { <EOL> action ( it ) <EOL> it <EOL> } <EOL> }

/**
 * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.
 *
 * The operation is _intermediate_ and _stateless_.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T > Sequence < T > . onEachIndexed ( action : ( index : Int , T ) -> Unit ) : Sequence < T >

{ <EOL> return mapIndexed { index , element -> <EOL> action ( index , element ) <EOL> element <EOL> } <EOL> }

/**
 * Returns a sequence which performs the given [action] on each element of the original sequence as they pass through it.
 * @param [action] function that takes the index of an element and the element itself
 * and performs the action on the element.
 *
 * The operation is _intermediate_ and _stateless_.
 */


public inline fun < S , T : S > Sequence < T > . reduce ( operation : ( acc : S , T ) -> S ) : S

{ <EOL> val iterator = this . iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw UnsupportedOperationException ( "<STR_LIT>" ) <EOL> var accumulator : S = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( accumulator , iterator . next ( ) ) <EOL> } <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with the first element and applying [operation] from left to right
 * to current accumulator value and each element.
 *
 * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,
 * please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
 *
 * @param [operation] function that takes current accumulator value and an element,
 * and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.reduce
 */


public inline fun < S , T : S > Sequence < T > . reduceIndexed ( operation : ( index : Int , acc : S , T ) -> S ) : S

{ <EOL> val iterator = this . iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) throw UnsupportedOperationException ( "<STR_LIT>" ) <EOL> var index = <NUM_LIT:1> <EOL> var accumulator : S = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( checkIndexOverflow ( index ++ ) , accumulator , iterator . next ( ) ) <EOL> } <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with the first element and applying [operation] from left to right
 * to current accumulator value and each element with its index in the original sequence.
 *
 * Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,
 * please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
 *
 * @param [operation] function that takes the index of an element, current accumulator value and the element itself,
 * and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.reduce
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public inline fun < S , T : S > Sequence < T > . reduceIndexedOrNull ( operation : ( index : Int , acc : S , T ) -> S ) : S ?

{ <EOL> val iterator = this . iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var index = <NUM_LIT:1> <EOL> var accumulator : S = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( checkIndexOverflow ( index ++ ) , accumulator , iterator . next ( ) ) <EOL> } <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with the first element and applying [operation] from left to right
 * to current accumulator value and each element with its index in the original sequence.
 *
 * Returns `null` if the sequence is empty.
 *
 * @param [operation] function that takes the index of an element, current accumulator value and the element itself,
 * and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.reduceOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public inline fun < S , T : S > Sequence < T > . reduceOrNull ( operation : ( acc : S , T ) -> S ) : S ?

{ <EOL> val iterator = this . iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return null <EOL> var accumulator : S = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( accumulator , iterator . next ( ) ) <EOL> } <EOL> return accumulator <EOL> }

/**
 * Accumulates value starting with the first element and applying [operation] from left to right
 * to current accumulator value and each element.
 *
 * Returns `null` if the sequence is empty.
 *
 * @param [operation] function that takes current accumulator value and an element,
 * and calculates the next accumulator value.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Aggregates.reduceOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T , R > Sequence < T > . runningFold ( initial : R , operation : ( acc : R , T ) -> R ) : Sequence < R >

{ <EOL> return sequence { <EOL> yield ( initial ) <EOL> var accumulator = initial <EOL> for ( element in this @ runningFold ) { <EOL> accumulator = operation ( accumulator , element ) <EOL> yield ( accumulator ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element and current accumulator value that starts with [initial] value.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 * The [initial] value should also be immutable (or should not be mutated)
 * as it may be passed to [operation] function later because of sequence's lazy nature.
 *
 * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.runningFold
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T , R > Sequence < T > . runningFoldIndexed ( initial : R , operation : ( index : Int , acc : R , T ) -> R ) : Sequence < R >

{ <EOL> return sequence { <EOL> yield ( initial ) <EOL> var index = <NUM_LIT:0> <EOL> var accumulator = initial <EOL> for ( element in this @ runningFoldIndexed ) { <EOL> accumulator = operation ( checkIndexOverflow ( index ++ ) , accumulator , element ) <EOL> yield ( accumulator ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 * The [initial] value should also be immutable (or should not be mutated)
 * as it may be passed to [operation] function later because of sequence's lazy nature.
 *
 * @param [operation] function that takes the index of an element, current accumulator value
 * and the element itself, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.runningFold
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < S , T : S > Sequence < T > . runningReduce ( operation : ( acc : S , T ) -> S ) : Sequence < S >

{ <EOL> return sequence { <EOL> val iterator = iterator ( ) <EOL> if ( iterator . hasNext ( ) ) { <EOL> var accumulator : S = iterator . next ( ) <EOL> yield ( accumulator ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( accumulator , iterator . next ( ) ) <EOL> yield ( accumulator ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element and current accumulator value that starts with the first element of this sequence.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 *
 * @param [operation] function that takes current accumulator value and the element, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.runningReduce
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < S , T : S > Sequence < T > . runningReduceIndexed ( operation : ( index : Int , acc : S , T ) -> S ) : Sequence < S >

{ <EOL> return sequence { <EOL> val iterator = iterator ( ) <EOL> if ( iterator . hasNext ( ) ) { <EOL> var accumulator : S = iterator . next ( ) <EOL> yield ( accumulator ) <EOL> var index = <NUM_LIT:1> <EOL> while ( iterator . hasNext ( ) ) { <EOL> accumulator = operation ( checkIndexOverflow ( index ++ ) , accumulator , iterator . next ( ) ) <EOL> yield ( accumulator ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element, its index in the original sequence and current accumulator value that starts with the first element of this sequence.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 *
 * @param [operation] function that takes the index of an element, current accumulator value
 * and the element itself, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.runningReduce
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T , R > Sequence < T > . scan ( initial : R , operation : ( acc : R , T ) -> R ) : Sequence < R >

{ <EOL> return runningFold ( initial , operation ) <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element and current accumulator value that starts with [initial] value.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 * The [initial] value should also be immutable (or should not be mutated)
 * as it may be passed to [operation] function later because of sequence's lazy nature.
 *
 * @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.scan
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T , R > Sequence < T > . scanIndexed ( initial : R , operation : ( index : Int , acc : R , T ) -> R ) : Sequence < R >

{ <EOL> return runningFoldIndexed ( initial , operation ) <EOL> }

/**
 * Returns a sequence containing successive accumulation values generated by applying [operation] from left to right
 * to each element, its index in the original sequence and current accumulator value that starts with [initial] value.
 *
 * Note that `acc` value passed to [operation] function should not be mutated;
 * otherwise it would affect the previous value in resulting sequence.
 * The [initial] value should also be immutable (or should not be mutated)
 * as it may be passed to [operation] function later because of sequence's lazy nature.
 *
 * @param [operation] function that takes the index of an element, current accumulator value
 * and the element itself, and calculates the next accumulator value.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Aggregates.scan
 */


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> @ DeprecatedSinceKotlin ( warningSince = "<STR_LIT:1.5>" ) <EOL> public inline fun < T > Sequence < T > . sumBy ( selector : ( T ) -> Int ) : Int

{ <EOL> var sum : Int = <NUM_LIT:0> <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }

/**
 * Returns the sum of all values produced by [selector] function applied to each element in the sequence.
 *
 * The operation is _terminal_.
 */


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> @ DeprecatedSinceKotlin ( warningSince = "<STR_LIT:1.5>" ) <EOL> public inline fun < T > Sequence < T > . sumByDouble ( selector : ( T ) -> Double ) : Double

{ <EOL> var sum : Double = <NUM_LIT:0.0> <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . sumOf ( selector : ( T ) -> Double ) : Double

{ <EOL> var sum : Double = <NUM_LIT:0> . toDouble ( ) <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . sumOf ( selector : ( T ) -> Int ) : Int

{ <EOL> var sum : Int = <NUM_LIT:0> . toInt ( ) <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . sumOf ( selector : ( T ) -> Long ) : Long

{ <EOL> var sum : Long = <NUM_LIT:0> . toLong ( ) <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


@ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . sumOf ( selector : ( T ) -> UInt ) : UInt

{ <EOL> var sum : UInt = <NUM_LIT:0> . toUInt ( ) <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


@ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ WasExperimental ( ExperimentalUnsignedTypes :: class ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . sumOf ( selector : ( T ) -> ULong ) : ULong

{ <EOL> var sum : ULong = <NUM_LIT:0> . toULong ( ) <EOL> for ( element in this ) { <EOL> sum += selector ( element ) <EOL> } <EOL> return sum <EOL> }


public fun < T : Any > Sequence < T ? > . requireNoNulls ( ) : Sequence < T >

{ <EOL> return map { it ? : throw IllegalArgumentException ( "<STR_LIT>" ) } <EOL> }

/**
 * Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
 *
 * The operation is _intermediate_ and _stateless_.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T > Sequence < T > . chunked ( size : Int ) : Sequence < List < T > >

{ <EOL> return windowed ( size , size , partialWindows = true ) <EOL> }

/**
 * Splits this sequence into a sequence of lists each not exceeding the given [size].
 *
 * The last list in the resulting sequence may have fewer elements than the given [size].
 *
 * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.
 *
 * The operation is _intermediate_ and _stateful_.
 *
 * @sample samples.collections.Collections.Transformations.chunked
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T , R > Sequence < T > . chunked ( size : Int , transform : ( List < T > ) -> R ) : Sequence < R >

{ <EOL> return windowed ( size , size , partialWindows = true , transform = transform ) <EOL> }

/**
 * Splits this sequence into several lists each not exceeding the given [size]
 * and applies the given [transform] function to an each.
 *
 * @return sequence of results of the [transform] applied to an each list.
 *
 * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.
 * You should not store it or allow it to escape in some way, unless you made a snapshot of it.
 * The last list may have fewer elements than the given [size].
 *
 * @param size the number of elements to take in each list, must be positive and can be greater than the number of elements in this sequence.
 *
 * The operation is _intermediate_ and _stateful_.
 *
 * @sample samples.text.Strings.chunkedTransform
 */


public operator fun < T > Sequence < T > . minus ( element : T ) : Sequence < T >

{ <EOL> return object : Sequence < T > { <EOL> override fun iterator ( ) : Iterator < T > { <EOL> var removed = false <EOL> return this@minus . filter { if ( ! removed && it == element ) { removed = true ; false } else true } . iterator ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing all elements of the original sequence without the first occurrence of the given [element].
 *
 * The operation is _intermediate_ and _stateless_.
 */


public operator fun < T > Sequence < T > . minus ( elements : Array < out T > ) : Sequence < T >

{ <EOL> if ( elements . isEmpty ( ) ) return this <EOL> return object : Sequence < T > { <EOL> override fun iterator ( ) : Iterator < T > { <EOL> return this@minus . filterNot { it in elements } . iterator ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] array.
 *
 * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ and _stateful_.
 */


public operator fun < T > Sequence < T > . minus ( elements : Iterable < T > ) : Sequence < T >

{ <EOL> return object : Sequence < T > { <EOL> override fun iterator ( ) : Iterator < T > { <EOL> val other = elements . convertToListIfNotCollection ( ) <EOL> if ( other . isEmpty ( ) ) <EOL> return this@minus . iterator ( ) <EOL> else <EOL> return this@minus . filterNot { it in other } . iterator ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] collection.
 *
 * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ and _stateful_.
 */


public operator fun < T > Sequence < T > . minus ( elements : Sequence < T > ) : Sequence < T >

{ <EOL> return object : Sequence < T > { <EOL> override fun iterator ( ) : Iterator < T > { <EOL> val other = elements . toList ( ) <EOL> if ( other . isEmpty ( ) ) <EOL> return this@minus . iterator ( ) <EOL> else <EOL> return this@minus . filterNot { it in other } . iterator ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing all elements of original sequence except the elements contained in the given [elements] sequence.
 *
 * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ for this sequence and _terminal_ and _stateful_ for the [elements] sequence.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . minusElement ( element : T ) : Sequence < T >

{ <EOL> return minus ( element ) <EOL> }


public inline fun < T > Sequence < T > . partition ( predicate : ( T ) -> Boolean ) : Pair < List < T > , List < T > >

{ <EOL> val first = ArrayList < T > ( ) <EOL> val second = ArrayList < T > ( ) <EOL> for ( element in this ) { <EOL> if ( predicate ( element ) ) { <EOL> first . add ( element ) <EOL> } else { <EOL> second . add ( element ) <EOL> } <EOL> } <EOL> return Pair ( first , second ) <EOL> }

/**
 * Splits the original sequence into pair of lists,
 * where *first* list contains elements for which [predicate] yielded `true`,
 * while *second* list contains elements for which [predicate] yielded `false`.
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Sequences.Transformations.partition
 */


public operator fun < T > Sequence < T > . plus ( element : T ) : Sequence < T >

{ <EOL> return sequenceOf ( this , sequenceOf ( element ) ) . flatten ( ) <EOL> }

/**
 * Returns a sequence containing all elements of the original sequence and then the given [element].
 *
 * The operation is _intermediate_ and _stateless_.
 */


public operator fun < T > Sequence < T > . plus ( elements : Array < out T > ) : Sequence < T >

{ <EOL> return this . plus ( elements . asList ( ) ) <EOL> }

/**
 * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] array.
 *
 * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ and _stateless_.
 */


public operator fun < T > Sequence < T > . plus ( elements : Iterable < T > ) : Sequence < T >

{ <EOL> return sequenceOf ( this , elements . asSequence ( ) ) . flatten ( ) <EOL> }

/**
 * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] collection.
 *
 * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ and _stateless_.
 */


public operator fun < T > Sequence < T > . plus ( elements : Sequence < T > ) : Sequence < T >

{ <EOL> return sequenceOf ( this , elements ) . flatten ( ) <EOL> }

/**
 * Returns a sequence containing all elements of original sequence and then all elements of the given [elements] sequence.
 *
 * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from
 * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result.
 *
 * The operation is _intermediate_ and _stateless_.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . plusElement ( element : T ) : Sequence < T >

{ <EOL> return plus ( element ) <EOL> }


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T > Sequence < T > . windowed ( size : Int , step : Int = <NUM_LIT:1> , partialWindows : Boolean = false ) : Sequence < List < T > >

{ <EOL> return windowedSequence ( size , step , partialWindows , reuseBuffer = false ) <EOL> }

/**
 * Returns a sequence of snapshots of the window of the given [size]
 * sliding along this sequence with the given [step], where each
 * snapshot is a list.
 *
 * Several last lists may have fewer elements than the given [size].
 *
 * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
 * @param size the number of elements to take in each window
 * @param step the number of elements to move the window forward by on an each step, by default 1
 * @param partialWindows controls whether or not to keep partial windows in the end if any,
 * by default `false` which means partial windows won't be preserved
 *
 * @sample samples.collections.Sequences.Transformations.takeWindows
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T , R > Sequence < T > . windowed ( size : Int , step : Int = <NUM_LIT:1> , partialWindows : Boolean = false , transform : ( List < T > ) -> R ) : Sequence < R >

{ <EOL> return windowedSequence ( size , step , partialWindows , reuseBuffer = true ) . map ( transform ) <EOL> }

/**
 * Returns a sequence of results of applying the given [transform] function to
 * an each list representing a view over the window of the given [size]
 * sliding along this sequence with the given [step].
 *
 * Note that the list passed to the [transform] function is ephemeral and is valid only inside that function.
 * You should not store it or allow it to escape in some way, unless you made a snapshot of it.
 * Several last lists may have fewer elements than the given [size].
 *
 * Both [size] and [step] must be positive and can be greater than the number of elements in this sequence.
 * @param size the number of elements to take in each window
 * @param step the number of elements to move the window forward by on an each step, by default 1
 * @param partialWindows controls whether or not to keep partial windows in the end if any,
 * by default `false` which means partial windows won't be preserved
 *
 * @sample samples.collections.Sequences.Transformations.averageWindows
 */


public infix fun < T , R > Sequence < T > . zip ( other : Sequence < R > ) : Sequence < Pair < T , R > >

{ <EOL> return MergingSequence ( this , other ) { t1 , t2 -> t1 to t2 } <EOL> }

/**
 * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index.
 * The resulting sequence ends as soon as the shortest input sequence ends.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Sequences.Transformations.zip
 */


public fun < T , R , V > Sequence < T > . zip ( other : Sequence < R > , transform : ( a : T , b : R ) -> V ) : Sequence < V >

{ <EOL> return MergingSequence ( this , other , transform ) <EOL> }

/**
 * Returns a sequence of values built from the elements of `this` sequence and the [other] sequence with the same index
 * using the provided [transform] function applied to each pair of elements.
 * The resulting sequence ends as soon as the shortest input sequence ends.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Sequences.Transformations.zipWithTransform
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T > Sequence < T > . zipWithNext ( ) : Sequence < Pair < T , T > >

{ <EOL> return zipWithNext { a , b -> a to b } <EOL> }

/**
 * Returns a sequence of pairs of each two adjacent elements in this sequence.
 *
 * The returned sequence is empty if this sequence contains less than two elements.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.zipWithNext
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public fun < T , R > Sequence < T > . zipWithNext ( transform : ( a : T , b : T ) -> R ) : Sequence < R >

{ <EOL> return sequence result @ { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) return@result <EOL> var current = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) { <EOL> val next = iterator . next ( ) <EOL> yield ( transform ( current , next ) ) <EOL> current = next <EOL> } <EOL> } <EOL> }

/**
 * Returns a sequence containing the results of applying the given [transform] function
 * to an each pair of two adjacent elements in this sequence.
 *
 * The returned sequence is empty if this sequence contains less than two elements.
 *
 * The operation is _intermediate_ and _stateless_.
 *
 * @sample samples.collections.Collections.Transformations.zipWithNextToFindDeltas
 */


public fun < T , A : Appendable > Sequence < T > . joinTo ( buffer : A , separator : CharSequence = "<STR_LIT:U+002CU+0020>" , prefix : CharSequence = "<STR_LIT>" , postfix : CharSequence = "<STR_LIT>" , limit : Int = - <NUM_LIT:1> , truncated : CharSequence = "<STR_LIT:...>" , transform : ( ( T ) -> CharSequence ) ? = null ) : A

{ <EOL> buffer . append ( prefix ) <EOL> var count = <NUM_LIT:0> <EOL> for ( element in this ) { <EOL> if ( ++ count > <NUM_LIT:1> ) buffer . append ( separator ) <EOL> if ( limit < <NUM_LIT:0> || count <= limit ) { <EOL> buffer . appendElement ( element , transform ) <EOL> } else break <EOL> } <EOL> if ( limit >= <NUM_LIT:0> && count > limit ) buffer . append ( truncated ) <EOL> buffer . append ( postfix ) <EOL> return buffer <EOL> }

/**
 * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
 *
 * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
 * elements will be appended, followed by the [truncated] string (which defaults to "...").
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.joinTo
 */


public fun < T > Sequence < T > . joinToString ( separator : CharSequence = "<STR_LIT:U+002CU+0020>" , prefix : CharSequence = "<STR_LIT>" , postfix : CharSequence = "<STR_LIT>" , limit : Int = - <NUM_LIT:1> , truncated : CharSequence = "<STR_LIT:...>" , transform : ( ( T ) -> CharSequence ) ? = null ) : String

{ <EOL> return joinTo ( StringBuilder ( ) , separator , prefix , postfix , limit , truncated , transform ) . toString ( ) <EOL> }

/**
 * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied.
 *
 * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
 * elements will be appended, followed by the [truncated] string (which defaults to "...").
 *
 * The operation is _terminal_.
 *
 * @sample samples.collections.Collections.Transformations.joinToString
 */


public fun < T > Sequence < T > . asIterable ( ) : Iterable < T >

{ <EOL> return Iterable { this . iterator ( ) } <EOL> }

/**
 * Creates an [Iterable] instance that wraps the original sequence returning its elements when being iterated.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > Sequence < T > . asSequence ( ) : Sequence < T >

{ <EOL> return this <EOL> }

/**
 * Returns this sequence as a [Sequence].
 */


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Byte > . average ( ) : Double

{ <EOL> var sum : Double = <NUM_LIT:0.0> <EOL> var count : Int = <NUM_LIT:0> <EOL> for ( element in this ) { <EOL> sum += element <EOL> checkCountOverflow ( ++ count ) <EOL> } <EOL> return if ( count == <NUM_LIT:0> ) Double . NaN else sum / count <EOL> }

/**
 * Returns an average value of elements in the sequence.
 *
 * The operation is _terminal_.
 */


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Short > . average ( ) : Double


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Int > . average ( ) : Double


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Long > . average ( ) : Double


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Float > . average ( ) : Double


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Double > . average ( ) : Double


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Byte > . sum ( ) : Int

{ <EOL> var sum : Int = <NUM_LIT:0> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }

/**
 * Returns the sum of all elements in the sequence.
 *
 * The operation is _terminal_.
 */


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Short > . sum ( ) : Int


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Int > . sum ( ) : Int


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Long > . sum ( ) : Long

{ <EOL> var sum : Long = <NUM_LIT:0L> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Float > . sum ( ) : Float

{ <EOL> var sum : Float = <NUM_LIT:0.0f> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }


@ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> public fun Sequence < Double > . sum ( ) : Double

{ <EOL> var sum : Double = <NUM_LIT:0.0> <EOL> for ( element in this ) { <EOL> sum += element <EOL> } <EOL> return sum <EOL> }


override fun toProtobufMessage ( ) : TestData . MessageWithOptionals

= <EOL> TestData . MessageWithOptionals . newBuilder ( ) . also { builder -> <EOL> val defaults = MessageWithOptionals ( ) <EOL> if ( a != defaults . a ) builder . a = a <EOL> if ( b != defaults . b ) builder . b = b <EOL> if ( c != defaults . c ) builder . c = c . toProtoBuf ( ) <EOL> if ( d != defaults . d ) builder . d = d <EOL> if ( e != defaults . e ) builder . addAllE ( e ) <EOL> } . build ( )

/**
 * Convert this [Serializable] object to its expected [TestData.MessageWithOptionals] ProtoBuf message.
 *
 * For this test we expect that default values are not encoded.
 */


public expect fun Double . isNaN ( ) : Boolean

/**
 * Returns `true` if the specified number is a
 * Not-a-Number (NaN) value, `false` otherwise.
 */


public expect fun Float . isNaN ( ) : Boolean


public expect fun Double . isInfinite ( ) : Boolean

/**
 * Returns `true` if this value is infinitely large in magnitude.
 */


public expect fun Float . isInfinite ( ) : Boolean


public expect fun Double . isFinite ( ) : Boolean

/**
 * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
 */


public expect fun Float . isFinite ( ) : Boolean


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Double . toBits ( ) : Long

/**
 * Returns a bit representation of the specified floating-point value as [Long]
 * according to the IEEE 754 floating-point "double format" bit layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Double . toRawBits ( ) : Long

/**
 * Returns a bit representation of the specified floating-point value as [Long]
 * according to the IEEE 754 floating-point "double format" bit layout,
 * preserving `NaN` values exact layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Double . Companion . fromBits ( bits : Long ) : Double

/**
 * Returns the [Double] value corresponding to a given bit representation.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Float . toBits ( ) : Int

/**
 * Returns a bit representation of the specified floating-point value as [Int]
 * according to the IEEE 754 floating-point "single format" bit layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Float . toRawBits ( ) : Int

/**
 * Returns a bit representation of the specified floating-point value as [Int]
 * according to the IEEE 754 floating-point "single format" bit layout,
 * preserving `NaN` values exact layout.
 */


@ SinceKotlin ( "<STR_LIT:1.2>" ) <EOL> public expect fun Float . Companion . fromBits ( bits : Int ) : Float

/**
 * Returns the [Float] value corresponding to a given bit representation.
 */


public expect fun < T > lazy ( mode : LazyThreadSafetyMode , initializer : ( ) -> T ) : Lazy < T >

/**
 * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
 *
 * The [mode] parameter is ignored. */


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) ) <EOL> @ DeprecatedSinceKotlin ( warningSince = "<STR_LIT:1.9>" ) <EOL> public expect fun < T > lazy ( lock : Any ? , initializer : ( ) -> T ) : Lazy < T >

/**
 * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
 *
 * The [lock] parameter is ignored.
 */


fun BuildResult . assertOutputContains ( expectedSubString : String , message : String = "<STR_LIT>" , )

{ <EOL> assert ( output . contains ( expectedSubString ) ) { <EOL> printBuildOutput ( ) <EOL> message <EOL> } <EOL> }

/**
 * Asserts Gradle output contains [expectedSubString] string.
 */


fun BuildResult . assertOutputContainsAny ( vararg expectedSubStrings : String , )

{ <EOL> assert ( expectedSubStrings . any { output . contains ( it ) } ) { <EOL> printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Asserts Gradle output contains any of [expectedSubStrings] strings.
 */


fun BuildResult . assertOutputContainsExactTimes ( expectedSubString : String , expectedRepetitionTimes : Int = <NUM_LIT:1> , )

{ <EOL> var currentOffset = <NUM_LIT:0> <EOL> var count = <NUM_LIT:0> <EOL> var nextIndex = output . indexOf ( expectedSubString , currentOffset ) <EOL> while ( nextIndex != - <NUM_LIT:1> && count < expectedRepetitionTimes + <NUM_LIT:1> ) { <EOL> count ++ <EOL> currentOffset = nextIndex + expectedSubString . length <EOL> nextIndex = output . indexOf ( expectedSubString , currentOffset ) <EOL> } <EOL> assert ( count == expectedRepetitionTimes ) { <EOL> printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Asserts Gradle output contains [expectedSubString] string exact times.
 */


fun BuildResult . assertOutputDoesNotContain ( notExpectedSubString : String , wrappingCharsCount : Int = <NUM_LIT:100> , )

{ <EOL> assert ( ! output . contains ( notExpectedSubString ) ) { <EOL> printBuildOutput ( ) <EOL> val occurrences = mutableListOf < Pair < Int , Int > > ( ) <EOL> var startIndex = output . indexOf ( notExpectedSubString ) <EOL> var endIndex = startIndex + notExpectedSubString . length <EOL> do { <EOL> occurrences . add ( startIndex to endIndex ) <EOL> startIndex = output . indexOf ( notExpectedSubString , endIndex ) <EOL> endIndex = startIndex + notExpectedSubString . length <EOL> } while ( startIndex != - <NUM_LIT:1> ) <EOL> val linesContainingSubString = occurrences . map { ( startIndex , endIndex ) -> <EOL> output . subSequence ( ( startIndex - wrappingCharsCount ) . coerceAtLeast ( <NUM_LIT:0> ) , ( endIndex + wrappingCharsCount ) . coerceAtMost ( output . length ) ) <EOL> } <EOL> """<STR_LIT>""" . trimMargin ( ) <EOL> } <EOL> }

/**
 * Asserts Gradle output does not contain [notExpectedSubString] string.
 *
 * @param wrappingCharsCount amount of chars to include before and after [notExpectedSubString] occurrence
 */


fun BuildResult . assertOutputContains ( expected : Regex , message : String = "<STR_LIT>" , )

{ <EOL> assert ( output . contains ( expected ) ) { <EOL> printBuildOutput ( ) <EOL> message <EOL> } <EOL> }

/**
 * Assert build output contains one or more strings matching [expected] regex.
 */


fun BuildResult . assertOutputDoesNotContain ( regexToCheck : Regex , )

{ <EOL> assert ( ! output . contains ( regexToCheck ) ) { <EOL> printBuildOutput ( ) <EOL> val matchedStrings = regexToCheck <EOL> . findAll ( output ) <EOL> . map { it . value } <EOL> . joinToString ( prefix = "<STR_LIT>" , separator = "<STR_LIT>" ) <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Asserts build output does not contain any lines matching [regexToCheck] regex.
 */


fun BuildResult . assertOutputContainsExactlyTimes ( expected : String , expectedCount : Int = <NUM_LIT:1> , )

{ <EOL> assertOutputContainsExactlyTimes ( expected . toRegex ( RegexOption . LITERAL ) , expectedCount ) <EOL> }

/**
 * Asserts build output contains exactly [expectedCount] of occurrences of [expected] string.
 */


fun BuildResult . assertNoBuildWarnings ( additionalExpectedWarnings : Set < String > = emptySet ( ) , )

{ <EOL> val expectedWarnings = setOf ( "<STR_LIT>" ) <EOL> val cleanedOutput = ( expectedWarnings + additionalExpectedWarnings ) . fold ( output ) { acc , s -> <EOL> acc . replace ( s , "<STR_LIT>" ) <EOL> } <EOL> val warnings = cleanedOutput <EOL> . lineSequence ( ) <EOL> . filter { it . trim ( ) . startsWith ( "<STR_LIT>" ) } <EOL> . toList ( ) <EOL> assert ( warnings . isEmpty ( ) ) { <EOL> printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Assert build contains no warnings.
 */


fun BuildResult . assertKotlinDaemonJvmOptions ( expectedJvmArgs : List < String > , )

{ <EOL> val jvmArgsCommonMessage = "<STR_LIT>" <EOL> assertOutputContains ( jvmArgsCommonMessage ) <EOL> val argsRegex = "<STR_LIT>" . toRegex ( ) <EOL> val argsStrings = output . lineSequence ( ) <EOL> . filter { it . contains ( jvmArgsCommonMessage ) } <EOL> . map { <EOL> argsRegex . findAll ( it ) . last ( ) . value . removePrefix ( "<STR_LIT:[>" ) . removeSuffix ( "<STR_LIT:]>" ) . split ( "<STR_LIT:U+002CU+0020>" ) <EOL> } <EOL> val containsArgs = argsStrings . any { <EOL> it . containsAll ( expectedJvmArgs ) <EOL> } <EOL> assert ( containsArgs ) { <EOL> printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> }

/**
 * Asserts compilation is running via Kotlin daemon with given jvm arguments.
 */


fun BuildResult . assertDeprecationWarningsArePresent ( warningMode : WarningMode )

{ <EOL> assertOutputContains ( "<STR_LIT>" , NO_GRADLE_WARNINGS_DETECTOR_PLUGIN_ERROR_MESSAGE ) <EOL> assertOutputContains ( "<STR_LIT>" , getWarningModeChangeAdvice ( warningMode ) ) <EOL> }

/**
 * Asserts that the build produced some deprecation warnings.
 *
 * Expected to be executed only for the case when [BuildOptions.warningMode] is not set to [WarningMode.Fail]
 */


fun BuildResult . assertNativeTasksClasspath ( vararg tasksPaths : String , toolName : NativeToolKind = NativeToolKind . KONANC , assertions : ( List < String > ) -> Unit , )

= tasksPaths . forEach { taskPath -> assertions ( extractNativeCompilerClasspath ( getOutputForTask ( taskPath , LogLevel . INFO ) , toolName ) ) }

/**
 * Asserts classpath of the given K/N compiler tool for given tasks' paths.
 *
 * Note: Log level of output must be set to [LogLevel.INFO].
 *
 * @param tasksPaths tasks' paths, for which classpath should be checked with give assertions
 * @param toolName name of build tool
 * @param assertions assertions, with will be applied to each classpath of each given task
 */


fun BuildResult . extractTaskCompilerArguments ( taskPath : String , logLevel : LogLevel = LogLevel . INFO ) : String

{ <EOL> val taskOutput = getOutputForTask ( taskPath , logLevel ) <EOL> return taskOutput . lines ( ) . first { <EOL> it . contains ( "<STR_LIT>" ) <EOL> } . substringAfter ( "<STR_LIT>" ) <EOL> }

/**
 * Extracts compiler arguments used in compilation for a given Kotlin task under [taskPath] path.
 *
 * @param logLevel [LogLevel] with which build was running, default to [LogLevel.INFO].
 */


fun BuildResult . assertNativeTasksCustomEnvironment ( vararg tasksPaths : String , toolName : NativeToolKind = NativeToolKind . KONANC , assertions : ( Map < String , String > ) -> Unit , )

= tasksPaths . forEach { taskPath -> assertions ( extractNativeCustomEnvironment ( taskPath , toolName ) ) }

/**
 * Asserts environment variables of the given K/N compiler for given tasks' paths
 *
 * Note: Log level of output must be set to [LogLevel.INFO].
 *
 * @param tasksPaths tasks' paths, for which command line arguments should be checked with give assertions.
 * @param toolName name of build tool
 * @param assertions assertions, with will be applied to each command line arguments of each given task
 */


fun CommandLineArguments . assertCommandLineArgumentsDoNotContain ( vararg expectedArgs : String , )

{ <EOL> expectedArgs . forEach { <EOL> assert ( ! args . contains ( it ) ) { <EOL> this . buildResult . printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> }

/**
 * Asserts that the given list of command line arguments does not contain any of the expected arguments.
 *
 * @param expectedArgs the list of expected arguments
 * @throws AssertionError if any of the expected arguments are found in the actual arguments list
 */


fun CommandLineArguments . assertCommandLineArgumentsContain ( vararg expectedArgs : String , )

{ <EOL> expectedArgs . forEach { <EOL> assert ( args . contains ( it ) ) { <EOL> this . buildResult . printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> }

/**
 * Asserts that the given list of command line arguments contains all the expected arguments.
 *
 * @param expectedArgs the list of expected arguments
 * @throws AssertionError if any of the expected arguments are missing from the actual arguments list
 */


fun CommandLineArguments . assertCommandLineArgumentsContainSequentially ( vararg expectedArgs : String , )

{ <EOL> expectedArgs . forEach { <EOL> assert ( expectedArgs . isNotEmpty ( ) && Collections . indexOfSubList ( args , expectedArgs . toList ( ) ) != - <NUM_LIT:1> ) { <EOL> this . buildResult . printBuildOutput ( ) <EOL> "<STR_LIT>" <EOL> } <EOL> } <EOL> }

/**
 * Asserts that the given list of command line arguments contains sequentially all the expected arguments.
 *
 * @param expectedArgs the list of expected arguments
 * @throws AssertionError if any of the expected arguments are missing from the actual arguments list
 */


fun BuildResult . assertOutputContainsNativeFrameworkVariant ( variantName : String , gradleVersion : GradleVersion )

{ <EOL> val isAtLeastGradle75 = gradleVersion >= GradleVersion . version ( TestVersions . Gradle . G_7_5 ) <EOL> try { <EOL> assertOutputContains ( if ( isAtLeastGradle75 ) "<STR_LIT>" else "<STR_LIT>" ) <EOL> } catch ( originalError : AssertionError ) { <EOL> val regexPattern = if ( isAtLeastGradle75 ) { <EOL> "<STR_LIT>" <EOL> } else { <EOL> "<STR_LIT>" <EOL> } <EOL> val matchedVariants = Regex ( regexPattern ) . findAll ( output ) . toList ( ) <EOL> throw AssertionError ( "<STR_LIT>" + if ( matchedVariants . isNotEmpty ( ) ) "<STR_LIT>" + matchedVariants . joinToString { it . groupValues [ <NUM_LIT:1> ] } else "<STR_LIT>" , originalError ) <EOL> } <EOL> }

/**
 * Asserts that the output of a Gradle build contains a variant with the given name.
 *
 * @param variantName The name of the variant to look for in the output.
 * @param gradleVersion The version of Gradle used to build the variant.
 * @throws AssertionError if no variant with the given name and Gradle version is found in the output.
 */


fun CommandLineArguments . assertNoDuplicates ( )

{ <EOL> val argsWithoutLibraries = args . filter { it != "<STR_LIT>" } <EOL> assertEquals ( argsWithoutLibraries . joinToString ( "<STR_LIT:\n>" ) , argsWithoutLibraries . toSet ( ) . joinToString ( "<STR_LIT:\n>" ) , "<STR_LIT>" ) <EOL> }

/**
 * Asserts that the command line arguments do not contain any duplicates.
 */


public fun copy ( copiedModelName : String ? = null , copyOptimizerState : Boolean = false , copyWeights : Boolean = true ) : Sequential

{ <EOL> val serializedModel = serializeModel ( true ) <EOL> return deserializeSequentialModel ( serializedModel ) . also { modelCopy -> <EOL> if ( copiedModelName != null ) modelCopy . name = copiedModelName <EOL> if ( copyWeights ) copyWeightsTo ( modelCopy , copyOptimizerState ) <EOL> } <EOL> }

/**
 * Creates a copy of this model.
 *
 * @param [copiedModelName] a name for the copy
 * @param [copyOptimizerState] whether optimizer state needs to be copied
 * @param [copyWeights] whether model weights need to be copied
 * @return A copied inference model.
 */


@ JvmStatic <EOL> public fun of ( vararg layers : Layer , noInput : Boolean = false , gpuConfiguration : GpuConfiguration ? = null ) : Sequential

{ <EOL> if ( ! noInput ) { <EOL> layerValidation ( layers . toList ( ) ) <EOL> } <EOL> preProcessLayerNames ( layers ) <EOL> return Sequential ( * layers , gpuConfiguration = gpuConfiguration ) <EOL> }

/**
 * Creates the [Sequential] model.
 *
 * @param [noInput] If true it disables input layer check.
 * @param [layers] The layers to describe the model design.
 * @param [gpuConfiguration] The configuration of a model passed to the Tensorflow Runtime.
 *
 * NOTE: The first layer should be an input layer if you want to compile a model.
 *
 * @return the [Sequential] model.
 */


@ JvmStatic <EOL> public fun of ( vararg layers : Layer , noInput : Boolean = false ) : Sequential

{ <EOL> return of ( layers = layers , noInput = noInput , gpuConfiguration = null ) <EOL> }

/**
 * Creates the [Sequential] model.
 *
 * @param [noInput] If true it disables input layer check.
 * @param [layers] The layers to describe the model design.
 *
 * NOTE: The first layer should be an input layer if you want to compile a model.
 *
 * @return the [Sequential] model.
 */


@ JvmStatic <EOL> public fun of ( layers : List < Layer > , noInput : Boolean = false , gpuConfiguration : GpuConfiguration ? = null ) : Sequential

{ <EOL> if ( ! noInput ) { <EOL> layerValidation ( layers . toList ( ) ) <EOL> } <EOL> preProcessLayerNames ( layers . toTypedArray ( ) ) <EOL> return Sequential ( * layers . toTypedArray ( ) , gpuConfiguration = gpuConfiguration ) <EOL> }

/**
 * Creates the [Functional] model.
 *
 * @param [noInput] If true it disables input layer check.
 * @param [layers] The layers to describe the model design.
 * @param [gpuConfiguration] The configuration of a model passed to the Tensorflow Runtime.
 *
 * NOTE: The first layer should be an input layer if you want to compile a model.
 *
 * @return the [Sequential] model.
 */


@ JvmStatic <EOL> public fun of ( layers : List < Layer > , noInput : Boolean = false ) : Sequential


@ JvmStatic <EOL> public fun loadModelConfiguration ( configuration : File , inputShape : IntArray ? = null ) : Sequential

{ <EOL> require ( configuration . isFile ) { "<STR_LIT>" } <EOL> return loadSequentialModelConfiguration ( configuration , inputShape ) <EOL> }

/**
 * Loads a [Sequential] model from json file with model configuration.
 *
 * @param [configuration] File in .json format, containing the [Sequential] model.
 * @return Non-compiled and non-trained Sequential model.
 */


@ JvmStatic <EOL> public fun loadModelLayersFromConfiguration ( configuration : File , inputShape : IntArray ? = null ) : Pair < Input , List < Layer > >

{ <EOL> require ( configuration . isFile ) { "<STR_LIT>" } <EOL> val config = loadSerializedModel ( configuration ) <EOL> return loadSequentialModelLayers ( config , inputShape ) <EOL> }

/**
 * Loads a [Sequential] model layers from json file with model configuration.
 *
 * @param [configuration] File in .json format, containing the [Sequential] model.
 * @return Pair of <input layer; list of layers>.
 */