{ <EOL> val builder = StringBuilder ( ) <EOL> val codeBlockBuilder = StringBuilder ( ) <EOL> var targetBuilder = builder <EOL> var contentStarted = false <EOL> var afterAsterisk = false <EOL> var indentedCodeBlock = false <EOL> fun isCodeBlock ( ) = targetBuilder == codeBlockBuilder <EOL> fun startCodeBlock ( ) { <EOL> targetBuilder = codeBlockBuilder <EOL> } <EOL> fun flushCodeBlock ( ) { <EOL> if ( isCodeBlock ( ) ) { <EOL> builder . append ( trimCommonIndent ( codeBlockBuilder , indentedCodeBlock ) ) <EOL> codeBlockBuilder . setLength ( <NUM_LIT:0> ) <EOL> targetBuilder = builder <EOL> } <EOL> } <EOL> var children = childrenAfterTagName ( ) <EOL> if ( hasSubject ( children ) ) { <EOL> children = children . drop ( <NUM_LIT:1> ) <EOL> } <EOL> for ( node in children ) { <EOL> val type = node . elementType <EOL> if ( type == KDocTokens . CODE_BLOCK_TEXT ) { <EOL> if ( ! isCodeBlock ( ) ) <EOL> indentedCodeBlock = indentedCodeBlock || node . text . startsWith ( indentationWhiteSpaces ) || node . text . startsWith ( "<STR_LIT>" ) <EOL> startCodeBlock ( ) <EOL> } else if ( KDocTokens . CONTENT_TOKENS . contains ( type ) ) { <EOL> flushCodeBlock ( ) <EOL> indentedCodeBlock = false <EOL> } <EOL> if ( KDocTokens . CONTENT_TOKENS . contains ( type ) ) { <EOL> val isPlainContent = afterAsterisk && ! isCodeBlock ( ) <EOL> val trimLeadingSpaces = ! ( contentStarted || indentedCodeBlock ) || isPlainContent <EOL> targetBuilder . append ( if ( trimLeadingSpaces ) node . text . trimStart ( ) else node . text ) <EOL> contentStarted = true <EOL> afterAsterisk = false <EOL> } <EOL> if ( type == KDocTokens . LEADING_ASTERISK ) { <EOL> afterAsterisk = true <EOL> } <EOL> if ( type == TokenType . WHITE_SPACE && contentStarted ) { <EOL> targetBuilder . append ( "<STR_LIT:\n>" . repeat ( StringUtil . countNewLines ( node . text ) ) ) <EOL> } <EOL> if ( type == KDocElementTypes . KDOC_TAG ) { <EOL> break <EOL> } <EOL> } <EOL> flushCodeBlock ( ) <EOL> return builder . toString ( ) . trimEnd ( '<CHAR_LIT:U+0020>' , '<CHAR_LIT>' ) <EOL> }

/**
 * Returns the content of this tag (all text following the tag name and the subject if present,
 * with leading asterisks removed).
 */


abstract fun replaceType ( newType : TypeRefWithNullability ) : Field

/**
 * Returns a copy of this field with its [typeRef] set to [newType] (if it's possible).
 */


abstract fun copy ( ) : Field

/**
 * Returns a copy of this field.
 */


public fun < T : Any > create ( any : T ) : StableRef < T >

= StableRef < T > ( createStablePointer ( any ) )

/**
 * Creates a handle for given object.
 */


public fun asCPointer ( ) : COpaquePointer

= this . stablePtr

/**
 * Converts the handle to C pointer.
 * @see [asStableRef]
 */


{ <EOL> disposeStablePointer ( this . stablePtr ) <EOL> }

/**
 * Disposes the handle. It must not be used after that.
 */


@ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> public fun get ( ) : T

= derefStablePointer ( this . stablePtr ) as T

/**
 * Returns the object this handle was [created][StableRef.create] for.
 */


@ ExperimentalForeignApi <EOL> public inline fun < reified T : Any > CPointer < * > . asStableRef ( ) : StableRef < T >

= StableRef < T > ( this ) . also { it . get ( ) }

/**
 * Converts to [StableRef] this opaque pointer produced by [StableRef.asCPointer].
 */


@ JsName ( "<STR_LIT>" ) <EOL> internal fun setAdapter ( adapter : dynamic )

= kotlin . test . setAdapter ( adapter )

/**
 * Overrides current framework adapter with a provided instance of [FrameworkAdapter]. Use in order to support custom test frameworks.
 *
 * Also some string arguments are supported. Use "qunit" to set the adapter to [QUnit](https://qunitjs.com/), "mocha" for
 * [Mocha](https://mochajs.org/), "jest" for [Jest](https://facebook.github.io/jest/),
 * "jasmine" for [Jasmine](https://github.com/jasmine/jasmine), and "auto" to detect one of those frameworks automatically.
 *
 * If this function is not called, the test framework will be detected automatically (as if "auto" was passed).
 *
 */


public suspend fun CompletableSource . await ( ) : Unit

= suspendCancellableCoroutine { cont -> <EOL> subscribe ( object : CompletableObserver { <EOL> override fun onSubscribe ( d : Disposable ) { <EOL> cont . disposeOnCancellation ( d ) <EOL> } <EOL> override fun onComplete ( ) { <EOL> cont . resume ( Unit ) <EOL> } <EOL> override fun onError ( e : Throwable ) { <EOL> cont . resumeWithException ( e ) <EOL> } <EOL> } ) <EOL> }

/**
 * Awaits for completion of this completable without blocking the thread.
 * Returns `Unit`, or throws the corresponding exception if this completable produces an error.
 *
 * This suspending function is cancellable. If the [Job] of the invoking coroutine is cancelled while this
 * suspending function is suspended, this function immediately resumes with [CancellationException] and disposes of its
 * subscription.
 */


public suspend fun < T > MaybeSource < T > . awaitSingleOrNull ( ) : T ?

= suspendCancellableCoroutine { cont -> <EOL> subscribe ( object : MaybeObserver < T > { <EOL> override fun onSubscribe ( d : Disposable ) { <EOL> cont . disposeOnCancellation ( d ) <EOL> } <EOL> override fun onComplete ( ) { <EOL> cont . resume ( null ) <EOL> } <EOL> override fun onSuccess ( t : T & Any ) { <EOL> cont . resume ( t ) <EOL> } <EOL> override fun onError ( error : Throwable ) { <EOL> cont . resumeWithException ( error ) <EOL> } <EOL> } ) <EOL> }

/**
 * Awaits for completion of the [MaybeSource] without blocking the thread.
 * Returns the resulting value, or `null` if no value is produced, or throws the corresponding exception if this
 * [MaybeSource] produces an error.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this
 * function immediately resumes with [CancellationException] and disposes of its subscription.
 */


public suspend fun < T > MaybeSource < T > . awaitSingle ( ) : T

= awaitSingleOrNull ( ) ? : throw NoSuchElementException ( )

/**
 * Awaits for completion of the [MaybeSource] without blocking the thread.
 * Returns the resulting value, or throws if either no value is produced or this [MaybeSource] produces an error.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this
 * function immediately resumes with [CancellationException] and disposes of its subscription.
 *
 * @throws NoSuchElementException if no elements were produced by this [MaybeSource].
 */


@ Deprecated ( message = "<STR_LIT>" , level = DeprecationLevel . HIDDEN , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public suspend fun < T > MaybeSource < T > . await ( ) : T ?

= awaitSingleOrNull ( )

/**
 * Awaits for completion of the maybe without blocking a thread.
 * Returns the resulting value, null if no value was produced or throws the corresponding exception if this
 * maybe had produced error.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
 * immediately resumes with [CancellationException].
 *
 * ### Deprecation
 *
 * Deprecated in favor of [awaitSingleOrNull] in order to reflect that `null` can be returned to denote the absence of
 * a value, as opposed to throwing in such case.
 * @suppress
 */


@ Deprecated ( message = "<STR_LIT>" , level = DeprecationLevel . HIDDEN , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public suspend fun < T > MaybeSource < T > . awaitOrDefault ( default : T ) : T

= awaitSingleOrNull ( ) ? : default

/**
 * Awaits for completion of the maybe without blocking a thread.
 * Returns the resulting value, [default] if no value was produced or throws the corresponding exception if this
 * maybe had produced error.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while this suspending function is waiting, this function
 * immediately resumes with [CancellationException].
 *
 * ### Deprecation
 *
 * Deprecated in favor of [awaitSingleOrNull] for naming consistency (see the deprecation of [MaybeSource.await] for
 * details).
 * @suppress
 */


public suspend fun < T > SingleSource < T > . await ( ) : T

= suspendCancellableCoroutine { cont -> <EOL> subscribe ( object : SingleObserver < T > { <EOL> override fun onSubscribe ( d : Disposable ) { <EOL> cont . disposeOnCancellation ( d ) <EOL> } <EOL> override fun onSuccess ( t : T & Any ) { <EOL> cont . resume ( t ) <EOL> } <EOL> override fun onError ( error : Throwable ) { <EOL> cont . resumeWithException ( error ) <EOL> } <EOL> } ) <EOL> }

/**
 * Awaits for completion of the single value response without blocking the thread.
 * Returns the resulting value, or throws the corresponding exception if this response produces an error.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 */


public suspend fun < T > ObservableSource < T > . awaitFirst ( ) : T

= awaitOne ( Mode . FIRST )

/**
 * Awaits the first value from the given [Observable] without blocking the thread and returns the resulting value, or,
 * if the observable has produced an error, throws the corresponding exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 *
 * @throws NoSuchElementException if the observable does not emit any value
 */


public suspend fun < T > ObservableSource < T > . awaitFirstOrDefault ( default : T ) : T

= awaitOne ( Mode . FIRST_OR_DEFAULT , default )

/**
 * Awaits the first value from the given [Observable], or returns the [default] value if none is emitted, without
 * blocking the thread, and returns the resulting value, or, if this observable has produced an error, throws the
 * corresponding exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 */


public suspend fun < T > ObservableSource < T > . awaitFirstOrNull ( ) : T ?

= awaitOne ( Mode . FIRST_OR_DEFAULT )

/**
 * Awaits the first value from the given [Observable], or returns `null` if none is emitted, without blocking the
 * thread, and returns the resulting value, or, if this observable has produced an error, throws the corresponding
 * exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 */


public suspend fun < T > ObservableSource < T > . awaitFirstOrElse ( defaultValue : ( ) -> T ) : T

= <EOL> awaitOne ( Mode . FIRST_OR_DEFAULT ) ? : defaultValue ( )

/**
 * Awaits the first value from the given [Observable], or calls [defaultValue] to get a value if none is emitted,
 * without blocking the thread, and returns the resulting value, or, if this observable has produced an error, throws
 * the corresponding exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 */


public suspend fun < T > ObservableSource < T > . awaitLast ( ) : T

= awaitOne ( Mode . LAST )

/**
 * Awaits the last value from the given [Observable] without blocking the thread and
 * returns the resulting value, or, if this observable has produced an error, throws the corresponding exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 *
 * @throws NoSuchElementException if the observable does not emit any value
 */


public suspend fun < T > ObservableSource < T > . awaitSingle ( ) : T

= awaitOne ( Mode . SINGLE )

/**
 * Awaits the single value from the given observable without blocking the thread and returns the resulting value, or,
 * if this observable has produced an error, throws the corresponding exception.
 *
 * This suspending function is cancellable.
 * If the [Job] of the current coroutine is cancelled while the suspending function is waiting, this
 * function immediately disposes of its subscription and resumes with [CancellationException].
 *
 * @throws NoSuchElementException if the observable does not emit any value
 * @throws IllegalArgumentException if the observable emits more than one value
 */


{ <EOL> val tag = getStrictParentOfType < KDocTag > ( ) <EOL> return if ( tag != null && tag . getSubjectLink ( ) == this ) tag else null <EOL> }

/**
 * If this link is the subject of a tag, returns the tag. Otherwise, returns null.
 */


private fun modifiedLenet5 ( ) : Sequential

= Sequential . of ( Input ( IMAGE_SIZE , IMAGE_SIZE , NUM_CHANNELS , name = "<STR_LIT>" ) , Conv2D ( filters = <NUM_LIT> , kernelSize = intArrayOf ( <NUM_LIT:5> , <NUM_LIT:5> ) , strides = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , activation = Activations . Elu , kernelInitializer = kernelInitializer , biasInitializer = biasInitializer , padding = ConvPadding . SAME , name = "<STR_LIT>" ) , MaxPool2D ( poolSize = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) , strides = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) , name = "<STR_LIT>" ) , Conv2D ( filters = <NUM_LIT> , kernelSize = intArrayOf ( <NUM_LIT:5> , <NUM_LIT:5> ) , strides = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) , activation = Activations . Elu , kernelInitializer = kernelInitializer , biasInitializer = biasInitializer , padding = ConvPadding . SAME , name = "<STR_LIT>" ) , MaxPool2D ( poolSize = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) , strides = intArrayOf ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:1> ) , name = "<STR_LIT>" ) , Flatten ( name = "<STR_LIT>" ) , Dense ( outputSize = <NUM_LIT> , activation = Activations . Relu , kernelInitializer = kernelInitializer , biasInitializer = biasInitializer , name = "<STR_LIT>" ) , Dense ( outputSize = <NUM_LIT> , activation = Activations . Relu , kernelInitializer = kernelInitializer , biasInitializer = biasInitializer , name = "<STR_LIT>" ) , Dense ( outputSize = NUMBER_OF_CLASSES , activation = Activations . Linear , kernelInitializer = kernelInitializer , biasInitializer = biasInitializer , name = "<STR_LIT>" ) )

/**
 * See [lenet5]. This just has Relu replaced for ELU on earlier layers for save/load test.
 */


fun eluLenetOnMnistWithIntermediateSave ( )

{ <EOL> val ( train , test ) = mnist ( ) <EOL> SaveTrainedModelHelper ( ) . trainAndSave ( train , test , modifiedLenet5 ( ) , MODEL_SAVE_PATH , <NUM_LIT> ) <EOL> Sequential . loadDefaultModelConfiguration ( File ( MODEL_SAVE_PATH ) ) . use { <EOL> it . compile ( optimizer = SGD ( learningRate = <NUM_LIT> ) , loss = Losses . SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS , metric = Metrics . ACCURACY ) <EOL> it . loadWeights ( File ( MODEL_SAVE_PATH ) ) <EOL> val accuracy = it . evaluate ( test ) . metrics [ Metrics . ACCURACY ] ? : <NUM_LIT:0.0> <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * This examples demonstrates running Save and Load for prediction on [mnist] dataset.
 */


{ <EOL> val layersActivation = Activations . Tanh <EOL> val classifierActivation = Activations . Linear <EOL> val model = Sequential . of ( Input ( IMAGE_SIZE , IMAGE_SIZE , NUM_CHANNELS , ) , Conv2D ( filters = <NUM_LIT:6> , kernelSize = <NUM_LIT:5> , strides = <NUM_LIT:1> , activation = layersActivation , kernelInitializer = GlorotNormal ( SEED ) , biasInitializer = Zeros ( ) , padding = ConvPadding . SAME , ) , AvgPool2D ( poolSize = <NUM_LIT:2> , strides = <NUM_LIT:2> , padding = ConvPadding . VALID , ) , Conv2D ( filters = <NUM_LIT:16> , kernelSize = <NUM_LIT:5> , strides = <NUM_LIT:1> , activation = layersActivation , kernelInitializer = GlorotNormal ( SEED ) , biasInitializer = Zeros ( ) , padding = ConvPadding . SAME , ) , AvgPool2D ( poolSize = <NUM_LIT:2> , strides = <NUM_LIT:2> , padding = ConvPadding . VALID , ) , Flatten ( ) , Dense ( outputSize = <NUM_LIT> , activation = layersActivation , kernelInitializer = GlorotNormal ( SEED ) , biasInitializer = Constant ( <NUM_LIT> ) , ) , Dense ( outputSize = <NUM_LIT> , activation = Activations . Tanh , kernelInitializer = GlorotNormal ( SEED ) , biasInitializer = Constant ( <NUM_LIT> ) , ) , Dense ( outputSize = NUMBER_OF_CLASSES , activation = classifierActivation , kernelInitializer = GlorotNormal ( SEED ) , biasInitializer = Constant ( <NUM_LIT> ) , ) , gpuConfiguration = GpuConfiguration ( allowGrowth = true ) ) <EOL> val ( train , test ) = mnist ( ) <EOL> model . use { <EOL> it . compile ( optimizer = Adam ( clipGradient = ClipGradientByValue ( <NUM_LIT> ) ) , loss = Losses . SOFT_MAX_CROSS_ENTROPY_WITH_LOGITS , metric = Metrics . ACCURACY ) <EOL> it . logSummary ( ) <EOL> it . fit ( dataset = train , epochs = EPOCHS , batchSize = TRAINING_BATCH_SIZE ) <EOL> val accuracy = it . evaluate ( dataset = test , batchSize = TEST_BATCH_SIZE ) . metrics [ Metrics . ACCURACY ] <EOL> println ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * This example shows how to do image classification from scratch using [lenet5Classic], without leveraging pre-trained weights or a pre-made model.
 * We demonstrate the workflow on the Mnist classification dataset.
 *
 * It could be run only with enabled tensorflow GPU dependencies
 *
 * It includes:
 * - dataset loading from S3
 * - model compilation
 * - model summary
 * - model training
 * - model evaluation
 */


= lenetClassicWithGPUMemoryConfig ( )


{ <EOL> val oldErr = System . err <EOL> val baos = ByteArrayOutputStream ( ) <EOL> try { <EOL> System . setErr ( PrintStream ( baos , true ) ) <EOL> DebugProbes . withDebugProbes { <EOL> try { <EOL> runTest ( timeout = <NUM_LIT:100> . milliseconds ) { <EOL> uniquelyNamedFunction ( ) <EOL> } <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } catch ( e : UncompletedCoroutinesError ) { <EOL> } <EOL> } <EOL> baos . toString ( ) . let { <EOL> assertTrue ( it . contains ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> } <EOL> } finally { <EOL> System . setErr ( oldErr ) <EOL> } <EOL> }

/**
 * Tests that the dump on timeout contains the correct stacktrace.
 */


fun testAnonymousObjectTypeMetadataKlibWithOldCLIKey ( )

= doTestAnonymousObjectTypeMetadata ( listOf ( "<STR_LIT>" ) ) { output -> <EOL> output . lines ( ) . filterNot { "<STR_LIT>" in it } . joinToString ( "<STR_LIT:\n>" ) <EOL> }

/**
 * This test does exactly the same as [testAnonymousObjectTypeMetadataKlib] but using the old (now deprecated)
 * CLI argument `-Xexpect-actual-linker` instead of its successor `-Xmetadata-klib`.
 *
 * The test is needed only to check that the old CLI argument still works as needed.
 */


fun createFreeFakeLambdaDescriptor ( descriptor : FunctionDescriptor , typeApproximator : TypeApproximator ? ) : FunctionDescriptor

{ <EOL> return createFreeDescriptor ( descriptor , typeApproximator ) <EOL> }

/**
 * Given a function descriptor, creates another function descriptor with type parameters copied from outer context(s).
 * This is needed because once we're serializing this to a proto, there's no place to store information about external type parameters.
 */


fun createFreeFakeLocalPropertyDescriptor ( descriptor : LocalVariableDescriptor , typeApproximator : TypeApproximator ? ) : PropertyDescriptor

{ <EOL> val property = PropertyDescriptorImpl . create ( descriptor . containingDeclaration , descriptor . annotations , Modality . FINAL , descriptor . visibility , descriptor . isVar , descriptor . name , CallableMemberDescriptor . Kind . DECLARATION , descriptor . source , false , descriptor . isConst , false , false , false , descriptor . isDelegated ) <EOL> property . setType ( descriptor . type , descriptor . typeParameters , descriptor . dispatchReceiverParameter , descriptor . extensionReceiverParameter , descriptor . contextReceiverParameters ) <EOL> property . initialize ( descriptor . getter ? . run { <EOL> PropertyGetterDescriptorImpl ( property , annotations , modality , visibility , true , isExternal , isInline , kind , null , source ) <EOL> . apply { <EOL> initialize ( this @ run . returnType ) <EOL> } <EOL> } , descriptor . setter ? . run { <EOL> PropertySetterDescriptorImpl ( property , annotations , modality , visibility , true , isExternal , isInline , kind , null , source ) <EOL> . apply { <EOL> initialize ( this @ run . valueParameters . single ( ) ) <EOL> } <EOL> } ) <EOL> return createFreeDescriptor ( property , typeApproximator ) <EOL> }

/**
 * Given a local delegated variable descriptor, creates a descriptor of a property that should be observed
 * when using reflection on that local variable at runtime.
 * Only members used by [DescriptorSerializer.propertyProto] are implemented correctly in this property descriptor.
 */


@ ExperimentalSerializationApi <EOL> public fun < T > Json . encodeToStream ( serializer : SerializationStrategy < T > , value : T , stream : OutputStream )

{ <EOL> val writer = JsonToJavaStreamWriter ( stream ) <EOL> try { <EOL> encodeByWriter ( this , writer , serializer , value ) <EOL> } finally { <EOL> writer . release ( ) <EOL> } <EOL> }

/**
 * Serializes the [value] with [serializer] into a [stream] using JSON format and UTF-8 encoding.
 *
 * @throws [SerializationException] if the given value cannot be serialized to JSON.
 * @throws [IOException] If an I/O error occurs and stream cannot be written to.
 */


@ ExperimentalSerializationApi <EOL> public inline fun < reified T > Json . encodeToStream ( value : T , stream : OutputStream ) : Unit

= <EOL> encodeToStream ( serializersModule . serializer ( ) , value , stream )

/**
 * Serializes given [value] to [stream] using UTF-8 encoding and serializer retrieved from the reified type parameter.
 *
 * @throws [SerializationException] if the given value cannot be serialized to JSON.
 * @throws [IOException] If an I/O error occurs and stream cannot be written to.
 */


@ ExperimentalSerializationApi <EOL> public fun < T > Json . decodeFromStream ( deserializer : DeserializationStrategy < T > , stream : InputStream ) : T

{ <EOL> val reader = JavaStreamSerialReader ( stream ) <EOL> try { <EOL> return decodeByReader ( this , deserializer , reader ) <EOL> } finally { <EOL> reader . release ( ) <EOL> } <EOL> }

/**
 * Deserializes JSON from [stream] using UTF-8 encoding to a value of type [T] using [deserializer].
 *
 * Note that this functions expects that exactly one object would be present in the stream
 * and throws an exception if there are any dangling bytes after an object.
 *
 * @throws [SerializationException] if the given JSON input cannot be deserialized to the value of type [T].
 * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance of type [T]
 * @throws [IOException] If an I/O error occurs and stream cannot be read from.
 */


@ ExperimentalSerializationApi <EOL> public inline fun < reified T > Json . decodeFromStream ( stream : InputStream ) : T

= <EOL> decodeFromStream ( serializersModule . serializer ( ) , stream )

/**
 * Deserializes the contents of given [stream] to the value of type [T] using UTF-8 encoding and
 * deserializer retrieved from the reified type parameter.
 *
 * Note that this functions expects that exactly one object would be present in the stream
 * and throws an exception if there are any dangling bytes after an object.
 *
 * @throws [SerializationException] if the given JSON input cannot be deserialized to the value of type [T].
 * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance of type [T]
 * @throws [IOException] If an I/O error occurs and stream cannot be read from.
 */


@ ExperimentalSerializationApi <EOL> public fun < T > Json . decodeToSequence ( stream : InputStream , deserializer : DeserializationStrategy < T > , format : DecodeSequenceMode = DecodeSequenceMode . AUTO_DETECT ) : Sequence < T >

{ <EOL> return decodeToSequenceByReader ( this , JavaStreamSerialReader ( stream ) , deserializer , format ) <EOL> }

/**
 * Transforms the given [stream] into lazily deserialized sequence of elements of type [T] using UTF-8 encoding and [deserializer].
 * Unlike [decodeFromStream], [stream] is allowed to have more than one element, separated as [format] declares.
 *
 * Elements must all be of type [T].
 * Elements are parsed lazily when resulting [Sequence] is evaluated.
 * Resulting sequence is tied to the stream and can be evaluated only once.
 *
 * **Resource caution:** this method neither closes the [stream] when the parsing is finished nor provides a method to close it manually.
 * It is a caller responsibility to hold a reference to a stream and close it. Moreover, because stream is parsed lazily,
 * closing it before returned sequence is evaluated completely will result in [IOException] from decoder.
 *
 * @throws [SerializationException] if the given JSON input cannot be deserialized to the value of type [T].
 * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance of type [T]
 * @throws [IOException] If an I/O error occurs and stream cannot be read from.
 */


@ ExperimentalSerializationApi <EOL> public inline fun < reified T > Json . decodeToSequence ( stream : InputStream , format : DecodeSequenceMode = DecodeSequenceMode . AUTO_DETECT ) : Sequence < T >

= decodeToSequence ( stream , serializersModule . serializer ( ) , format )

/**
 * Transforms the given [stream] into lazily deserialized sequence of elements of type [T] using UTF-8 encoding and deserializer retrieved from the reified type parameter.
 * Unlike [decodeFromStream], [stream] is allowed to have more than one element, separated as [format] declares.
 *
 * Elements must all be of type [T].
 * Elements are parsed lazily when resulting [Sequence] is evaluated.
 * Resulting sequence is tied to the stream and constrained to be evaluated only once.
 *
 * **Resource caution:** this method does not close [stream] when the parsing is finished neither provides method to close it manually.
 * It is a caller responsibility to hold a reference to a stream and close it. Moreover, because stream is parsed lazily,
 * closing it before returned sequence is evaluated fully would result in [IOException] from decoder.
 *
 * @throws [SerializationException] if the given JSON input cannot be deserialized to the value of type [T].
 * @throws [IllegalArgumentException] if the decoded input cannot be represented as a valid instance of type [T]
 * @throws [IOException] If an I/O error occurs and stream cannot be read from.
 */


private fun mustNotBeWrittenToStubs ( flags : Int ) : Boolean

{ <EOL> return Flags . MEMBER_KIND . get ( flags ) == MemberKind . FAKE_OVERRIDE <EOL> }

/**
 * @see org.jetbrains.kotlin.analysis.decompiler.psi.text.mustNotBeWrittenToDecompiledText
 */


/**
 * This function will not do anything
 */


public inline fun buildJsonObject ( builderAction : JsonObjectBuilder . ( ) -> Unit ) : JsonObject

{ <EOL> contract { callsInPlace ( builderAction , InvocationKind . EXACTLY_ONCE ) } <EOL> val builder = JsonObjectBuilder ( ) <EOL> builder . builderAction ( ) <EOL> return builder . build ( ) <EOL> }

/**
 * Builds [JsonObject] with the given [builderAction] builder.
 * Example of usage:
 * ```
 * val json = buildJsonObject {
 * put("booleanKey", true)
 * putJsonArray("arrayKey") {
 * for (i in 1..10) add(i)
 * }
 * putJsonObject("objectKey") {
 * put("stringKey", "stringValue")
 * }
 * }
 * ```
 */


public inline fun buildJsonArray ( builderAction : JsonArrayBuilder . ( ) -> Unit ) : JsonArray

{ <EOL> contract { callsInPlace ( builderAction , InvocationKind . EXACTLY_ONCE ) } <EOL> val builder = JsonArrayBuilder ( ) <EOL> builder . builderAction ( ) <EOL> return builder . build ( ) <EOL> }

/**
 * Builds [JsonArray] with the given [builderAction] builder.
 * Example of usage:
 * ```
 * val json = buildJsonArray {
 * add(true)
 * addJsonArray {
 * for (i in 1..10) add(i)
 * }
 * addJsonObject {
 * put("stringKey", "stringValue")
 * }
 * }
 * ```
 */


public fun put ( key : String , element : JsonElement ) : JsonElement ?

= content . put ( key , element )

/**
 * Add the given JSON [element] to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun JsonObjectBuilder . putJsonObject ( key : String , builderAction : JsonObjectBuilder . ( ) -> Unit ) : JsonElement ?

= <EOL> put ( key , buildJsonObject ( builderAction ) )

/**
 * Add the [JSON object][JsonObject] produced by the [builderAction] function to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun JsonObjectBuilder . putJsonArray ( key : String , builderAction : JsonArrayBuilder . ( ) -> Unit ) : JsonElement ?

= <EOL> put ( key , buildJsonArray ( builderAction ) )

/**
 * Add the [JSON array][JsonArray] produced by the [builderAction] function to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun JsonObjectBuilder . put ( key : String , value : Boolean ? ) : JsonElement ?

= put ( key , JsonPrimitive ( value ) )

/**
 * Add the given boolean [value] to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun JsonObjectBuilder . put ( key : String , value : Number ? ) : JsonElement ?

= put ( key , JsonPrimitive ( value ) )

/**
 * Add the given numeric [value] to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun JsonObjectBuilder . put ( key : String , value : String ? ) : JsonElement ?

= put ( key , JsonPrimitive ( value ) )

/**
 * Add the given string [value] to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


@ ExperimentalSerializationApi <EOL> @ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) <EOL> public fun JsonObjectBuilder . put ( key : String , value : Nothing ? ) : JsonElement ?

= put ( key , JsonNull )

/**
 * Add `null` to a resulting JSON object using the given [key].
 *
 * Returns the previous value associated with [key], or `null` if the key was not present.
 */


public fun add ( element : JsonElement ) : Boolean

{ <EOL> content += element <EOL> return true <EOL> }

/**
 * Adds the given JSON [element] to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


@ ExperimentalSerializationApi <EOL> public fun addAll ( elements : Collection < JsonElement > ) : Boolean

= <EOL> content . addAll ( elements )

/**
 * Adds the given JSON [elements] to a resulting JSON array.
 *
 * @return `true` if the list was changed as the result of the operation.
 */


public fun JsonArrayBuilder . add ( value : Boolean ? ) : Boolean

= add ( JsonPrimitive ( value ) )

/**
 * Adds the given boolean [value] to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


public fun JsonArrayBuilder . add ( value : Number ? ) : Boolean

= add ( JsonPrimitive ( value ) )

/**
 * Adds the given numeric [value] to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


public fun JsonArrayBuilder . add ( value : String ? ) : Boolean

= add ( JsonPrimitive ( value ) )

/**
 * Adds the given string [value] to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


@ ExperimentalSerializationApi <EOL> @ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) <EOL> public fun JsonArrayBuilder . add ( value : Nothing ? ) : Boolean

= add ( JsonNull )

/**
 * Adds `null` to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


public fun JsonArrayBuilder . addJsonObject ( builderAction : JsonObjectBuilder . ( ) -> Unit ) : Boolean

= <EOL> add ( buildJsonObject ( builderAction ) )

/**
 * Adds the [JSON object][JsonObject] produced by the [builderAction] function to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


public fun JsonArrayBuilder . addJsonArray ( builderAction : JsonArrayBuilder . ( ) -> Unit ) : Boolean

= <EOL> add ( buildJsonArray ( builderAction ) )

/**
 * Adds the [JSON array][JsonArray] produced by the [builderAction] function to a resulting JSON array.
 *
 * Always returns `true` similarly to [ArrayList] specification.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> @ ExperimentalSerializationApi <EOL> public fun JsonArrayBuilder . addAll ( values : Collection < String ? > ) : Boolean

= <EOL> addAll ( values . map ( :: JsonPrimitive ) )

/**
 * Adds the given string [values] to a resulting JSON array.
 *
 * @return `true` if the list was changed as the result of the operation.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> @ ExperimentalSerializationApi <EOL> public fun JsonArrayBuilder . addAll ( values : Collection < Boolean ? > ) : Boolean

/**
 * Adds the given boolean [values] to a resulting JSON array.
 *
 * @return `true` if the list was changed as the result of the operation.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> @ ExperimentalSerializationApi <EOL> public fun JsonArrayBuilder . addAll ( values : Collection < Number ? > ) : Boolean

/**
 * Adds the given numeric [values] to a resulting JSON array.
 *
 * @return `true` if the list was changed as the result of the operation.
 */


internal fun String . toBooleanStrictOrNull ( ) : Boolean ?

= when { <EOL> this . equals ( "<STR_LIT:true>" , ignoreCase = true ) -> true <EOL> this . equals ( "<STR_LIT:false>" , ignoreCase = true ) -> false <EOL> else -> null <EOL> }

/**
 * Returns `true` if the contents of this string is equal to the word "true", ignoring case, `false` if content equals "false",
 * and returns `null` otherwise.
 */


public fun < T > width ( column : ColumnReference < T > , parameters : LetsPlotNonPositionalMappingParametersContinuous < T , Double > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Double >

{ <EOL> return addNonPositionalMapping < T , Double > ( SIZE , column . name ( ) , LetsPlotNonPositionalMappingParametersContinuous < T , Double > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `width` aesthetic to a data column by [ColumnReference].
 *
 * @param column the data column to map to the size.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > width ( column : KProperty < T > , parameters : LetsPlotNonPositionalMappingParametersContinuous < T , Double > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Double >

{ <EOL> return addNonPositionalMapping < T , Double > ( SIZE , column . name , LetsPlotNonPositionalMappingParametersContinuous < T , Double > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `width` aesthetic to a data column by [KProperty].
 *
 * @param column the data column to map to the size.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun width ( column : String , parameters : LetsPlotNonPositionalMappingParametersContinuous < Any ? , Double > . ( ) -> Unit = { } ) : NonPositionalMapping < Any ? , Double >

{ <EOL> return addNonPositionalMapping ( SIZE , column , LetsPlotNonPositionalMappingParametersContinuous < Any ? , Double > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `width` aesthetic to a data column by [String].
 *
 * @param column the data column to map to the size.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > width ( values : Iterable < T > , name : String ? = null , parameters : LetsPlotNonPositionalMappingParametersContinuous < T , Double > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Double >

{ <EOL> return addNonPositionalMapping ( SIZE , values . toList ( ) , name , LetsPlotNonPositionalMappingParametersContinuous < T , Double > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `width` aesthetic to iterable of discrete values.
 *
 * @param values the iterable containing the discrete values.
 * @param name optional name for this aesthetic mapping.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > width ( values : DataColumn < T > , parameters : LetsPlotNonPositionalMappingParametersContinuous < T , Double > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Double >

{ <EOL> return addNonPositionalMapping ( SIZE , values , LetsPlotNonPositionalMappingParametersContinuous < T , Double > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the `width` aesthetic to a data column.
 *
 * @param values the data column to map to the size.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public inline fun < T , R > Flow < T > . transform ( @ BuilderInference crossinline transform : suspend FlowCollector < R > . ( value : T ) -> Unit ) : Flow < R >

= flow { <EOL> collect { value -> <EOL> return@collect transform ( value ) <EOL> } <EOL> }

/**
 * Applies [transform] function to each value of the given flow.
 *
 * The receiver of the `transform` is [FlowCollector] and thus `transform` is a
 * flexible function that may transform emitted element, skip it or emit it multiple times.
 *
 * This operator generalizes [filter] and [map] operators and
 * can be used as a building block for other operators, for example:
 *
 * ```
 * fun Flow<Int>.skipOddAndDuplicateEven(): Flow<Int> = transform { value ->
 * if (value % 2 == 0) { // Emit only even values, but twice
 * emit(value)
 * emit(value)
 * } // Do nothing if odd
 * }
 * ```
 */


public fun < T > Flow < T > . onStart ( action : suspend FlowCollector < T > . ( ) -> Unit ) : Flow < T >

= unsafeFlow { <EOL> val safeCollector = SafeCollector < T > ( this , currentCoroutineContext ( ) ) <EOL> try { <EOL> safeCollector . action ( ) <EOL> } finally { <EOL> safeCollector . releaseIntercepted ( ) <EOL> } <EOL> collect ( this ) <EOL> }

/**
 * Returns a flow that invokes the given [action] **before** this flow starts to be collected.
 *
 * The [action] is called before the upstream flow is started, so if it is used with a [SharedFlow]
 * there is **no guarantee** that emissions from the upstream flow that happen inside or immediately
 * after this `onStart` action will be collected
 * (see [onSubscription] for an alternative operator on shared flows).
 *
 * The receiver of the [action] is [FlowCollector], so `onStart` can emit additional elements.
 * For example:
 *
 * ```
 * flowOf("a", "b", "c")
 * .onStart { emit("Begin") }
 * .collect { println(it) } // prints Begin, a, b, c
 * ```
 */


public fun < T > Flow < T > . onCompletion ( action : suspend FlowCollector < T > . ( cause : Throwable ? ) -> Unit ) : Flow < T >

= unsafeFlow { <EOL> try { <EOL> collect ( this ) <EOL> } catch ( e : Throwable ) { <EOL> ThrowingCollector ( e ) . invokeSafely ( action , e ) <EOL> throw e <EOL> } <EOL> val sc = SafeCollector ( this , currentCoroutineContext ( ) ) <EOL> try { <EOL> sc . action ( null ) <EOL> } finally { <EOL> sc . releaseIntercepted ( ) <EOL> } <EOL> }

/**
 * Returns a flow that invokes the given [action] **after** the flow is completed or cancelled, passing
 * the cancellation exception or failure as cause parameter of [action].
 *
 * Conceptually, `onCompletion` is similar to wrapping the flow collection into a `finally` block,
 * for example the following imperative snippet:
 *
 * ```
 * try {
 * myFlow.collect { value ->
 * println(value)
 * }
 * } finally {
 * println("Done")
 * }
 * ```
 *
 * can be replaced with a declarative one using `onCompletion`:
 *
 * ```
 * myFlow
 * .onEach { println(it) }
 * .onCompletion { println("Done") }
 * .collect()
 * ```
 *
 * Unlike [catch], this operator reports exception that occur both upstream and downstream
 * and observe exceptions that are thrown to cancel the flow. Exception is empty if and only if
 * the flow had fully completed successfully. Conceptually, the following code:
 *
 * ```
 * myFlow.collect { value ->
 * println(value)
 * }
 * println("Completed successfully")
 * ```
 *
 * can be replaced with:
 *
 * ```
 * myFlow
 * .onEach { println(it) }
 * .onCompletion { if (it == null) println("Completed successfully") }
 * .collect()
 * ```
 *
 * The receiver of the [action] is [FlowCollector] and this operator can be used to emit additional
 * elements at the end **if it completed successfully**. For example:
 *
 * ```
 * flowOf("a", "b", "c")
 * .onCompletion { emit("Done") }
 * .collect { println(it) } // prints a, b, c, Done
 * ```
 *
 * In case of failure or cancellation, any attempt to emit additional elements throws the corresponding exception.
 * Use [catch] if you need to suppress failure and replace it with emission of elements.
 */


public fun < T > Flow < T > . onEmpty ( action : suspend FlowCollector < T > . ( ) -> Unit ) : Flow < T >

= unsafeFlow { <EOL> var isEmpty = true <EOL> collect { <EOL> isEmpty = false <EOL> emit ( it ) <EOL> } <EOL> if ( isEmpty ) { <EOL> val collector = SafeCollector ( this , currentCoroutineContext ( ) ) <EOL> try { <EOL> collector . action ( ) <EOL> } finally { <EOL> collector . releaseIntercepted ( ) <EOL> } <EOL> } <EOL> }

/**
 * Invokes the given [action] when this flow completes without emitting any elements.
 * The receiver of the [action] is [FlowCollector], so `onEmpty` can emit additional elements.
 * For example:
 *
 * ```
 * emptyFlow<Int>().onEmpty {
 * emit(1)
 * emit(2)
 * }.collect { println(it) } // prints 1, 2
 * ```
 */


internal fun KtDeclaration . resolveToDescriptorIfAny ( resolutionFacade : ResolutionFacade , bodyResolveMode : BodyResolveMode = BodyResolveMode . PARTIAL ) : DeclarationDescriptor ?

{ <EOL> val context = safeAnalyze ( resolutionFacade , bodyResolveMode ) <EOL> return if ( this is KtParameter && hasValOrVar ( ) ) { <EOL> context . get ( BindingContext . PRIMARY_CONSTRUCTOR_PARAMETER , this ) <EOL> ? : context . get ( BindingContext . DECLARATION_TO_DESCRIPTOR , this ) <EOL> } else { <EOL> context . get ( BindingContext . DECLARATION_TO_DESCRIPTOR , this ) <EOL> } <EOL> }

/**
 * This function first uses declaration resolvers to resolve this declaration and/or additional declarations (e.g. its parent),
 * and then takes the relevant descriptor from binding context.
 * The exact set of declarations to resolve depends on bodyResolveMode
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun LinAlg . inv ( mat : MultiArray < Float , D2 > ) : NDArray < Float , D2 >

= this . linAlgEx . invF ( mat )


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Number > LinAlg . inv ( mat : MultiArray < T , D2 > ) : NDArray < Double , D2 >

= this . linAlgEx . inv ( mat )

/**
 * Returns inverse of a double matrix from numeric matrix
 */


@ JvmName ( "<STR_LIT>" ) <EOL> public fun < T : Complex > LinAlg . inv ( mat : MultiArray < T , D2 > ) : NDArray < T , D2 >

= this . linAlgEx . invC ( mat )

/**
 * Returns inverse complex matrix
 */


@ WasmNoOpCast <EOL> @ ExcludedFromCodegen <EOL> public fun < T : JsAny > JsAny . unsafeCast ( ) : T

= <EOL> implementedAsIntrinsic

/**
 * Cast JsAny to other Js type without runtime check
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun < T > List < T > . component1 ( ) : T

{ <EOL> return get ( <NUM_LIT:0> ) <EOL> }

/**
 * Returns 1st *element* from the list.
 *
 * Throws an [IndexOutOfBoundsException] if the size of this list is less than 1.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun < T > List < T > . component2 ( ) : T

{ <EOL> return get ( <NUM_LIT:1> ) <EOL> }

/**
 * Returns 2nd *element* from the list.
 *
 * Throws an [IndexOutOfBoundsException] if the size of this list is less than 2.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun < T > List < T > . component3 ( ) : T

{ <EOL> return get ( <NUM_LIT:2> ) <EOL> }

/**
 * Returns 3rd *element* from the list.
 *
 * Throws an [IndexOutOfBoundsException] if the size of this list is less than 3.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun < T > List < T > . component4 ( ) : T

{ <EOL> return get ( <NUM_LIT:3> ) <EOL> }

/**
 * Returns 4th *element* from the list.
 *
 * Throws an [IndexOutOfBoundsException] if the size of this list is less than 4.
 */


@ kotlin . internal . InlineOnly <EOL> public inline operator fun < T > List < T > . component5 ( ) : T

{ <EOL> return get ( <NUM_LIT:4> ) <EOL> }

/**
 * Returns 5th *element* from the list.
 *
 * Throws an [IndexOutOfBoundsException] if the size of this list is less than 5.
 */


public operator fun < @ kotlin . internal . OnlyInputTypes T > Iterable < T > . contains ( element : T ) : Boolean

{ <EOL> if ( this is Collection ) <EOL> return contains ( element ) <EOL> return indexOf ( element ) >= <NUM_LIT:0> <EOL> }

/**
 * Returns `true` if [element] is found in the collection.
 */


public fun < T > Iterable < T > . elementAt ( index : Int ) : T

{ <EOL> if ( this is List ) <EOL> return get ( index ) <EOL> return elementAtOrElse ( index ) { throw IndexOutOfBoundsException ( "<STR_LIT>" ) } <EOL> }

/**
 * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection.
 *
 * @sample samples.collections.Collections.Elements.elementAt
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > List < T > . elementAt ( index : Int ) : T

{ <EOL> return get ( index ) <EOL> }

/**
 * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list.
 *
 * @sample samples.collections.Collections.Elements.elementAt
 */


public fun < T > Iterable < T > . elementAtOrElse ( index : Int , defaultValue : ( Int ) -> T ) : T

{ <EOL> contract { <EOL> callsInPlace ( defaultValue , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> if ( this is List ) <EOL> return this . getOrElse ( index , defaultValue ) <EOL> if ( index < <NUM_LIT:0> ) <EOL> return defaultValue ( index ) <EOL> val iterator = iterator ( ) <EOL> var count = <NUM_LIT:0> <EOL> while ( iterator . hasNext ( ) ) { <EOL> val element = iterator . next ( ) <EOL> if ( index == count ++ ) <EOL> return element <EOL> } <EOL> return defaultValue ( index ) <EOL> }

/**
 * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection.
 *
 * @sample samples.collections.Collections.Elements.elementAtOrElse
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > List < T > . elementAtOrElse ( index : Int , defaultValue : ( Int ) -> T ) : T

{ <EOL> contract { <EOL> callsInPlace ( defaultValue , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> return if ( index in <NUM_LIT:0> ..< size ) get ( index ) else defaultValue ( index ) <EOL> }

/**
 * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.
 *
 * @sample samples.collections.Collections.Elements.elementAtOrElse
 */


public fun < T > Iterable < T > . elementAtOrNull ( index : Int ) : T ?

{ <EOL> if ( this is List ) <EOL> return this . getOrNull ( index ) <EOL> if ( index < <NUM_LIT:0> ) <EOL> return null <EOL> val iterator = iterator ( ) <EOL> var count = <NUM_LIT:0> <EOL> while ( iterator . hasNext ( ) ) { <EOL> val element = iterator . next ( ) <EOL> if ( index == count ++ ) <EOL> return element <EOL> } <EOL> return null <EOL> }

/**
 * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
 *
 * @sample samples.collections.Collections.Elements.elementAtOrNull
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > List < T > . elementAtOrNull ( index : Int ) : T ?

{ <EOL> return this . getOrNull ( index ) <EOL> }

/**
 * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.
 *
 * @sample samples.collections.Collections.Elements.elementAtOrNull
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > Iterable < T > . find ( predicate : ( T ) -> Boolean ) : T ?

{ <EOL> return firstOrNull ( predicate ) <EOL> }

/**
 * Returns the first element matching the given [predicate], or `null` if no such element was found.
 *
 * @sample samples.collections.Collections.Elements.find
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > Iterable < T > . findLast ( predicate : ( T ) -> Boolean ) : T ?

{ <EOL> return lastOrNull ( predicate ) <EOL> }

/**
 * Returns the last element matching the given [predicate], or `null` if no such element was found.
 *
 * @sample samples.collections.Collections.Elements.find
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > List < T > . findLast ( predicate : ( T ) -> Boolean ) : T ?


public fun < T > Iterable < T > . first ( ) : T

{ <EOL> when ( this ) { <EOL> is List -> return this . first ( ) <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> return iterator . next ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns the first element.
 *
 * @throws NoSuchElementException if the collection is empty.
 */


public fun < T > List < T > . first ( ) : T

{ <EOL> if ( isEmpty ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> return this [ <NUM_LIT:0> ] <EOL> }

/**
 * Returns the first element.
 *
 * @throws NoSuchElementException if the list is empty.
 */


public inline fun < T > Iterable < T > . first ( predicate : ( T ) -> Boolean ) : T

{ <EOL> for ( element in this ) if ( predicate ( element ) ) return element <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> }

/**
 * Returns the first element matching the given [predicate].
 * @throws [NoSuchElementException] if no such element is found.
 */


@ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Any > Iterable < T > . firstNotNullOf ( transform : ( T ) -> R ? ) : R

{ <EOL> return firstNotNullOfOrNull ( transform ) ? : throw NoSuchElementException ( "<STR_LIT>" ) <EOL> }

/**
 * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,
 * or throws [NoSuchElementException] if no non-null value was produced.
 *
 * @sample samples.collections.Collections.Transformations.firstNotNullOf
 */


@ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R : Any > Iterable < T > . firstNotNullOfOrNull ( transform : ( T ) -> R ? ) : R ?

{ <EOL> for ( element in this ) { <EOL> val result = transform ( element ) <EOL> if ( result != null ) { <EOL> return result <EOL> } <EOL> } <EOL> return null <EOL> }

/**
 * Returns the first non-null value produced by [transform] function being applied to elements of this collection in iteration order,
 * or `null` if no non-null value was produced.
 *
 * @sample samples.collections.Collections.Transformations.firstNotNullOf
 */


public fun < T > Iterable < T > . firstOrNull ( ) : T ?

{ <EOL> when ( this ) { <EOL> is List -> { <EOL> if ( isEmpty ( ) ) <EOL> return null <EOL> else <EOL> return this [ <NUM_LIT:0> ] <EOL> } <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> return null <EOL> return iterator . next ( ) <EOL> } <EOL> } <EOL> }

/**
 * Returns the first element, or `null` if the collection is empty.
 */


public fun < T > List < T > . firstOrNull ( ) : T ?

{ <EOL> return if ( isEmpty ( ) ) null else this [ <NUM_LIT:0> ] <EOL> }

/**
 * Returns the first element, or `null` if the list is empty.
 */


public inline fun < T > Iterable < T > . firstOrNull ( predicate : ( T ) -> Boolean ) : T ?

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

/**
 * Returns the first element matching the given [predicate], or `null` if element was not found.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < T > List < T > . getOrElse ( index : Int , defaultValue : ( Int ) -> T ) : T

/**
 * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list.
 */


public fun < T > List < T > . getOrNull ( index : Int ) : T ?

{ <EOL> return if ( index in <NUM_LIT:0> ..< size ) get ( index ) else null <EOL> }

/**
 * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.
 *
 * @sample samples.collections.Collections.Elements.getOrNull
 */


public fun < @ kotlin . internal . OnlyInputTypes T > Iterable < T > . indexOf ( element : T ) : Int

{ <EOL> if ( this is List ) return this . indexOf ( element ) <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> checkIndexOverflow ( index ) <EOL> if ( element == item ) <EOL> return index <EOL> index ++ <EOL> } <EOL> return - <NUM_LIT:1> <EOL> }

/**
 * Returns first index of [element], or -1 if the collection does not contain element.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public fun < @ kotlin . internal . OnlyInputTypes T > List < T > . indexOf ( element : T ) : Int

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

/**
 * Returns first index of [element], or -1 if the list does not contain element.
 */


public inline fun < T > Iterable < T > . indexOfFirst ( predicate : ( T ) -> Boolean ) : Int

{ <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> checkIndexOverflow ( index ) <EOL> if ( predicate ( item ) ) <EOL> return index <EOL> index ++ <EOL> } <EOL> return - <NUM_LIT:1> <EOL> }

/**
 * Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element.
 */


public inline fun < T > List < T > . indexOfFirst ( predicate : ( T ) -> Boolean ) : Int

{ <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> if ( predicate ( item ) ) <EOL> return index <EOL> index ++ <EOL> } <EOL> return - <NUM_LIT:1> <EOL> }

/**
 * Returns index of the first element matching the given [predicate], or -1 if the list does not contain such element.
 */


public inline fun < T > Iterable < T > . indexOfLast ( predicate : ( T ) -> Boolean ) : Int

{ <EOL> var lastIndex = - <NUM_LIT:1> <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> checkIndexOverflow ( index ) <EOL> if ( predicate ( item ) ) <EOL> lastIndex = index <EOL> index ++ <EOL> } <EOL> return lastIndex <EOL> }

/**
 * Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element.
 */


public inline fun < T > List < T > . indexOfLast ( predicate : ( T ) -> Boolean ) : Int

{ <EOL> val iterator = this . listIterator ( size ) <EOL> while ( iterator . hasPrevious ( ) ) { <EOL> if ( predicate ( iterator . previous ( ) ) ) { <EOL> return iterator . nextIndex ( ) <EOL> } <EOL> } <EOL> return - <NUM_LIT:1> <EOL> }

/**
 * Returns index of the last element matching the given [predicate], or -1 if the list does not contain such element.
 */


public fun < T > Iterable < T > . last ( ) : T

{ <EOL> when ( this ) { <EOL> is List -> return this . last ( ) <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> var last = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) <EOL> last = iterator . next ( ) <EOL> return last <EOL> } <EOL> } <EOL> }

/**
 * Returns the last element.
 *
 * @throws NoSuchElementException if the collection is empty.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public fun < T > List < T > . last ( ) : T

{ <EOL> if ( isEmpty ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> return this [ lastIndex ] <EOL> }

/**
 * Returns the last element.
 *
 * @throws NoSuchElementException if the list is empty.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public inline fun < T > Iterable < T > . last ( predicate : ( T ) -> Boolean ) : T

{ <EOL> var last : T ? = null <EOL> var found = false <EOL> for ( element in this ) { <EOL> if ( predicate ( element ) ) { <EOL> last = element <EOL> found = true <EOL> } <EOL> } <EOL> if ( ! found ) throw NoSuchElementException ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return last as T <EOL> }

/**
 * Returns the last element matching the given [predicate].
 *
 * @throws NoSuchElementException if no such element is found.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public inline fun < T > List < T > . last ( predicate : ( T ) -> Boolean ) : T

{ <EOL> val iterator = this . listIterator ( size ) <EOL> while ( iterator . hasPrevious ( ) ) { <EOL> val element = iterator . previous ( ) <EOL> if ( predicate ( element ) ) return element <EOL> } <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> }


public fun < @ kotlin . internal . OnlyInputTypes T > Iterable < T > . lastIndexOf ( element : T ) : Int

{ <EOL> if ( this is List ) return this . lastIndexOf ( element ) <EOL> var lastIndex = - <NUM_LIT:1> <EOL> var index = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> checkIndexOverflow ( index ) <EOL> if ( element == item ) <EOL> lastIndex = index <EOL> index ++ <EOL> } <EOL> return lastIndex <EOL> }

/**
 * Returns last index of [element], or -1 if the collection does not contain element.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public fun < @ kotlin . internal . OnlyInputTypes T > List < T > . lastIndexOf ( element : T ) : Int

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

/**
 * Returns last index of [element], or -1 if the list does not contain element.
 */


public fun < T > Iterable < T > . lastOrNull ( ) : T ?

{ <EOL> when ( this ) { <EOL> is List -> return if ( isEmpty ( ) ) null else this [ size - <NUM_LIT:1> ] <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> return null <EOL> var last = iterator . next ( ) <EOL> while ( iterator . hasNext ( ) ) <EOL> last = iterator . next ( ) <EOL> return last <EOL> } <EOL> } <EOL> }

/**
 * Returns the last element, or `null` if the collection is empty.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public fun < T > List < T > . lastOrNull ( ) : T ?

{ <EOL> return if ( isEmpty ( ) ) null else this [ size - <NUM_LIT:1> ] <EOL> }

/**
 * Returns the last element, or `null` if the list is empty.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public inline fun < T > Iterable < T > . lastOrNull ( predicate : ( T ) -> Boolean ) : T ?

{ <EOL> var last : T ? = null <EOL> for ( element in this ) { <EOL> if ( predicate ( element ) ) { <EOL> last = element <EOL> } <EOL> } <EOL> return last <EOL> }

/**
 * Returns the last element matching the given [predicate], or `null` if no such element was found.
 *
 * @sample samples.collections.Collections.Elements.last
 */


public inline fun < T > List < T > . lastOrNull ( predicate : ( T ) -> Boolean ) : T ?

{ <EOL> val iterator = this . listIterator ( size ) <EOL> while ( iterator . hasPrevious ( ) ) { <EOL> val element = iterator . previous ( ) <EOL> if ( predicate ( element ) ) return element <EOL> } <EOL> return null <EOL> }


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Collection < T > . random ( ) : T

{ <EOL> return random ( Random ) <EOL> }

/**
 * Returns a random element from this collection.
 *
 * @throws NoSuchElementException if this collection is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public fun < T > Collection < T > . random ( random : Random ) : T

{ <EOL> if ( isEmpty ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> return elementAt ( random . nextInt ( size ) ) <EOL> }

/**
 * Returns a random element from this collection using the specified source of randomness.
 *
 * @throws NoSuchElementException if this collection is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < T > Collection < T > . randomOrNull ( ) : T ?

{ <EOL> return randomOrNull ( Random ) <EOL> }

/**
 * Returns a random element from this collection, or `null` if this collection is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public fun < T > Collection < T > . randomOrNull ( random : Random ) : T ?

{ <EOL> if ( isEmpty ( ) ) <EOL> return null <EOL> return elementAt ( random . nextInt ( size ) ) <EOL> }

/**
 * Returns a random element from this collection using the specified source of randomness, or `null` if this collection is empty.
 */


public fun < T > Iterable < T > . single ( ) : T

{ <EOL> when ( this ) { <EOL> is List -> return this . single ( ) <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> val single = iterator . next ( ) <EOL> if ( iterator . hasNext ( ) ) <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> return single <EOL> } <EOL> } <EOL> }

/**
 * Returns the single element, or throws an exception if the collection is empty or has more than one element.
 */


public fun < T > List < T > . single ( ) : T

{ <EOL> return when ( size ) { <EOL> <NUM_LIT:0> -> throw NoSuchElementException ( "<STR_LIT>" ) <EOL> <NUM_LIT:1> -> this [ <NUM_LIT:0> ] <EOL> else -> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Returns the single element, or throws an exception if the list is empty or has more than one element.
 */


public inline fun < T > Iterable < T > . single ( predicate : ( T ) -> Boolean ) : T

{ <EOL> var single : T ? = null <EOL> var found = false <EOL> for ( element in this ) { <EOL> if ( predicate ( element ) ) { <EOL> if ( found ) throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> single = element <EOL> found = true <EOL> } <EOL> } <EOL> if ( ! found ) throw NoSuchElementException ( "<STR_LIT>" ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return single as T <EOL> }

/**
 * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
 */


public fun < T > Iterable < T > . singleOrNull ( ) : T ?

{ <EOL> when ( this ) { <EOL> is List -> return if ( size == <NUM_LIT:1> ) this [ <NUM_LIT:0> ] else null <EOL> else -> { <EOL> val iterator = iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> return null <EOL> val single = iterator . next ( ) <EOL> if ( iterator . hasNext ( ) ) <EOL> return null <EOL> return single <EOL> } <EOL> } <EOL> }

/**
 * Returns single element, or `null` if the collection is empty or has more than one element.
 */


public fun < T > List < T > . singleOrNull ( ) : T ?

{ <EOL> return if ( size == <NUM_LIT:1> ) this [ <NUM_LIT:0> ] else null <EOL> }

/**
 * Returns single element, or `null` if the list is empty or has more than one element.
 */


public inline fun < T > Iterable < T > . singleOrNull ( predicate : ( T ) -> Boolean ) : T ?

{ <EOL> var single : T ? = null <EOL> var found = false <EOL> for ( element in this ) { <EOL> if ( predicate ( element ) ) { <EOL> if ( found ) return null <EOL> single = element <EOL> found = true <EOL> } <EOL> } <EOL> if ( ! found ) return null <EOL> return single <EOL> }

/**
 * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
 */


public fun < T > Iterable < T > . drop ( n : Int ) : List < T >

{ <EOL> require ( n >= <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> if ( n == <NUM_LIT:0> ) return toList ( ) <EOL> val list : ArrayList < T > <EOL> if ( this is Collection < * > ) { <EOL> val resultSize = size - n <EOL> if ( resultSize <= <NUM_LIT:0> ) <EOL> return emptyList ( ) <EOL> if ( resultSize == <NUM_LIT:1> ) <EOL> return listOf ( last ( ) ) <EOL> list = ArrayList < T > ( resultSize ) <EOL> if ( this is List < T > ) { <EOL> if ( this is RandomAccess ) { <EOL> for ( index in n until size ) <EOL> list . add ( this [ index ] ) <EOL> } else { <EOL> for ( item in listIterator ( n ) ) <EOL> list . add ( item ) <EOL> } <EOL> return list <EOL> } <EOL> } <EOL> else { <EOL> list = ArrayList < T > ( ) <EOL> } <EOL> var count = <NUM_LIT:0> <EOL> for ( item in this ) { <EOL> if ( count >= n ) list . add ( item ) else ++ count <EOL> } <EOL> return list . optimizeReadOnlyList ( ) <EOL> }

/**
 * Returns a list containing all elements except first [n] elements.
 *
 * @throws IllegalArgumentException if [n] is negative.
 *
 * @sample samples.collections.Collections.Transformations.drop
 */


public fun < T > List < T > . dropLast ( n : Int ) : List < T >

{ <EOL> require ( n >= <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> return take ( ( size - n ) . coerceAtLeast ( <NUM_LIT:0> ) ) <EOL> }

/**
 * Returns a list containing all elements except last [n] elements.
 *
 * @throws IllegalArgumentException if [n] is negative.
 *
 * @sample samples.collections.Collections.Transformations.drop
 */


public inline fun < T > List < T > . dropLastWhile ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> if ( ! isEmpty ( ) ) { <EOL> val iterator = listIterator ( size ) <EOL> while ( iterator . hasPrevious ( ) ) { <EOL> if ( ! predicate ( iterator . previous ( ) ) ) { <EOL> return take ( iterator . nextIndex ( ) + <NUM_LIT:1> ) <EOL> } <EOL> } <EOL> } <EOL> return emptyList ( ) <EOL> }

/**
 * Returns a list containing all elements except last elements that satisfy the given [predicate].
 *
 * @sample samples.collections.Collections.Transformations.drop
 */


public inline fun < T > Iterable < T > . dropWhile ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> var yielding = false <EOL> val list = ArrayList < T > ( ) <EOL> for ( item in this ) <EOL> if ( yielding ) <EOL> list . add ( item ) <EOL> else if ( ! predicate ( item ) ) { <EOL> list . add ( item ) <EOL> yielding = true <EOL> } <EOL> return list <EOL> }

/**
 * Returns a list containing all elements except first elements that satisfy the given [predicate].
 *
 * @sample samples.collections.Collections.Transformations.drop
 */


public inline fun < T > Iterable < T > . filter ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> return filterTo ( ArrayList < T > ( ) , predicate ) <EOL> }

/**
 * Returns a list containing only elements matching the given [predicate].
 *
 * @sample samples.collections.Collections.Filtering.filter
 */


public inline fun < T > Iterable < T > . filterIndexed ( predicate : ( index : Int , T ) -> Boolean ) : List < T >

{ <EOL> return filterIndexedTo ( ArrayList < T > ( ) , predicate ) <EOL> }

/**
 * Returns a list containing only elements matching the given [predicate].
 * @param [predicate] function that takes the index of an element and the element itself
 * and returns the result of predicate evaluation on the element.
 *
 * @sample samples.collections.Collections.Filtering.filterIndexed
 */


public inline fun < T , C : MutableCollection < in T > > Iterable < T > . filterIndexedTo ( destination : C , predicate : ( index : Int , T ) -> Boolean ) : C

{ <EOL> forEachIndexed { index , element -> <EOL> if ( predicate ( index , element ) ) destination . add ( element ) <EOL> } <EOL> return destination <EOL> }

/**
 * Appends all elements matching the given [predicate] to the given [destination].
 * @param [predicate] function that takes the index of an element and the element itself
 * and returns the result of predicate evaluation on the element.
 *
 * @sample samples.collections.Collections.Filtering.filterIndexedTo
 */


public inline fun < reified R > Iterable < * > . filterIsInstance ( ) : List < @ kotlin . internal . NoInfer R >

{ <EOL> return filterIsInstanceTo ( ArrayList < R > ( ) ) <EOL> }

/**
 * Returns a list containing all elements that are instances of specified type parameter R.
 *
 * @sample samples.collections.Collections.Filtering.filterIsInstance
 */


public inline fun < reified R , C : MutableCollection < in R > > Iterable < * > . filterIsInstanceTo ( destination : C ) : C

{ <EOL> for ( element in this ) if ( element is R ) destination . add ( element ) <EOL> return destination <EOL> }

/**
 * Appends all elements that are instances of specified type parameter R to the given [destination].
 *
 * @sample samples.collections.Collections.Filtering.filterIsInstanceTo
 */


public inline fun < T > Iterable < T > . filterNot ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> return filterNotTo ( ArrayList < T > ( ) , predicate ) <EOL> }

/**
 * Returns a list containing all elements not matching the given [predicate].
 *
 * @sample samples.collections.Collections.Filtering.filter
 */


public fun < T : Any > Iterable < T ? > . filterNotNull ( ) : List < T >

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

/**
 * Returns a list containing all elements that are not `null`.
 *
 * @sample samples.collections.Collections.Filtering.filterNotNull
 */


public fun < C : MutableCollection < in T > , T : Any > Iterable < T ? > . filterNotNullTo ( destination : C ) : C

{ <EOL> for ( element in this ) if ( element != null ) destination . add ( element ) <EOL> return destination <EOL> }

/**
 * Appends all elements that are not `null` to the given [destination].
 *
 * @sample samples.collections.Collections.Filtering.filterNotNullTo
 */


public inline fun < T , C : MutableCollection < in T > > Iterable < T > . filterNotTo ( destination : C , predicate : ( T ) -> Boolean ) : C

{ <EOL> for ( element in this ) if ( ! predicate ( element ) ) destination . add ( element ) <EOL> return destination <EOL> }

/**
 * Appends all elements not matching the given [predicate] to the given [destination].
 *
 * @sample samples.collections.Collections.Filtering.filterTo
 */


public inline fun < T , C : MutableCollection < in T > > Iterable < T > . filterTo ( destination : C , predicate : ( T ) -> Boolean ) : C

{ <EOL> for ( element in this ) if ( predicate ( element ) ) destination . add ( element ) <EOL> return destination <EOL> }

/**
 * Appends all elements matching the given [predicate] to the given [destination].
 *
 * @sample samples.collections.Collections.Filtering.filterTo
 */


public fun < T > List < T > . slice ( indices : IntRange ) : List < T >

{ <EOL> if ( indices . isEmpty ( ) ) return listOf ( ) <EOL> return this . subList ( indices . start , indices . endInclusive + <NUM_LIT:1> ) . toList ( ) <EOL> }

/**
 * Returns a list containing elements at indices in the specified [indices] range.
 */


public fun < T > List < T > . slice ( indices : Iterable < Int > ) : List < T >

{ <EOL> val size = indices . collectionSizeOrDefault ( <NUM_LIT:10> ) <EOL> if ( size == <NUM_LIT:0> ) return emptyList ( ) <EOL> val list = ArrayList < T > ( size ) <EOL> for ( index in indices ) { <EOL> list . add ( get ( index ) ) <EOL> } <EOL> return list <EOL> }

/**
 * Returns a list containing elements at specified [indices].
 */


public fun < T > Iterable < T > . take ( n : Int ) : List < T >

{ <EOL> require ( n >= <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> if ( n == <NUM_LIT:0> ) return emptyList ( ) <EOL> if ( this is Collection < T > ) { <EOL> if ( n >= size ) return toList ( ) <EOL> if ( n == <NUM_LIT:1> ) return listOf ( first ( ) ) <EOL> } <EOL> var count = <NUM_LIT:0> <EOL> val list = ArrayList < T > ( n ) <EOL> for ( item in this ) { <EOL> list . add ( item ) <EOL> if ( ++ count == n ) <EOL> break <EOL> } <EOL> return list . optimizeReadOnlyList ( ) <EOL> }

/**
 * Returns a list containing first [n] elements.
 *
 * @throws IllegalArgumentException if [n] is negative.
 *
 * @sample samples.collections.Collections.Transformations.take
 */


public fun < T > List < T > . takeLast ( n : Int ) : List < T >

{ <EOL> require ( n >= <NUM_LIT:0> ) { "<STR_LIT>" } <EOL> if ( n == <NUM_LIT:0> ) return emptyList ( ) <EOL> val size = size <EOL> if ( n >= size ) return toList ( ) <EOL> if ( n == <NUM_LIT:1> ) return listOf ( last ( ) ) <EOL> val list = ArrayList < T > ( n ) <EOL> if ( this is RandomAccess ) { <EOL> for ( index in size - n until size ) <EOL> list . add ( this [ index ] ) <EOL> } else { <EOL> for ( item in listIterator ( size - n ) ) <EOL> list . add ( item ) <EOL> } <EOL> return list <EOL> }

/**
 * Returns a list containing last [n] elements.
 *
 * @throws IllegalArgumentException if [n] is negative.
 *
 * @sample samples.collections.Collections.Transformations.take
 */


public inline fun < T > List < T > . takeLastWhile ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> if ( isEmpty ( ) ) <EOL> return emptyList ( ) <EOL> val iterator = listIterator ( size ) <EOL> while ( iterator . hasPrevious ( ) ) { <EOL> if ( ! predicate ( iterator . previous ( ) ) ) { <EOL> iterator . next ( ) <EOL> val expectedSize = size - iterator . nextIndex ( ) <EOL> if ( expectedSize == <NUM_LIT:0> ) return emptyList ( ) <EOL> return ArrayList < T > ( expectedSize ) . apply { <EOL> while ( iterator . hasNext ( ) ) <EOL> add ( iterator . next ( ) ) <EOL> } <EOL> } <EOL> } <EOL> return toList ( ) <EOL> }

/**
 * Returns a list containing last elements satisfying the given [predicate].
 *
 * @sample samples.collections.Collections.Transformations.take
 */


public inline fun < T > Iterable < T > . takeWhile ( predicate : ( T ) -> Boolean ) : List < T >

{ <EOL> val list = ArrayList < T > ( ) <EOL> for ( item in this ) { <EOL> if ( ! predicate ( item ) ) <EOL> break <EOL> list . add ( item ) <EOL> } <EOL> return list <EOL> }

/**
 * Returns a list containing first elements satisfying the given [predicate].
 *
 * @sample samples.collections.Collections.Transformations.take
 */


public expect fun < T > MutableList < T > . reverse ( ) : Unit

/**
 * Reverses elements in the list in-place.
 */


public fun < T > Iterable < T > . reversed ( ) : List < T >

{ <EOL> if ( this is Collection && size <= <NUM_LIT:1> ) return toList ( ) <EOL> val list = toMutableList ( ) <EOL> list . reverse ( ) <EOL> return list <EOL> }

/**
 * Returns a list with elements in reversed order.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public fun < T > MutableList < T > . shuffle ( random : Random ) : Unit

{ <EOL> for ( i in lastIndex downTo <NUM_LIT:1> ) { <EOL> val j = random . nextInt ( i + <NUM_LIT:1> ) <EOL> this [ j ] = this . set ( i , this [ j ] ) <EOL> } <EOL> }

/**
 * Randomly shuffles elements in this list in-place using the specified [random] instance as the source of randomness.
 *
 * See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
 */


public inline fun < T , R : Comparable < R > > MutableList < T > . sortBy ( crossinline selector : ( T ) -> R ? ) : Unit

{ <EOL> if ( size > <NUM_LIT:1> ) sortWith ( compareBy ( selector ) ) <EOL> }

/**
 * Sorts elements in the list in-place according to natural sort order of the value returned by specified [selector] function.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public inline fun < T , R : Comparable < R > > MutableList < T > . sortByDescending ( crossinline selector : ( T ) -> R ? ) : Unit

{ <EOL> if ( size > <NUM_LIT:1> ) sortWith ( compareByDescending ( selector ) ) <EOL> }

/**
 * Sorts elements in the list in-place descending according to natural sort order of the value returned by specified [selector] function.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public fun < T : Comparable < T > > MutableList < T > . sortDescending ( ) : Unit

{ <EOL> sortWith ( reverseOrder ( ) ) <EOL> }

/**
 * Sorts elements in the list in-place descending according to their natural sort order.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public fun < T : Comparable < T > > Iterable < T > . sorted ( ) : List < T >

{ <EOL> if ( this is Collection ) { <EOL> if ( size <= <NUM_LIT:1> ) return this . toList ( ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return ( toTypedArray < Comparable < T > > ( ) as Array < T > ) . apply { sort ( ) } . asList ( ) <EOL> } <EOL> return toMutableList ( ) . apply { sort ( ) } <EOL> }

/**
 * Returns a list of all elements sorted according to their natural sort order.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public inline fun < T , R : Comparable < R > > Iterable < T > . sortedBy ( crossinline selector : ( T ) -> R ? ) : List < T >

{ <EOL> return sortedWith ( compareBy ( selector ) ) <EOL> }

/**
 * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 *
 * @sample samples.collections.Collections.Sorting.sortedBy
 */


public inline fun < T , R : Comparable < R > > Iterable < T > . sortedByDescending ( crossinline selector : ( T ) -> R ? ) : List < T >

{ <EOL> return sortedWith ( compareByDescending ( selector ) ) <EOL> }

/**
 * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public fun < T : Comparable < T > > Iterable < T > . sortedDescending ( ) : List < T >

{ <EOL> return sortedWith ( reverseOrder ( ) ) <EOL> }

/**
 * Returns a list of all elements sorted descending according to their natural sort order.
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public fun < T > Iterable < T > . sortedWith ( comparator : Comparator < in T > ) : List < T >

{ <EOL> if ( this is Collection ) { <EOL> if ( size <= <NUM_LIT:1> ) return this . toList ( ) <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return ( toTypedArray < Any ? > ( ) as Array < T > ) . apply { sortWith ( comparator ) } . asList ( ) <EOL> } <EOL> return toMutableList ( ) . apply { sortWith ( comparator ) } <EOL> }

/**
 * Returns a list of all elements sorted according to the specified [comparator].
 *
 * The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
 */


public fun Collection < Boolean > . toBooleanArray ( ) : BooleanArray

{ <EOL> val result = BooleanArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Boolean containing all of the elements of this collection.
 */


public fun Collection < Byte > . toByteArray ( ) : ByteArray

{ <EOL> val result = ByteArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Byte containing all of the elements of this collection.
 */


public fun Collection < Char > . toCharArray ( ) : CharArray

{ <EOL> val result = CharArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Char containing all of the elements of this collection.
 */


public fun Collection < Double > . toDoubleArray ( ) : DoubleArray

{ <EOL> val result = DoubleArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Double containing all of the elements of this collection.
 */


public fun Collection < Float > . toFloatArray ( ) : FloatArray

{ <EOL> val result = FloatArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Float containing all of the elements of this collection.
 */


public fun Collection < Int > . toIntArray ( ) : IntArray

{ <EOL> val result = IntArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Int containing all of the elements of this collection.
 */


public fun Collection < Long > . toLongArray ( ) : LongArray

{ <EOL> val result = LongArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Long containing all of the elements of this collection.
 */


public fun Collection < Short > . toShortArray ( ) : ShortArray

{ <EOL> val result = ShortArray ( size ) <EOL> var index = <NUM_LIT:0> <EOL> for ( element in this ) <EOL> result [ index ++ ] = element <EOL> return result <EOL> }

/**
 * Returns an array of Short containing all of the elements of this collection.
 */


public inline fun < T , K , V > Iterable < T > . associate ( transform : ( T ) -> Pair < K , V > ) : Map < K , V >

{ <EOL> val capacity = mapCapacity ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) . coerceAtLeast ( <NUM_LIT:16> ) <EOL> return associateTo ( LinkedHashMap < K , V > ( capacity ) , transform ) <EOL> }

/**
 * Returns a [Map] containing key-value pairs provided by [transform] function
 * applied to elements of the given collection.
 *
 * If any of two pairs would have the same key the last one gets added to the map.
 *
 * The returned map preserves the entry iteration order of the original collection.
 *
 * @sample samples.collections.Collections.Transformations.associate
 */


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

{ <EOL> val capacity = mapCapacity ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) . coerceAtLeast ( <NUM_LIT:16> ) <EOL> return associateByTo ( LinkedHashMap < K , T > ( capacity ) , keySelector ) <EOL> }

/**
 * Returns a [Map] containing the elements from the given collection indexed by the key
 * returned from [keySelector] function applied to each element.
 *
 * 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 collection.
 *
 * @sample samples.collections.Collections.Transformations.associateBy
 */


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

{ <EOL> val capacity = mapCapacity ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) . coerceAtLeast ( <NUM_LIT:16> ) <EOL> return associateByTo ( LinkedHashMap < K , V > ( capacity ) , keySelector , valueTransform ) <EOL> }

/**
 * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given collection.
 *
 * 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 collection.
 *
 * @sample samples.collections.Collections.Transformations.associateByWithValueTransform
 */


public inline fun < T , K , M : MutableMap < in K , in T > > Iterable < 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 collection
 * 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.
 *
 * @sample samples.collections.Collections.Transformations.associateByTo
 */


public inline fun < T , K , V , M : MutableMap < in K , in V > > Iterable < 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 collection.
 *
 * If any two elements would have the same key returned by [keySelector] the last one gets added to the map.
 *
 * @sample samples.collections.Collections.Transformations.associateByToWithValueTransform
 */


public inline fun < T , K , V , M : MutableMap < in K , in V > > Iterable < 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 collection.
 *
 * If any of two pairs would have the same key the last one gets added to the map.
 *
 * @sample samples.collections.Collections.Transformations.associateTo
 */


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

{ <EOL> val result = LinkedHashMap < K , V > ( mapCapacity ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) . coerceAtLeast ( <NUM_LIT:16> ) ) <EOL> return associateWithTo ( result , valueSelector ) <EOL> }

/**
 * Returns a [Map] where keys are elements from the given collection 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 collection.
 *
 * @sample samples.collections.Collections.Transformations.associateWith
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public inline fun < K , V , M : MutableMap < in K , in V > > Iterable < 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 collection,
 * 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.
 *
 * @sample samples.collections.Collections.Transformations.associateWithTo
 */


public fun < T , C : MutableCollection < in T > > Iterable < 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.
 */


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

{ <EOL> return toCollection ( HashSet < T > ( mapCapacity ( collectionSizeOrDefault ( <NUM_LIT:12> ) ) ) ) <EOL> }

/**
 * Returns a new [HashSet] of all elements.
 */


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

{ <EOL> if ( this is Collection ) { <EOL> return when ( size ) { <EOL> <NUM_LIT:0> -> emptyList ( ) <EOL> <NUM_LIT:1> -> listOf ( if ( this is List ) get ( <NUM_LIT:0> ) else iterator ( ) . next ( ) ) <EOL> else -> this . toMutableList ( ) <EOL> } <EOL> } <EOL> return this . toMutableList ( ) . optimizeReadOnlyList ( ) <EOL> }

/**
 * Returns a [List] containing all elements.
 */


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

{ <EOL> if ( this is Collection < T > ) <EOL> return this . toMutableList ( ) <EOL> return toCollection ( ArrayList < T > ( ) ) <EOL> }

/**
 * Returns a new [MutableList] filled with all elements of this collection.
 */


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

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


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

{ <EOL> if ( this is Collection ) { <EOL> return when ( size ) { <EOL> <NUM_LIT:0> -> emptySet ( ) <EOL> <NUM_LIT:1> -> setOf ( if ( this is List ) this [ <NUM_LIT:0> ] else iterator ( ) . next ( ) ) <EOL> else -> toCollection ( LinkedHashSet < T > ( mapCapacity ( size ) ) ) <EOL> } <EOL> } <EOL> return toCollection ( LinkedHashSet < T > ( ) ) . optimizeReadOnlySet ( ) <EOL> }

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


public inline fun < T , R > Iterable < T > . flatMap ( transform : ( T ) -> Iterable < R > ) : List < R >

{ <EOL> return flatMapTo ( ArrayList < R > ( ) , transform ) <EOL> }

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection.
 *
 * @sample samples.collections.Collections.Transformations.flatMap
 */


@ 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 > Iterable < T > . flatMap ( transform : ( T ) -> Sequence < R > ) : List < R >


@ 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 > Iterable < T > . flatMapIndexed ( transform : ( index : Int , T ) -> Iterable < R > ) : List < R >

{ <EOL> return flatMapIndexedTo ( ArrayList < R > ( ) , transform ) <EOL> }

/**
 * Returns a single list of all elements yielded from results of [transform] function being invoked on each element
 * and its index in the original collection.
 *
 * @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> @ kotlin . internal . InlineOnly <EOL> public inline fun < T , R > Iterable < T > . flatMapIndexed ( transform : ( index : Int , T ) -> Sequence < R > ) : List < R >


@ 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 > > Iterable < 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 collection, to the given [destination].
 */


@ 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 > > Iterable < T > . flatMapIndexedTo ( destination : C , transform : ( index : Int , T ) -> Sequence < R > ) : C


public inline fun < T , R , C : MutableCollection < in R > > Iterable < 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 collection, to the given [destination].
 */


@ 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 > > Iterable < T > . flatMapTo ( destination : C , transform : ( T ) -> Sequence < R > ) : C


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

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

/**
 * Groups elements of the original collection 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 collection.
 *
 * @sample samples.collections.Collections.Transformations.groupBy
 */


public inline fun < T , K , V > Iterable < 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 collection
 * 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 collection.
 *
 * @sample samples.collections.Collections.Transformations.groupByKeysAndValues
 */


public inline fun < T , K , M : MutableMap < in K , MutableList < T > > > Iterable < 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 collection 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.
 *
 * @sample samples.collections.Collections.Transformations.groupBy
 */


public inline fun < T , K , V , M : MutableMap < in K , MutableList < V > > > Iterable < 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 collection
 * 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.
 *
 * @sample samples.collections.Collections.Transformations.groupByKeysAndValues
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < T , K > Iterable < 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 collection to be used later with one of group-and-fold operations
 * using the specified [keySelector] function to extract a key from each element.
 *
 * @sample samples.collections.Grouping.groupingByEachCount
 */


public inline fun < T , R > Iterable < T > . map ( transform : ( T ) -> R ) : List < R >

{ <EOL> return mapTo ( ArrayList < R > ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) , transform ) <EOL> }

/**
 * Returns a list containing the results of applying the given [transform] function
 * to each element in the original collection.
 *
 * @sample samples.collections.Collections.Transformations.map
 */


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

{ <EOL> return mapIndexedTo ( ArrayList < R > ( collectionSizeOrDefault ( <NUM_LIT:10> ) ) , transform ) <EOL> }

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


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

{ <EOL> return mapIndexedNotNullTo ( ArrayList < R > ( ) , transform ) <EOL> }

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


public inline fun < T , R : Any , C : MutableCollection < in R > > Iterable < 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 collection
 * 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.
 */