public fun < T > ( suspend ( ) -> T ) . asFlow ( ) : Flow < T >

/**
 * Creates a _cold_ flow that produces a single value from the given functional type.
 *
 * Example of usage:
 *
 * ```
 * suspend fun remoteCall(): R = ...
 * fun remoteCallFlow(): Flow<R> = ::remoteCall.asFlow()
 * ```
 */


public fun < T > Iterable < T > . asFlow ( ) : Flow < T >

= flow { <EOL> forEach { value -> <EOL> emit ( value ) <EOL> } <EOL> }

/**
 * Creates a _cold_ flow that produces values from the given iterable.
 */


public fun < T > Iterator < T > . asFlow ( ) : Flow < T >

/**
 * Creates a _cold_ flow that produces values from the given iterator.
 */


public fun < T > Sequence < T > . asFlow ( ) : Flow < T >

/**
 * Creates a _cold_ flow that produces values from the given sequence.
 */


public fun < T > flowOf ( vararg elements : T ) : Flow < T >

= flow { <EOL> for ( element in elements ) { <EOL> emit ( element ) <EOL> } <EOL> }

/**
 * Creates a flow that produces values from the specified `vararg`-arguments.
 *
 * Example of usage:
 *
 * ```
 * flowOf(1, 2, 3)
 * ```
 */


public fun < T > flowOf ( value : T ) : Flow < T >

= flow { <EOL> emit ( value ) <EOL> }

/**
 * Creates a flow that produces the given [value].
 */


public fun < T > emptyFlow ( ) : Flow < T >

= EmptyFlow


public fun < T > Array < T > . asFlow ( ) : Flow < T >

/**
 * Creates a _cold_ flow that produces values from the given array.
 * The flow being _cold_ means that the array components are read every time a terminal operator is applied
 * to the resulting flow.
 */


public fun IntArray . asFlow ( ) : Flow < Int >

/**
 * Creates a _cold_ flow that produces values from the array.
 * The flow being _cold_ means that the array components are read every time a terminal operator is applied
 * to the resulting flow.
 */


public fun LongArray . asFlow ( ) : Flow < Long >


public fun IntRange . asFlow ( ) : Flow < Int >

/**
 * Creates a flow that produces values from the range.
 */


public fun LongRange . asFlow ( ) : Flow < Long >


public fun < T > channelFlow ( @ BuilderInference block : suspend ProducerScope < T > . ( ) -> Unit ) : Flow < T >

= <EOL> ChannelFlowBuilder ( block )

/**
 * Creates an instance of a _cold_ [Flow] with elements that are sent to a [SendChannel]
 * provided to the builder's [block] of code via [ProducerScope]. It allows elements to be
 * produced by code that is running in a different context or concurrently.
 * The resulting flow is _cold_, which means that [block] is called every time a terminal operator
 * is applied to the resulting flow.
 *
 * This builder ensures thread-safety and context preservation, thus the provided [ProducerScope] can be used
 * concurrently from different contexts.
 * The resulting flow completes as soon as the code in the [block] and all its children completes.
 * Use [awaitClose] as the last statement to keep it running.
 * A more detailed example is provided in the documentation of [callbackFlow].
 *
 * A channel with the [default][Channel.BUFFERED] buffer size is used. Use the [buffer] operator on the
 * resulting flow to specify a user-defined value and to control what happens when data is produced faster
 * than consumed, i.e. to control the back-pressure behavior.
 *
 * Adjacent applications of [channelFlow], [flowOn], [buffer], and [produceIn] are
 * always fused so that only one properly configured channel is used for execution.
 *
 * Examples of usage:
 *
 * ```
 * fun <T> Flow<T>.merge(other: Flow<T>): Flow<T> = channelFlow {
 * // collect from one coroutine and send it
 * launch {
 * collect { send(it) }
 * }
 * // collect and send from this coroutine, too, concurrently
 * other.collect { send(it) }
 * }
 *
 * fun <T> contextualFlow(): Flow<T> = channelFlow {
 * // send from one coroutine
 * launch(Dispatchers.IO) {
 * send(computeIoValue())
 * }
 * // send from another coroutine, concurrently
 * launch(Dispatchers.Default) {
 * send(computeCpuValue())
 * }
 * }
 * ```
 */


public fun < T > callbackFlow ( @ BuilderInference block : suspend ProducerScope < T > . ( ) -> Unit ) : Flow < T >

= CallbackFlowBuilder ( block )

/**
 * Creates an instance of a _cold_ [Flow] with elements that are sent to a [SendChannel]
 * provided to the builder's [block] of code via [ProducerScope]. It allows elements to be
 * produced by code that is running in a different context or concurrently.
 *
 * The resulting flow is _cold_, which means that [block] is called every time a terminal operator
 * is applied to the resulting flow.
 *
 * This builder ensures thread-safety and context preservation, thus the provided [ProducerScope] can be used
 * from any context, e.g. from a callback-based API.
 * The resulting flow completes as soon as the code in the [block] completes.
 * [awaitClose] should be used to keep the flow running, otherwise the channel will be closed immediately
 * when block completes.
 * [awaitClose] argument is called either when a flow consumer cancels the flow collection
 * or when a callback-based API invokes [SendChannel.close] manually and is typically used
 * to cleanup the resources after the completion, e.g. unregister a callback.
 * Using [awaitClose] is mandatory in order to prevent memory leaks when the flow collection is cancelled,
 * otherwise the callback may keep running even when the flow collector is already completed.
 * To avoid such leaks, this method throws [IllegalStateException] if block returns, but the channel
 * is not closed yet.
 *
 * A channel with the [default][Channel.BUFFERED] buffer size is used. Use the [buffer] operator on the
 * resulting flow to specify a user-defined value and to control what happens when data is produced faster
 * than consumed, i.e. to control the back-pressure behavior.
 *
 * Adjacent applications of [callbackFlow], [flowOn], [buffer], and [produceIn] are
 * always fused so that only one properly configured channel is used for execution.
 *
 * Example of usage that converts a multi-shot callback API to a flow.
 * For single-shot callbacks use [suspendCancellableCoroutine].
 *
 * ```
 * fun flowFrom(api: CallbackBasedApi): Flow<T> = callbackFlow {
 * val callback = object : Callback { // Implementation of some callback interface
 * override fun onNextValue(value: T) {
 * // To avoid blocking you can configure channel capacity using
 * // either buffer(Channel.CONFLATED) or buffer(Channel.UNLIMITED) to avoid overfill
 * trySendBlocking(value)
 * .onFailure { throwable ->
 * // Downstream has been cancelled or failed, can log here
 * }
 * }
 * override fun onApiError(cause: Throwable) {
 * cancel(CancellationException("API Error", cause))
 * }
 * override fun onCompleted() = channel.close()
 * }
 * api.register(callback)
 * /*
 * * Suspends until either 'onCompleted'/'onApiError' from the callback is invoked
 * * or flow collector is cancelled (e.g. by 'take(1)' or because a collector's coroutine was cancelled).
 * * In both cases, callback will be properly unregistered.
 * */
 * awaitClose { api.unregister(callback) }
 * }
 * ```
 *
 * > The callback `register`/`unregister` methods provided by an external API must be thread-safe, because
 * > `awaitClose` block can be called at any time due to asynchronous nature of cancellation, even
 * > concurrently with the call of the callback.
 */


override fun printBuildReport ( data : ReadableFileReportData < B , P > , outputFile : File )

{ <EOL> outputFile . bufferedWriter ( ) . use { writer -> <EOL> Printer ( writer ) . printBuildReport ( data , printMetrics ) { compileStatisticsData -> <EOL> printCustomTaskMetrics ( compileStatisticsData , this ) <EOL> } <EOL> } <EOL> }

/**
 * Prints general build information, sum up compile metrics and detailed task and transform information.
 *
 * BuildExecutionData / BuildOperationRecord contains data for both tasks and transforms.
 * We still use the term "tasks" because saying "tasks/transforms" is a bit verbose and "build operations" may sound a bit unfamiliar.
 */


public fun Sink . asNSOutputStream ( ) : NSOutputStream

= SinkNSOutputStream ( this )

/**
 * Returns an output stream that writes to this sink. Closing the stream will also close this sink.
 *
 * The stream supports both polling and run-loop scheduling, please check
 * [Apple's documentation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Streams/Articles/PollingVersusRunloop.html)
 * for information about stream events handling.
 *
 * The stream does not implement initializers
 * ([NSOutputStream.initToBuffer](https://developer.apple.com/documentation/foundation/nsoutputstream/1410805-inittobuffer),
 * [NSOutputStream.initToMemory](https://developer.apple.com/documentation/foundation/nsoutputstream/1409909-inittomemory),
 * [NSOutputStream.initWithURL](https://developer.apple.com/documentation/foundation/nsoutputstream/1414446-initwithurl),
 * [NSOutputStream.initToFileAtPath](https://developer.apple.com/documentation/foundation/nsoutputstream/1416367-inittofileatpath)),
 * their use will result in a runtime error.
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesApple.asStream
 */


inline fun < reified T : Any > empty ( vararg shape : Int , order : Order = Order . C ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( shape , T :: class . javaObjectType , order ) )

/**
 * Return a new array of given shape and T type, without initializing entries.
 *
 * @param shape of the empty array.
 * @param order see [Order].
 * @return [KtNDArray] of uninitialized data of the given [shape], [T], [order].
 */


inline fun < reified T : Any > emptyLike ( prototype : KtNDArray < T > , order : Order = Order . K , subok : Boolean = true , shape : IntArray ? = null ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( prototype , T :: class . javaObjectType ) , order = order , subok = subok , shape = shape )

/**
 * Return a new array with the same shape and T type as a given array.
 *
 * @param prototype the shape and type of prototype define same attributes of the returned array.
 * @param order see [Order].
 * @param subok if *true*, then sub-classes will be passed-through,
 * otherwise the returned array will be forced to be a base-class array (default).
 * @param shape overrides the shape of the result.
 * @return [KtNDArray] of uninitialized data with the same shape and type as prototype.
 */


inline fun < reified T : Any > eye ( n : Int , m : Int ? = null , k : Int = <NUM_LIT:0> , order : Order = Order . C ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( n , m ? : none , k , T :: class . javaObjectType ) , order = order )

/**
 * Return a 2-D array with ones on the diagonal and zeros elsewhere.
 *
 * @param n number of rows in the output.
 * @param m number of columns in the output. If null, defaults to [n].
 * @param k index of the diagonal.
 * @param order see [Order]
 * @return [KtNDArray] where all elements are equal to zero, except for the k-th diagonal,
 * whose values are equal to one.
 * @see identity
 * @see diag
 */


inline fun < reified T : Any > identity ( n : Int ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( n , T :: class . javaObjectType ) )

/**
 * Return the identity array.
 *
 * @param n number of rows and columns in *n*x*n* output.
 * @return 2-D [KtNDArray] *n*x*n* with its main diagonal set to one, and all other elements 0.
 */


inline fun < reified T : Any > ones ( vararg shape : Int , order : Order = Order . C ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( shape , T :: class . javaObjectType ) , order = order )

/**
 * Return a new array of given shape and T type, filled with ones.
 *
 * @param shape of the new array.
 * @param order see [Order]
 * @return [KtNDArray] of ones with the given [shape], type [T] and [order].
 * @see onesLike
 * @see empty
 * @see zeros
 * @see full
 */


inline fun < reified T : Any > onesLike ( prototype : KtNDArray < T > , order : Order = Order . K , subok : Boolean = true , shape : IntArray ? = null ) : KtNDArray < T >

/**
 * Return an array of ones with the same shape and T type as a given array.
 *
 * @param prototype the shape and type of prototype define same attributes of the returned array.
 * @param order see [Order]
 * @param subok if *true*, then sub-classes will be passed-through,
 * otherwise the returned array will be forced to be a base-class array (default).
 * @param shape overrides the shape of the result.
 * @return [KtNDArray] of ones with the same shape and type as prototype.
 * @see emptyLike
 * @see zerosLike
 * @see fullLike
 * @see ones
 */


inline fun < reified T : Any > zeros ( vararg shape : Int , order : Order = Order . C ) : KtNDArray < T >

/**
 * Return a new array of given shape and T type, filled with zeros.
 *
 * @param shape shape of the new array.
 * @param order see [Order]
 * @return Array of zeros with the given [shape], type [T] and [order].
 * @see zerosLike
 * @see empty
 * @see ones
 * @see full
 */


inline fun < reified T : Any > zerosLike ( prototype : KtNDArray < T > , order : Order = Order . K , subok : Boolean = true , shape : IntArray ? = null ) : KtNDArray < T >

/**
 * Return an array of zeros with the same shape and T type as a given array.
 *
 * @param prototype the shape and type of prototype define same attributes of the returned array.
 * @param order see [Order]
 * @param subok if *true*, then sub-classes will be passed-through,
 * otherwise the returned array will be forced to be a base-class array (default).
 * @param shape overrides the shape of the result.
 * @return Array of zeros with the same shape and type as [prototype].
 * @see emptyLike
 * @see onesLike
 * @see fullLike
 * @see zeros
 */


inline fun < reified T : Any > full ( shape : IntArray , fillValue : T , order : Order = Order . C ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( shape , fillValue , T :: class . javaObjectType ) , order = order )

/**
 * Return a new array of given shape and T type, filled with fill_value.
 *
 * @param shape of the new array.
 * @param order see [Order]
 * @return [KtNDArray] of [fillValue] the given [shape], [T] and [order].
 * @see fullLike
 * @see empty
 * @see ones
 * @see zeros
 */


inline fun < reified T : Any > fullLike ( prototype : KtNDArray < T > , fillValue : T , order : Order = Order . K , subok : Boolean = true , shape : IntArray ? = null ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( prototype , fillValue , T :: class . javaObjectType ) , order = order , subok = subok , shape = shape )

/**
 * Return a full array with the same shape and T type as a given array.
 *
 * @param prototype the shape and type of prototype define same attributes of the returned array.
 * @param fillValue fill value.
 * @param order see [Order]
 * @return [KtNDArray] of [fillValue] with the same [shape] and type [T] as [prototype].
 * @see emptyLike
 * @see onesLike
 * @see zerosLike
 * @see full
 */


inline fun < reified T : Any > array ( arr : Array < T > , order : Order = Order . K , subok : Boolean = false , ndmin : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( arr , T :: class . javaObjectType ) , order = order , subok = subok , ndmin = ndmin )

/**
 * Create an flattened array.
 *
 * @param arr any [Array].
 * @param order specify the memory layout of the array.
 * @param subok if *true*, then sub-classes will be passed-through,
 * otherwise the returned array will be forced to be a base-class array (default).
 * @param ndmin specifies the minimum number of dimensions that the resulting array should have.
 * @return [KtNDArray]
 * @see emptyLike
 * @see onesLike
 * @see zerosLike
 * @see fullLike
 * @see empty
 * @see ones
 * @see zeros
 * @see full
 */


inline fun < reified T : Any > array ( arr : List < Any > , order : Order = Order . K , subok : Boolean = false , ndmin : Int = <NUM_LIT:0> ) : KtNDArray < T >

/**
 * Create an array.
 * Dimension is set by nesting lists.
 * > Note that the [List] type is [Any]; use the same type everywhere.
 *
 * @param arr list of any.
 * @param order specify the memory layout of the array.
 * @param subok if *true*, then sub-classes will be passed-through,
 * otherwise the returned array will be forced to be a base-class array (default).
 * @param ndmin specifies the minimum number of dimensions that the resulting array should have.
 * @return [KtNDArray]
 * @see emptyLike
 * @see onesLike
 * @see zerosLike
 * @see fullLike
 * @see empty
 * @see ones
 * @see zeros
 * @see full
 */


fun < T : Any > copy ( a : KtNDArray < T > , order : Order = Order . K ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( a ) , order = order )

/**
 * Return an array copy of the given object.
 *
 * @param a input data.
 * @param order see [Order]
 * @return Array interpretation of [a].
 */


inline fun < reified T : Any > fromfile ( file : File , count : Int = - <NUM_LIT:1> , sep : String = "<STR_LIT>" , offset : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( file . absolutePath , T :: class . javaObjectType , count , sep , offset ) )

/**
 * Construct an array from data in a text or binary file.
 *
 * @param file open file object.
 * @param count number of items to read. -1 means all items.
 * @param sep separator between items if file is a text file.
 * @param offset (in bytes) from the file's current position.
 * @see loadtxt
 */


inline fun < reified T : Any > fromfile ( file : String , count : Int = - <NUM_LIT:1> , sep : String = "<STR_LIT>" , offset : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( file , T :: class . javaObjectType , count , sep , offset ) )


inline fun < reified T : Any > fromstring ( string : String , count : Int = - <NUM_LIT:1> , sep : String ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( string , T :: class . javaObjectType , count , sep ) )

/**
 * A new 1-D array initialized from text data in a string.
 *
 * @param string containing the data.
 * @param count number of items to read. -1 means all items.
 * @param sep separatoring numbers in the data.
 * @see fromfile
 */


inline fun < reified T : Any > loadtxt ( fname : String , comments : String = "<STR_LIT:#>" , delimiter : String ? = null , converters : Map < Any , Any > ? = null , skiprows : Int = <NUM_LIT:0> , usecols : IntArray ? = null , unpack : Boolean = false , ndmin : Int = <NUM_LIT:0> , encoding : String = "<STR_LIT>" , max_rows : Int ? = null ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( fname , T :: class . javaObjectType , comments , delimiter ? : none ) )

/**
 * Load data from a text file.
 *
 * @param fname filename.
 * @param comments the characters used to indicate the start of a comment.
 * @param delimiter the string used to separate values.
 * @param converters A [Map] mapping column number to a function that will parse the column string in the desired value.
 * Not impl.
 * @param skiprows skip the first lines.
 * @param usecols which columns to read.
 * @return [KtNDArray] from the text file.
 * @see fromstring
 */


inline fun < reified T : Number > arange ( start : Number , stop : Number , step : Number ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( start , stop , step , T :: class . javaObjectType ) )

/**
 * Return evenly spaced values within a given interval.
 * @param start start of interval.
 * @param stop end of interval.
 * @param step spacing between values.
 * @return new [KtNDArray] of type [T].
 */


inline fun < reified T : Number > linspace ( start : Number , stop : Number , num : Int = <NUM_LIT> , endpoint : Boolean = true , retstep : Boolean = false , axis : Int = <NUM_LIT:0> ) : KtNDArray < T >

= callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( start , stop , num , endpoint , retstep , T :: class . javaObjectType , axis ) )

/**
 * Return evenly spaced numbers over a specified interval.
 *
 * @param start the starting value of the sequence.
 * @param stop the end value of the sequence.
 * @param num number of samples to generate. Default is 50.
 * @param endpoint if *true*, [stop] is the last sample.
 * @param retstep if *true*, return (samples, step).
 * @param axis the axis in the result to store the samples.
 * @return There are [num] equally spaced samples in the closed interval ```[start, stop]```.
 */


inline fun < reified T : Number > geomspace ( start : Number , stop : Number , num : Int = <NUM_LIT> , endpoint : Boolean = true , axis : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( start , stop , num , endpoint , T :: class . javaObjectType , axis ) )

/**
 * Return numbers spaced evenly on a geometric progression.
 *
 * @param start the starting value of the sequence.
 * @param stop the final value of the sequence.
 * @param num number of samples to generate. Default is 50.
 * @param endpoint if *true*, [stop] is the las sample.
 * @param axis in the result to store the samples.
 * @return [num] samples, equally spaced on a log scale.
 * @see logspace
 * @see linspace
 * @see arange
 */


fun < T : Number > diag ( vararg v : T , k : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( v , k ) )

/**
 * Extract a diagonal or construct a diagonal array.
 * @param v values.
 * @param k diagonal
 * @return [KtNDArray]
 * @see diagflat
 * @see triu
 * @see tril
 */


fun < T : Number > diag ( v : KtNDArray < T > , k : Int = <NUM_LIT:0> ) : KtNDArray < T >

/**
 * @param v if [v] a 2-D array, return a copy of its k-th diagonal. If [v] is a 1-D array, return a 2-D array
 * with [v] on the [k]-th diagonal
 */


fun < T : Number > diagflat ( v : KtNDArray < T > , k : Int = <NUM_LIT:0> ) : KtNDArray < T >

/**
 * Create a 2-D array with the flattened input as a diagonal.
 * @param v input data.
 * @param k diagonal.
 * @return 2-D output [KtNDArray]
 * @see diag
 */


inline fun < reified T : Any > tri ( n : Int , m : Int ? = null , k : Int = <NUM_LIT:0> ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( n , m ? : none , k , T :: class . javaObjectType ) )

/**
 * An array with ones at and below the given diagonal and zeros elsewhere.
 *
 * @param n number of rows in the array.
 * @param m number of columns in the array. By default, [m] is taken equal to [n].
 * @param k the sub-diagonal at and below which the array is filled.
 * @return Array with its lower triangle filled with ones and zero elsewhere.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> fun tril ( m : List < List < Byte > > , k : Int = <NUM_LIT:0> ) : KtNDArray < Long >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( m , k ) )

/**
 * Lower triangle of an array.
 *
 * @param m input array.
 * @param k diagonal above which to zero elements.
 * @return Return a copy of an array with elements above the k-th diagonal zeroed.
 * @see triu
 */


@ JvmName ( "<STR_LIT>" ) <EOL> fun triu ( m : List < List < Byte > > , k : Int = <NUM_LIT:0> ) : KtNDArray < Long >

/**
 * Upper triangle of an array.
 *
 * @param m input array.
 * @param k diagonal above which to zeros elements.
 * @return Return a copy of a matrix with elements below the k-th diagonal zeroed.
 * @see tril
 */


fun < T : Number > vander ( x : KtNDArray < T > , n : Int ? = null , increasing : Boolean = false ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( x , n ? : none , increasing ) )

/**
 * Generate a Vandermonde matrix.
 *
 * @param x 1-D input array.
 * @param n number of columns in the output.
 * @param increasing order of the powers if the columns.
 * @return Vendermonde matrix.
 */


@ JvmName ( "<STR_LIT>" ) <EOL> inline fun < reified T : Any > mat ( data : List < T > ) : KtNDArray < T >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( data , T :: class . javaObjectType ) )

/**
 * Interpret the input as a matrix (2-D [KtNDArray]).
 *
 * @param data input data.
 * @return 2-D [KtNDArray]
 */


@ JvmName ( "<STR_LIT>" ) <EOL> inline fun < reified T : Any > bmat ( data : List < KtNDArray < T > > ) : KtNDArray < T >

/**
 * Build a matrix object from a [List].
 *
 * @param data input data.
 * @return a 2-D [KtNDArray].
 * @see block
 */


@ JvmName ( "<STR_LIT>" ) <EOL> inline fun < reified T : Any > bmat ( data : List < List < KtNDArray < T > > > ) : KtNDArray < T >

/**
 * Build a matrix object from a [List] of [List].
 * @param data input data.
 * @return a 2-D [KtNDArray].
 * @see block
 */


fun < T : Number > meshgrid ( vararg xi : KtNDArray < T > ) : List < KtNDArray < T > >

= <EOL> callFunc ( nameMethod = arrayOf ( "<STR_LIT>" ) , args = arrayOf ( * xi ) , kClass = List :: class ) as List < KtNDArray < T > >

/**
 * Return coordinate matrices from coordinate vectors.
 *
 * @param xi 1-D arrays representing the coordinates of a grid.
 */


inline fun < reified T : Any > type ( l : KtNDArray < T > )

= T :: class . java


{ <EOL> val testProject = javaTestProject { <EOL> dokkaConfiguration { <EOL> moduleName = "<STR_LIT>" <EOL> javaSourceSet { <EOL> } <EOL> } <EOL> javaFile ( pathFromSrc = "<STR_LIT>" ) { <EOL> + """<STR_LIT>""" <EOL> } <EOL> } <EOL> val module = testProject . parse ( ) <EOL> assertEquals ( "<STR_LIT>" , module . name ) <EOL> assertEquals ( <NUM_LIT:1> , module . packages . size ) <EOL> val pckg = module . packages [ <NUM_LIT:0> ] <EOL> assertEquals ( "<STR_LIT>" , pckg . name ) <EOL> assertEquals ( <NUM_LIT:1> , pckg . classlikes . size ) <EOL> val fooClass = pckg . classlikes [ <NUM_LIT:0> ] <EOL> assertEquals ( "<STR_LIT>" , fooClass . name ) <EOL> }

/**
 * Used as a sample for [javaTestProject]
 */


private fun getEffectivePropertyInitializer ( property : FirProperty , resolveIfNeeded : Boolean ) : FirExpression ?

{ <EOL> val initializer = property . backingField ? . initializer ? : property . initializer <EOL> if ( resolveIfNeeded && initializer is FirLiteralExpression < * > ) { <EOL> property . lazyResolveToPhase ( FirResolvePhase . BODY_RESOLVE ) <EOL> return getEffectivePropertyInitializer ( property , resolveIfNeeded = false ) <EOL> } <EOL> return initializer <EOL> }

/**
 * In partial module compilation (see [org.jetbrains.kotlin.analysis.api.fir.components.KtFirCompilerFacility]),
 * referenced properties might be resolved only up to [FirResolvePhase.CONTRACTS],
 * however the backend requires the exact initializer type.
 */


internal fun computeDispatchReceiverType ( irFunction : IrSimpleFunction , firCallable : FirCallableDeclaration ? , parent : IrDeclarationParent ? , c : Fir2IrComponents ) : IrType ?

{ <EOL> if ( firCallable is FirProperty && firCallable . isLocal ) return null <EOL> val containingClass = computeContainingClass ( parent ) ? : return null <EOL> val defaultType = containingClass . defaultType <EOL> if ( firCallable == null ) return defaultType <EOL> if ( ! irFunction . isFakeOverride ) return defaultType <EOL> val originalCallable = firCallable . unwrapFakeOverrides ( ) <EOL> val containerOfOriginalCallable = originalCallable . containingClassLookupTag ( ) ? : return defaultType <EOL> val containerOfFakeOverride = firCallable . dispatchReceiverType ? : return defaultType <EOL> val correspondingSupertype = AbstractTypeChecker . findCorrespondingSupertypes ( c . session . typeContext . newTypeCheckerState ( errorTypesEqualToAnything = false , stubTypesEqualToAnything = false ) , containerOfFakeOverride , containerOfOriginalCallable ) . firstOrNull ( ) as ConeKotlinType ? ? : return defaultType <EOL> return correspondingSupertype . toIrType ( c ) <EOL> }

/**
 * [firCallable] is function or property (if [irFunction] is a property accessor) for
 * which [irFunction] was build
 *
 * It is needed to determine proper dispatch receiver type if this declaration is fake-override
 */


@ OptIn ( UnsafeDuringIrConstructionAPI :: class ) <EOL> internal fun addDeclarationToParent ( declaration : IrDeclaration , irParent : IrDeclarationParent ? )

{ <EOL> if ( irParent == null ) return <EOL> when ( irParent ) { <EOL> is Fir2IrLazyClass -> { <EOL> } <EOL> is IrClass -> irParent . declarations += declaration <EOL> is IrFile -> irParent . declarations += declaration <EOL> is IrExternalPackageFragment -> irParent . declarations += declaration <EOL> is IrScript -> { <EOL> } <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * We should not try to add declaration to list of parents declarations in two cases:
 * 1. getters, setters, and backing fields are not stored in parent directly. They are stored in IrProperty instead,
 * which is stored in parent
 * 2. if a declaration is declared in a local scope (in some body) then it will have contained class/function as a parent. But the declaration
 * should be listed in statements list of the corresponding IrBlock instead of IrClass.declarations
 * Note that IrClass will be a parent if some declaration is declared inside anonymous initializer, because IrAnonymousInitializer
 * is not a IrDeclarationParent
 */


{ <EOL> }


public fun DataFrame . Companion . readArrowIPC ( channel : ReadableByteChannel , allocator : RootAllocator = Allocator . ROOT , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= readArrowIPCImpl ( channel , allocator , nullability )

/**
 * Read [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format) data from existing [channel]
 */


public fun DataFrame . Companion . readArrowFeather ( channel : SeekableByteChannel , allocator : RootAllocator = Allocator . ROOT , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= readArrowFeatherImpl ( channel , allocator , nullability )

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [channel]
 */


public fun DataFrame . Companion . readArrowIPC ( file : File , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> Files . newByteChannel ( file . toPath ( ) ) . use { readArrowIPC ( it , nullability = nullability ) }

/**
 * Read [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format) data from existing [file]
 */


public fun DataFrame . Companion . readArrowIPC ( byteArray : ByteArray , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> SeekableInMemoryByteChannel ( byteArray ) . use { readArrowIPC ( it , nullability = nullability ) }

/**
 * Read [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format) data from existing [byteArray]
 */


public fun DataFrame . Companion . readArrowIPC ( stream : InputStream , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> Channels . newChannel ( stream ) . use { readArrowIPC ( it , nullability = nullability ) }

/**
 * Read [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format) data from existing [stream]
 */


public fun DataFrame . Companion . readArrowIPC ( url : URL , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> when { <EOL> isFile ( url ) -> readArrowIPC ( urlAsFile ( url ) , nullability ) <EOL> isProtocolSupported ( url ) -> url . openStream ( ) . use { readArrowIPC ( it , nullability ) } <EOL> else -> { <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Read [Arrow interprocess streaming format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-streaming-format) data from existing [url]
 */


public fun DataFrame . Companion . readArrowFeather ( file : File , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> Files . newByteChannel ( file . toPath ( ) ) . use { readArrowFeather ( it , nullability = nullability ) }

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [file]
 */


public fun DataFrame . Companion . readArrowFeather ( byteArray : ByteArray , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> SeekableInMemoryByteChannel ( byteArray ) . use { readArrowFeather ( it , nullability = nullability ) }

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [byteArray]
 */


public fun DataFrame . Companion . readArrowFeather ( stream : InputStream , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> readArrowFeather ( stream . readBytes ( ) , nullability )

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [stream]
 */


public fun DataFrame . Companion . readArrowFeather ( url : URL , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= <EOL> when { <EOL> isFile ( url ) -> readArrowFeather ( urlAsFile ( url ) , nullability ) <EOL> isProtocolSupported ( url ) -> readArrowFeather ( url . readBytes ( ) , nullability ) <EOL> else -> { <EOL> throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [url]
 */


public fun DataFrame . Companion . readArrowFeather ( path : String , nullability : NullabilityOptions = NullabilityOptions . Infer , ) : AnyFrame

= if ( isURL ( path ) ) { <EOL> readArrowFeather ( URL ( path ) , nullability ) <EOL> } else { <EOL> readArrowFeather ( File ( path ) , nullability ) <EOL> }

/**
 * Read [Arrow random access format](https://arrow.apache.org/docs/java/ipc.html#writing-and-reading-random-access-files) data from existing [path]
 */


public fun DataFrame . Companion . readArrow ( reader : ArrowReader , nullability : NullabilityOptions = NullabilityOptions . Infer ) : AnyFrame

= readArrowImpl ( reader , nullability )

/**
 * Read [Arrow any format](https://arrow.apache.org/docs/java/ipc.html#reading-writing-ipc-formats) data from existing [reader]
 */


public fun ArrowReader . toDataFrame ( nullability : NullabilityOptions = NullabilityOptions . Infer ) : AnyFrame

= DataFrame . Companion . readArrowImpl ( this , nullability )

/**
 * Read [Arrow any format](https://arrow.apache.org/docs/java/ipc.html#reading-writing-ipc-formats) data from existing [ArrowReader]
 */


@ Test <EOL> fun testSuspensionsUndoingMdcContextUpdates ( )

= runTest { <EOL> MDC . put ( "<STR_LIT:a>" , "<STR_LIT:b>" ) <EOL> withContext ( MDCContext ( ) ) { <EOL> MDC . put ( "<STR_LIT>" , "<STR_LIT:value>" ) <EOL> assertEquals ( "<STR_LIT:b>" , MDC . get ( "<STR_LIT:a>" ) ) <EOL> yield ( ) <EOL> assertNull ( MDC . get ( "<STR_LIT>" ) ) <EOL> assertEquals ( "<STR_LIT:b>" , MDC . get ( "<STR_LIT:a>" ) ) <EOL> } <EOL> }

/** Tests that the initially captured MDC context gets restored after suspension. */


@ Test <EOL> fun testRestoringMdcContext ( )

= runTest { <EOL> MDC . put ( "<STR_LIT:a>" , "<STR_LIT:b>" ) <EOL> val contextMap = withContext ( MDCContext ( ) ) { <EOL> MDC . put ( "<STR_LIT>" , "<STR_LIT:value>" ) <EOL> assertEquals ( "<STR_LIT:b>" , MDC . get ( "<STR_LIT:a>" ) ) <EOL> withContext ( MDCContext ( ) ) { <EOL> assertEquals ( "<STR_LIT:value>" , MDC . get ( "<STR_LIT>" ) ) <EOL> MDC . put ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> assertEquals ( "<STR_LIT>" , MDC . get ( "<STR_LIT>" ) ) <EOL> withContext ( MDCContext ( ) ) { <EOL> yield ( ) <EOL> MDC . getCopyOfContextMap ( ) <EOL> } <EOL> } <EOL> } <EOL> MDC . setContextMap ( contextMap ) <EOL> assertEquals ( "<STR_LIT>" , MDC . get ( "<STR_LIT>" ) ) <EOL> assertEquals ( "<STR_LIT:value>" , MDC . get ( "<STR_LIT>" ) ) <EOL> assertEquals ( "<STR_LIT:b>" , MDC . get ( "<STR_LIT:a>" ) ) <EOL> }

/** Tests capturing and restoring the MDC context. */


abstract fun convert ( value : kotlin . String , name : kotlin . String ) : T

/**
 * Function to convert string argument value to its type.
 * In case of error during conversion also provides help message.
 *
 * @param value value
 */


inline fun < reified T : Enum < T > > Choice ( noinline toVariant : ( ( kotlin . String ) -> T ) ? = null , noinline toString : ( T ) -> kotlin . String = { it . toString ( ) . lowercase ( ) } ) : Choice < T >

{ <EOL> return Choice ( enumValues < T > ( ) . toList ( ) , toVariant ? : { <EOL> enumValues < T > ( ) . find { e -> toString ( e ) . equals ( it , ignoreCase = true ) } <EOL> ? : throw IllegalArgumentException ( "<STR_LIT>" ) <EOL> } , toString ) <EOL> }

/**
 * Helper for arguments that have limited set of possible values represented as enumeration constants.
 */


private fun forceBoxedReturnType ( descriptor : FunctionDescriptor ) : Boolean

{ <EOL> if ( isBoxMethodForInlineClass ( descriptor ) ) return true <EOL> val returnType = descriptor . returnType ! ! <EOL> if ( ( isFunctionExpression ( descriptor ) || isFunctionLiteral ( descriptor ) ) && returnType . isInlineClassType ( ) ) return true <EOL> return isJvmPrimitive ( returnType ) && <EOL> getAllOverriddenDescriptors ( descriptor ) . any { ! isJvmPrimitive ( it . returnType ! ! ) } || <EOL> returnType . isInlineClassType ( ) && descriptor is JavaMethodDescriptor <EOL> }

/**
 * @return true iff a given function descriptor should be compiled to a method with boxed return type regardless of whether return type
 * of that descriptor is nullable or not. This happens in two cases:
 * - when a target function is a synthetic box method of erased inline class;
 * - when a function returning a value of a primitive type overrides another function with a non-primitive return type.
 * In that case the generated method's return type should be boxed: otherwise it's not possible to use
 * this class from Java since javac issues errors when loading the class (incompatible return types)
 */


fun computeClasspathChanges ( classpathSnapshotFiles : ClasspathSnapshotFiles , lookupStorage : LookupStorage , storeCurrentClasspathSnapshotForReuse : ( currentClasspathSnapshot : List < AccessibleClassSnapshot > , shrunkCurrentClasspathAgainstPreviousLookups : List < AccessibleClassSnapshot > ) -> Unit , reporter : ClasspathSnapshotBuildReporter ) : ProgramSymbolSet

{ <EOL> val currentClasspathSnapshot = reporter . measure ( GradleBuildTime . LOAD_CURRENT_CLASSPATH_SNAPSHOT ) { <EOL> val classpathSnapshot = <EOL> CachedClasspathSnapshotSerializer . load ( classpathSnapshotFiles . currentClasspathEntrySnapshotFiles , reporter ) <EOL> reporter . measure ( GradleBuildTime . REMOVE_DUPLICATE_CLASSES ) { <EOL> classpathSnapshot . removeDuplicateAndInaccessibleClasses ( ) <EOL> } <EOL> } <EOL> val shrunkCurrentClasspathAgainstPreviousLookups = reporter . measure ( GradleBuildTime . SHRINK_CURRENT_CLASSPATH_SNAPSHOT ) { <EOL> shrinkClasspath ( currentClasspathSnapshot , lookupStorage , ClasspathSnapshotShrinker . MetricsReporter ( reporter , GradleBuildTime . GET_LOOKUP_SYMBOLS , GradleBuildTime . FIND_REFERENCED_CLASSES , GradleBuildTime . FIND_TRANSITIVELY_REFERENCED_CLASSES ) ) <EOL> } <EOL> reporter . debug { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> storeCurrentClasspathSnapshotForReuse ( currentClasspathSnapshot , shrunkCurrentClasspathAgainstPreviousLookups ) <EOL> val shrunkPreviousClasspathSnapshot = reporter . measure ( GradleBuildTime . LOAD_SHRUNK_PREVIOUS_CLASSPATH_SNAPSHOT ) { <EOL> ListExternalizer ( AccessibleClassSnapshotExternalizer ) . loadFromFile ( classpathSnapshotFiles . shrunkPreviousClasspathSnapshotFile ) <EOL> } <EOL> reporter . debug { <EOL> "<STR_LIT>" <EOL> } <EOL> return reporter . measure ( GradleBuildTime . COMPUTE_CHANGED_AND_IMPACTED_SET ) { <EOL> computeChangedAndImpactedSet ( shrunkCurrentClasspathAgainstPreviousLookups , shrunkPreviousClasspathSnapshot , reporter ) <EOL> } <EOL> }

/**
 * Computes changes between the current and previous classpath, plus unchanged elements that are impacted by the changes.
 *
 * NOTE: We shrink the classpath first before comparing them. The original classpath may contain duplicate classes, but the shrunk
 * classpath must not contain duplicate classes.
 */


fun computeChangedAndImpactedSet ( currentClassSnapshots : List < AccessibleClassSnapshot > , previousClassSnapshots : List < AccessibleClassSnapshot > , reporter : ClasspathSnapshotBuildReporter ) : ProgramSymbolSet

{ <EOL> val currentClasses : Map < ClassId , AccessibleClassSnapshot > = currentClassSnapshots . associateBy { it . classId } <EOL> val previousClasses : Map < ClassId , AccessibleClassSnapshot > = previousClassSnapshots . associateBy { it . classId } <EOL> val changedCurrentClasses : List < AccessibleClassSnapshot > = currentClasses . mapNotNull { ( classId , currentClass ) -> <EOL> val previousClass = previousClasses [ classId ] <EOL> if ( previousClass == null || currentClass . classAbiHash != previousClass . classAbiHash ) { <EOL> currentClass <EOL> } else null <EOL> } <EOL> val changedPreviousClasses : List < AccessibleClassSnapshot > = previousClasses . mapNotNull { ( classId , previousClass ) -> <EOL> val currentClass = currentClasses [ classId ] <EOL> if ( currentClass == null || currentClass . classAbiHash != previousClass . classAbiHash ) { <EOL> previousClass <EOL> } else null <EOL> } <EOL> val changedSet = reporter . measure ( GradleBuildTime . COMPUTE_CLASS_CHANGES ) { <EOL> computeClassChanges ( changedCurrentClasses , changedPreviousClasses , reporter ) <EOL> } <EOL> reporter . reportVerboseWithLimit { "<STR_LIT>" } <EOL> if ( changedSet . isEmpty ( ) ) { <EOL> return changedSet <EOL> } <EOL> val changedAndImpactedSet = reporter . measure ( GradleBuildTime . COMPUTE_IMPACTED_SET ) { <EOL> computeImpactedSymbols ( changes = changedSet , allClasses = ( previousClassSnapshots . asSequence ( ) + changedCurrentClasses . asSequence ( ) ) . asIterable ( ) ) <EOL> } <EOL> reporter . reportVerboseWithLimit { <EOL> "<STR_LIT>" + <EOL> ( changedAndImpactedSet . run { classes + classMembers . keys } - changedSet . run { classes + classMembers . keys } ) <EOL> } <EOL> return changedAndImpactedSet <EOL> }

/**
 * Computes changes between the current and previous lists of classes, plus unchanged elements that are impacted by the changes.
 *
 * NOTE: Each list of classes must not contain duplicates.
 */


private fun computeClassChanges ( currentClassSnapshots : List < AccessibleClassSnapshot > , previousClassSnapshots : List < AccessibleClassSnapshot > , metrics : BuildMetricsReporter < GradleBuildTime , GradleBuildPerformanceMetric > ) : ProgramSymbolSet

{ <EOL> val ( currentKotlinClassSnapshots , currentJavaClassSnapshots ) = currentClassSnapshots . partition { it is KotlinClassSnapshot } <EOL> val ( previousKotlinClassSnapshots , previousJavaClassSnapshots ) = previousClassSnapshots . partition { it is KotlinClassSnapshot } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> val kotlinClassChanges = metrics . measure ( GradleBuildTime . COMPUTE_KOTLIN_CLASS_CHANGES ) { <EOL> computeKotlinClassChanges ( currentKotlinClassSnapshots as List < KotlinClassSnapshot > , previousKotlinClassSnapshots as List < KotlinClassSnapshot > ) <EOL> } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> val javaClassChanges = metrics . measure ( GradleBuildTime . COMPUTE_JAVA_CLASS_CHANGES ) { <EOL> JavaClassChangesComputer . compute ( currentJavaClassSnapshots as List < JavaClassSnapshot > , previousJavaClassSnapshots as List < JavaClassSnapshot > ) <EOL> } <EOL> return kotlinClassChanges + javaClassChanges <EOL> }

/**
 * Computes changes between the current and previous lists of classes. The returned result does not need to include elements that are
 * impacted by the changes.
 *
 * NOTE: Each list of classes must not contain duplicates.
 */


private fun DirtyData . toProgramSymbols ( allClasses : Iterable < AccessibleClassSnapshot > ) : ProgramSymbolSet

{ <EOL> val changedProgramSymbols = dirtyLookupSymbols . toProgramSymbolSet ( allClasses ) <EOL> val ( changedLookupSymbols , changedFqNames ) = changedProgramSymbols . toChangesEither ( ) . let { <EOL> it . lookupSymbols . toSet ( ) to it . fqNames . toSet ( ) <EOL> } <EOL> val unmatchedLookupSymbols = this . dirtyLookupSymbols . toMutableSet ( ) . also { <EOL> it . removeAll ( changedLookupSymbols ) <EOL> } <EOL> val unmatchedFqNames = this . dirtyClassesFqNames . toMutableSet ( ) . also { <EOL> it . addAll ( this . dirtyClassesFqNamesForceRecompile ) <EOL> it . removeAll ( changedFqNames ) <EOL> } <EOL> if ( unmatchedLookupSymbols . isEmpty ( ) && unmatchedFqNames . isEmpty ( ) ) { <EOL> return changedProgramSymbols <EOL> } <EOL> val changedClassesFqNames = changedProgramSymbols . classes . mapTo ( mutableSetOf ( ) ) { it . asSingleFqName ( ) } <EOL> unmatchedLookupSymbols . removeAll { FqName ( it . scope ) in changedClassesFqNames } <EOL> val companionObjectFqNames = allClasses . mapNotNullTo ( mutableSetOf ( ) ) { clazz -> <EOL> ( clazz as? RegularKotlinClassSnapshot ) ? . companionObjectName ? . let { it -> <EOL> clazz . classId . createNestedClassId ( Name . identifier ( it ) ) . asSingleFqName ( ) <EOL> } <EOL> } <EOL> unmatchedLookupSymbols . removeAll { FqName ( it . scope ) in companionObjectFqNames } <EOL> unmatchedFqNames . removeAll ( companionObjectFqNames ) <EOL> val classesFqNames = allClasses . filter { it is RegularKotlinClassSnapshot || it is JavaClassSnapshot } <EOL> . mapTo ( mutableSetOf ( ) ) { it . classId . asSingleFqName ( ) } <EOL> unmatchedLookupSymbols . removeAll { it . name == SAM_LOOKUP_NAME . asString ( ) && FqName ( it . scope ) !in classesFqNames } <EOL> val packageFacadeFqNames = allClasses . filter { it is KotlinClassSnapshot && it !is RegularKotlinClassSnapshot } <EOL> . mapTo ( mutableSetOf ( ) ) { it . classId . asSingleFqName ( ) } <EOL> unmatchedLookupSymbols . removeAll { FqName ( it . scope ) . child ( Name . identifier ( it . name ) ) in packageFacadeFqNames } <EOL> unmatchedFqNames . removeAll ( packageFacadeFqNames ) <EOL> check ( unmatchedLookupSymbols . isEmpty ( ) ) { <EOL> "<STR_LIT>" <EOL> } <EOL> check ( unmatchedFqNames . isEmpty ( ) ) { <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" <EOL> } <EOL> return changedProgramSymbols <EOL> }

/**
 * Converts this [DirtyData] to [ProgramSymbol]s.
 *
 * Specifically, [DirtyData] consists of:
 * - dirtyLookupSymbols (Collection<LookupSymbol)
 * - dirtyClassesFqNames (Collection<FqName>)
 * - dirtyClassesFqNamesForceRecompile (Collection<FqName>)
 *
 * First, we will convert `dirtyLookupSymbols` to [ProgramSymbol]s as `dirtyLookupSymbols` should contain all the changes.
 *
 * Then, we will check that:
 * 1. There are no items in `dirtyLookupSymbols` that have not yet been converted to [ProgramSymbol]s.
 * 2. `dirtyClassesFqNames` and `dirtyClassesFqNamesForceRecompile` must not contain new information that can't be derived from
 * `dirtyLookupSymbols`.
 */


fun computeImpactedSymbols ( changes : ProgramSymbolSet , allClasses : Iterable < AccessibleClassSnapshot > ) : ProgramSymbolSet

{ <EOL> val impactedSymbolsResolver = AllImpacts . getResolver ( allClasses ) <EOL> return ProgramSymbolSet . Collector ( ) . apply { <EOL> val impactedClasses = findReachableNodes ( changes . classes , impactedSymbolsResolver :: getImpactedClasses ) <EOL> addClasses ( impactedClasses ) <EOL> val classMembers = changes . classMembers . map { ClassMembers ( it . key , it . value ) } <EOL> val impactedClassMembers = findReachableNodes ( classMembers , impactedSymbolsResolver :: getImpactedClassMembers ) <EOL> impactedClassMembers . forEach { <EOL> addClassMembers ( it . classId , it . memberNames ) <EOL> } <EOL> changes . packageMembers . forEach { ( packageFqName , memberNames ) -> <EOL> addPackageMembers ( packageFqName , memberNames ) <EOL> } <EOL> } . getResult ( ) <EOL> }

/**
 * Computes the set of [ProgramSymbol]s that are *transitively* impacted by the given set of [ProgramSymbol]s. For example, if a
 * superclass has changed/been impacted, its subclasses will be impacted.
 *
 * The returned set is *inclusive* (it contains the given set + the directly/transitively impacted ones).
 */


inline fun < reified P : KtElement > getElementOfTypeAtCaretOrNull ( file : KtFile , caretTag : String ? = null ) : P ?

{ <EOL> val offset = getCaretPositionOrNull ( file , caretTag ) ? : return null <EOL> return file . findElementAt ( offset ) <EOL> ? . parentOfType ( ) <EOL> ? : error ( "<STR_LIT>" ) <EOL> }

/**
 * Returns an element of type [P] at the specified caret, or returns `null` if no such caret exists. If the caret can be found but the
 * element has the wrong type, an error will be raised.
 */


private fun < T : PsiElement > getBottommostElementOfTypeInRange ( file : KtFile , range : TextRange , elementType : Class < T > ) : T

{ <EOL> var candidate = PsiTreeUtil . findElementOfClassAtOffset ( file , range . startOffset , elementType , true ) <EOL> while ( candidate != null && candidate . endOffset < range . endOffset ) { <EOL> candidate = PsiTreeUtil . getParentOfType ( candidate , elementType ) ? . takeIf { it . startOffset == range . startOffset } <EOL> } <EOL> return candidate ? . takeIf { it . endOffset == range . endOffset } <EOL> ? : error ( "<STR_LIT>" ) <EOL> }

/**
 * Find the bottommost element of an [elementType] or its subtype located precisely in the [range].
 */


fun < E : KtElement > getBottommostSelectedElementOfType ( file : KtFile , elementType : Class < E > ) : E

{ <EOL> val range = getSelectedRange ( file ) <EOL> return getBottommostElementOfTypeInRange ( file , range , elementType ) <EOL> }

/**
 * Find the bottommost element of [E] or its subtype wrapped in an '<expr>' selection tag.
 */


public suspend fun send ( element : E )

/**
 * Sends the specified [element] to this channel, suspending the caller while the buffer of this channel is full
 * or if it does not exist, or throws an exception if the channel [is closed for `send`][isClosedForSend] (see [close] for details).
 *
 * [Closing][close] a channel _after_ this function has suspended does not cause this suspended [send] invocation
 * to abort, because closing a channel is conceptually like sending a special "close token" over this channel.
 * All elements sent over the channel are delivered in first-in first-out order. The sent element
 * will be delivered to receivers before the close token.
 *
 * 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].
 * There is a **prompt cancellation guarantee**: even if [send] managed to send the element, but was cancelled
 * while suspended, [CancellationException] will be thrown. See [suspendCancellableCoroutine] for low-level details.
 *
 * Because of the prompt cancellation guarantee, an exception does not always mean a failure to deliver the element.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 *
 * Note that this function does not check for cancellation when it is not suspended.
 * Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
 *
 * This function can be used in [select] invocations with the [onSend] clause.
 * Use [trySend] to try sending to this channel without waiting.
 */


public fun trySend ( element : E ) : ChannelResult < Unit >

/**
 * Immediately adds the specified [element] to this channel, if this doesn't violate its capacity restrictions,
 * and returns the successful result. Otherwise, returns failed or closed result.
 * This is synchronous variant of [send], which backs off in situations when `send` suspends or throws.
 *
 * When `trySend` call returns a non-successful result, it guarantees that the element was not delivered to the consumer, and
 * it does not call `onUndeliveredElement` that was installed for this channel.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 */


public fun close ( cause : Throwable ? = null ) : Boolean

/**
 * Closes this channel.
 * This is an idempotent operation — subsequent invocations of this function have no effect and return `false`.
 * Conceptually, it sends a special "close token" over this channel.
 *
 * Immediately after invocation of this function,
 * [isClosedForSend] starts returning `true`. However, [isClosedForReceive][ReceiveChannel.isClosedForReceive]
 * on the side of [ReceiveChannel] starts returning `true` only after all previously sent elements
 * are received.
 *
 * A channel that was closed without a [cause] throws a [ClosedSendChannelException] on attempts to [send]
 * and [ClosedReceiveChannelException] on attempts to [receive][ReceiveChannel.receive].
 * A channel that was closed with non-null [cause] is called a _failed_ channel. Attempts to send or
 * receive on a failed channel throw the specified [cause] exception.
 */


public fun invokeOnClose ( handler : ( cause : Throwable ? ) -> Unit )

/**
 * Registers a [handler] which is synchronously invoked once the channel is [closed][close]
 * or the receiving side of this channel is [cancelled][ReceiveChannel.cancel].
 * Only one handler can be attached to a channel during its lifetime.
 * The `handler` is invoked when [isClosedForSend] starts to return `true`.
 * If the channel is closed already, the handler is invoked immediately.
 *
 * The meaning of `cause` that is passed to the handler:
 * - `null` if the channel was closed normally without the corresponding argument.
 * - Instance of [CancellationException] if the channel was cancelled normally without the corresponding argument.
 * - The cause of `close` or `cancel` otherwise.
 *
 * ### Execution context and exception safety
 *
 * The [handler] is executed as part of the closing or cancelling operation, and only after the channel reaches its final state.
 * This means that if the handler throws an exception or hangs, the channel will still be successfully closed or cancelled.
 * Unhandled exceptions from [handler] are propagated to the closing or cancelling operation's caller.
 *
 * Example of usage:
 * ```
 * val events = Channel<Event>(UNLIMITED)
 * callbackBasedApi.registerCallback { event ->
 * events.trySend(event)
 * .onClosed { /* channel is already closed, but the callback hasn't stopped yet */ }
 * }
 *
 * val uiUpdater = uiScope.launch(Dispatchers.Main) {
 * events.consume { /* handle events */ }
 * }
 * // Stop the callback after the channel is closed or cancelled
 * events.invokeOnClose { callbackBasedApi.stop() }
 * ```
 *
 * **Stability note.** This function constitutes a stable API surface, with the only exception being
 * that an [IllegalStateException] is thrown when multiple handlers are registered.
 * This restriction could be lifted in the future.
 *
 * @throws UnsupportedOperationException if the underlying channel does not support [invokeOnClose].
 * Implementation note: currently, [invokeOnClose] is unsupported only by Rx-like integrations
 *
 * @throws IllegalStateException if another handler was already registered
 */


@ Deprecated ( level = DeprecationLevel . ERROR , message = "<STR_LIT>" , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun offer ( element : E ) : Boolean

{ <EOL> val result = trySend ( element ) <EOL> if ( result . isSuccess ) return true <EOL> throw recoverStackTrace ( result . exceptionOrNull ( ) ? : return false ) <EOL> }

/**
 * **Deprecated** offer method.
 *
 * This method was deprecated in the favour of [trySend].
 * It has proven itself as the most error-prone method in Channel API:
 *
 * - `Boolean` return type creates the false sense of security, implying that `false`
 * is returned instead of throwing an exception.
 * - It was used mostly from non-suspending APIs where CancellationException triggered
 * internal failures in the application (the most common source of bugs).
 * - Due to signature and explicit `if (ch.offer(...))` checks it was easy to
 * oversee such error during code review.
 * - Its name was not aligned with the rest of the API and tried to mimic Java's queue instead.
 *
 * **NB** Automatic migration provides best-effort for the user experience, but requires removal
 * or adjusting of the code that relied on the exception handling.
 * The complete replacement has a more verbose form:
 * ```
 * channel.trySend(element)
 * .onClosed { throw it ?: ClosedSendChannelException("Channel was closed normally") }
 * .isSuccess
 * ```
 *
 * See https://github.com/Kotlin/kotlinx.coroutines/issues/974 for more context.
 *
 * @suppress **Deprecated**.
 */


public suspend fun receive ( ) : E

/**
 * Retrieves and removes an element from this channel if it's not empty, or suspends the caller while the channel is empty,
 * or throws a [ClosedReceiveChannelException] if the channel [is closed for `receive`][isClosedForReceive].
 * If the channel was closed because of an exception, it is called a _failed_ channel and this function
 * will throw the original [close][SendChannel.close] cause exception.
 *
 * This suspending function is cancellable. If the [Job] of the current coroutine is cancelled while this
 * function is suspended, this function immediately resumes with a [CancellationException].
 * There is a **prompt cancellation guarantee**. If the job was cancelled while this function was
 * suspended, it will not resume successfully. The `receive` call can retrieve the element from the channel,
 * but then throw [CancellationException], thus failing to deliver the element.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 *
 * 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].
 * There is a **prompt cancellation guarantee**: even if [receive] managed to retrieve the element from the channel,
 * but was cancelled while suspended, [CancellationException] will be thrown.
 * See [suspendCancellableCoroutine] for low-level details.
 *
 * Because of the prompt cancellation guarantee, some values retrieved from the channel can become lost.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 *
 * Note that this function does not check for cancellation when it is not suspended.
 * Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
 *
 * This function can be used in [select] invocations with the [onReceive] clause.
 * Use [tryReceive] to try receiving from this channel without waiting.
 */


public suspend fun receiveCatching ( ) : ChannelResult < E >

/**
 * Retrieves and removes an element from this channel if it's not empty, or suspends the caller while this channel is empty.
 * This method returns [ChannelResult] with the value of an element successfully retrieved from the channel
 * or the close cause if the channel was closed. Closed cause may be `null` if the channel was closed normally.
 * The result cannot be [failed][ChannelResult.isFailure] without being [closed][ChannelResult.isClosed].
 *
 * 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].
 * There is a **prompt cancellation guarantee**: even if [receiveCatching] managed to retrieve the element from the
 * channel, but was cancelled while suspended, [CancellationException] will be thrown.
 * See [suspendCancellableCoroutine] for low-level details.
 *
 * Because of the prompt cancellation guarantee, some values retrieved from the channel can become lost.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 *
 * Note that this function does not check for cancellation when it is not suspended.
 * Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
 *
 * This function can be used in [select] invocations with the [onReceiveCatching] clause.
 * Use [tryReceive] to try receiving from this channel without waiting.
 */


public fun tryReceive ( ) : ChannelResult < E >

/**
 * Retrieves and removes an element from this channel if it's not empty, returning a [successful][ChannelResult.success]
 * result, returns [failed][ChannelResult.failed] result if the channel is empty, and [closed][ChannelResult.closed]
 * result if the channel is closed.
 */


public operator fun iterator ( ) : ChannelIterator < E >

/**
 * Returns a new iterator to receive elements from this channel using a `for` loop.
 * Iteration completes normally when the channel [is closed for `receive`][isClosedForReceive] without a cause and
 * throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
 */


public fun cancel ( cause : CancellationException ? = null )

/**
 * Cancels reception of remaining elements from this channel with an optional [cause].
 * This function closes the channel and removes all buffered sent elements from it.
 *
 * A cause can be used to specify an error message or to provide other details on
 * the cancellation reason for debugging purposes.
 * If the cause is not specified, then an instance of [CancellationException] with a
 * default message is created to [close][SendChannel.close] the channel.
 *
 * Immediately after invocation of this function [isClosedForReceive] and
 * [isClosedForSend][SendChannel.isClosedForSend]
 * on the side of [SendChannel] start returning `true`. Any attempt to send to or receive from this channel
 * will lead to a [CancellationException].
 */


@ Deprecated ( level = DeprecationLevel . HIDDEN , message = "<STR_LIT>" ) <EOL> public fun cancel ( ) : Unit

= cancel ( null )

/**
 * @suppress This method implements old version of JVM ABI. Use [cancel].
 */


@ Deprecated ( level = DeprecationLevel . HIDDEN , message = "<STR_LIT>" ) <EOL> public fun cancel ( cause : Throwable ? = null ) : Boolean

/**
 * @suppress This method has bad semantics when cause is not a [CancellationException]. Use [cancel].
 */


@ Deprecated ( level = DeprecationLevel . ERROR , message = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun poll ( ) : E ?

{ <EOL> val result = tryReceive ( ) <EOL> if ( result . isSuccess ) return result . getOrThrow ( ) <EOL> throw recoverStackTrace ( result . exceptionOrNull ( ) ? : return null ) <EOL> }

/**
 * **Deprecated** poll method.
 *
 * This method was deprecated in the favour of [tryReceive].
 * It has proven itself as error-prone method in Channel API:
 *
 * - Nullable return type creates the false sense of security, implying that `null`
 * is returned instead of throwing an exception.
 * - It was used mostly from non-suspending APIs where CancellationException triggered
 * internal failures in the application (the most common source of bugs).
 * - Its name was not aligned with the rest of the API and tried to mimic Java's queue instead.
 *
 * See https://github.com/Kotlin/kotlinx.coroutines/issues/974 for more context.
 *
 * ### Replacement note
 *
 * The replacement `tryReceive().getOrNull()` is a default that ignores all close exceptions and
 * proceeds with `null`, while `poll` throws an exception if the channel was closed with an exception.
 * Replacement with the very same 'poll' semantics is `tryReceive().onClosed { if (it != null) throw it }.getOrNull()`
 *
 * @suppress **Deprecated**.
 */


@ Suppress ( "<STR_LIT:INVISIBLE_REFERENCE>" , "<STR_LIT:INVISIBLE_MEMBER>" ) <EOL> @ LowPriorityInOverloadResolution <EOL> @ Deprecated ( message = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , level = DeprecationLevel . ERROR , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public suspend fun receiveOrNull ( ) : E ?

= receiveCatching ( ) . getOrNull ( )

/**
 * This function was deprecated since 1.3.0 and is no longer recommended to use
 * or to implement in subclasses.
 *
 * It had the following pitfalls:
 * - Didn't allow to distinguish 'null' as "closed channel" from "null as a value"
 * - Was throwing if the channel has failed even though its signature may suggest it returns 'null'
 * - It didn't really belong to core channel API and can be exposed as an extension instead.
 *
 * ### Replacement note
 *
 * The replacement `receiveCatching().getOrNull()` is a safe default that ignores all close exceptions and
 * proceeds with `null`, while `receiveOrNull` throws an exception if the channel was closed with an exception.
 * Replacement with the very same `receiveOrNull` semantics is `receiveCatching().onClosed { if (it != null) throw it }.getOrNull()`.
 *
 * @suppress **Deprecated**
 */


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

= if ( holder !is Failed ) holder as T else null

/**
 * Returns the encapsulated value if this instance represents success or `null` if it represents failed result.
 */


{ <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( holder !is Failed ) return holder as T <EOL> if ( holder is Closed && holder . cause != null ) throw holder . cause <EOL> error ( "<STR_LIT>" ) <EOL> }

/**
 * Returns the encapsulated value if this instance represents success or throws an exception if it is closed or failed.
 */


public fun exceptionOrNull ( ) : Throwable ?

= ( holder as? Closed ) ? . cause

/**
 * Returns the encapsulated exception if this instance represents failure or `null` if it is success
 * or unsuccessful operation to closed channel.
 */


@ OptIn ( ExperimentalContracts :: class ) <EOL> public inline fun < T > ChannelResult < T > . getOrElse ( onFailure : ( exception : Throwable ? ) -> T ) : T

{ <EOL> contract { <EOL> callsInPlace ( onFailure , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> return if ( holder is ChannelResult . Failed ) onFailure ( exceptionOrNull ( ) ) else holder as T <EOL> }

/**
 * Returns the encapsulated value if this instance represents [success][ChannelResult.isSuccess] or the
 * result of [onFailure] function for the encapsulated [Throwable] exception if it is failed or closed
 * result.
 */


@ OptIn ( ExperimentalContracts :: class ) <EOL> public inline fun < T > ChannelResult < T > . onSuccess ( action : ( value : T ) -> Unit ) : ChannelResult < T >

{ <EOL> contract { <EOL> callsInPlace ( action , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> @ Suppress ( "<STR_LIT:UNCHECKED_CAST>" ) <EOL> if ( holder !is ChannelResult . Failed ) action ( holder as T ) <EOL> return this <EOL> }

/**
 * Performs the given [action] on the encapsulated value if this instance represents [success][ChannelResult.isSuccess].
 * Returns the original `ChannelResult` unchanged.
 */


@ OptIn ( ExperimentalContracts :: class ) <EOL> public inline fun < T > ChannelResult < T > . onFailure ( action : ( exception : Throwable ? ) -> Unit ) : ChannelResult < T >

{ <EOL> contract { <EOL> callsInPlace ( action , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> if ( holder is ChannelResult . Failed ) action ( exceptionOrNull ( ) ) <EOL> return this <EOL> }

/**
 * Performs the given [action] on the encapsulated [Throwable] exception if this instance represents [failure][ChannelResult.isFailure].
 * The result of [ChannelResult.exceptionOrNull] is passed to the [action] parameter.
 *
 * Returns the original `ChannelResult` unchanged.
 */


@ OptIn ( ExperimentalContracts :: class ) <EOL> public inline fun < T > ChannelResult < T > . onClosed ( action : ( exception : Throwable ? ) -> Unit ) : ChannelResult < T >

{ <EOL> contract { <EOL> callsInPlace ( action , InvocationKind . AT_MOST_ONCE ) <EOL> } <EOL> if ( holder is ChannelResult . Closed ) action ( exceptionOrNull ( ) ) <EOL> return this <EOL> }

/**
 * Performs the given [action] on the encapsulated [Throwable] exception if this instance represents [failure][ChannelResult.isFailure]
 * due to channel being [closed][Channel.close].
 * The result of [ChannelResult.exceptionOrNull] is passed to the [action] parameter.
 * It is guaranteed that if action is invoked, then the channel is either [closed for send][Channel.isClosedForSend]
 * or is [closed for receive][Channel.isClosedForReceive] depending on the failed operation.
 *
 * Returns the original `ChannelResult` unchanged.
 */


public suspend operator fun hasNext ( ) : Boolean

/**
 * Returns `true` if the channel has more elements, suspending the caller while this channel is empty,
 * or returns `false` if the channel [is closed for `receive`][ReceiveChannel.isClosedForReceive] without a cause.
 * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
 *
 * This function retrieves and removes an element from this channel for the subsequent invocation
 * of [next].
 *
 * 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].
 * There is a **prompt cancellation guarantee**: even if [hasNext] retrieves the element from the channel during
 * its operation, but was cancelled while suspended, [CancellationException] will be thrown.
 * See [suspendCancellableCoroutine] for low-level details.
 *
 * Because of the prompt cancellation guarantee, some values retrieved from the channel can become lost.
 * See "Undelivered elements" section in [Channel] documentation for details on handling undelivered elements.
 *
 * Note that this function does not check for cancellation when it is not suspended.
 * Use [yield] or [CoroutineScope.isActive] to periodically check for cancellation in tight loops if needed.
 */


public operator fun next ( ) : E

/**
 * Retrieves the element removed from the channel by a preceding call to [hasNext], or
 * throws an [IllegalStateException] if [hasNext] was not invoked.
 * This method should only be used in pair with [hasNext]:
 * ```
 * while (iterator.hasNext()) {
 * val element = iterator.next()
 * // ... handle element ...
 * }
 * ```
 *
 * This method throws a [ClosedReceiveChannelException] if the channel [is closed for `receive`][ReceiveChannel.isClosedForReceive] without a cause.
 * It throws the original [close][SendChannel.close] cause exception if the channel has _failed_.
 */


public fun < E > Channel ( capacity : Int = RENDEZVOUS , onBufferOverflow : BufferOverflow = BufferOverflow . SUSPEND , onUndeliveredElement : ( ( E ) -> Unit ) ? = null ) : Channel < E >

= <EOL> when ( capacity ) { <EOL> RENDEZVOUS -> { <EOL> if ( onBufferOverflow == BufferOverflow . SUSPEND ) <EOL> BufferedChannel ( RENDEZVOUS , onUndeliveredElement ) <EOL> else <EOL> ConflatedBufferedChannel ( <NUM_LIT:1> , onBufferOverflow , onUndeliveredElement ) <EOL> } <EOL> CONFLATED -> { <EOL> require ( onBufferOverflow == BufferOverflow . SUSPEND ) { <EOL> "<STR_LIT>" <EOL> } <EOL> ConflatedBufferedChannel ( <NUM_LIT:1> , BufferOverflow . DROP_OLDEST , onUndeliveredElement ) <EOL> } <EOL> UNLIMITED -> BufferedChannel ( UNLIMITED , onUndeliveredElement ) <EOL> BUFFERED -> { <EOL> if ( onBufferOverflow == BufferOverflow . SUSPEND ) BufferedChannel ( CHANNEL_DEFAULT_CAPACITY , onUndeliveredElement ) <EOL> else ConflatedBufferedChannel ( <NUM_LIT:1> , onBufferOverflow , onUndeliveredElement ) <EOL> } <EOL> else -> { <EOL> if ( onBufferOverflow === BufferOverflow . SUSPEND ) BufferedChannel ( capacity , onUndeliveredElement ) <EOL> else ConflatedBufferedChannel ( capacity , onBufferOverflow , onUndeliveredElement ) <EOL> } <EOL> }

/**
 * Creates a channel with the specified buffer capacity (or without a buffer by default).
 * See [Channel] interface documentation for details.
 *
 * @param capacity either a positive channel capacity or one of the constants defined in [Channel.Factory].
 * @param onBufferOverflow configures an action on buffer overflow (optional, defaults to
 * a [suspending][BufferOverflow.SUSPEND] attempt to [send][Channel.send] a value,
 * supported only when `capacity >= 0` or `capacity == Channel.BUFFERED`,
 * implicitly creates a channel with at least one buffered element).
 * @param onUndeliveredElement an optional function that is called when element was sent but was not delivered to the consumer.
 * See "Undelivered elements" section in [Channel] documentation.
 * @throws IllegalArgumentException when [capacity] < -2
 */


public fun < T > rxMaybe ( context : CoroutineContext = EmptyCoroutineContext , block : suspend CoroutineScope . ( ) -> T ? <EOL> ) : Maybe < T >

{ <EOL> require ( context [ Job ] === null ) { "<STR_LIT>" + <EOL> "<STR_LIT>" } <EOL> return rxMaybeInternal ( GlobalScope , context , block ) <EOL> }

/**
 * Creates cold [maybe][Maybe] that will run a given [block] in a coroutine and emits its result.
 * If [block] result is `null`, [onComplete][MaybeObserver.onComplete] is invoked without a value.
 * Every time the returned observable is subscribed, it starts a new coroutine.
 * Unsubscribing cancels running coroutine.
 * Coroutine context can be specified with [context] argument.
 * If the context does not have any dispatcher nor any other [ContinuationInterceptor], then [Dispatchers.Default] is used.
 * Method throws [IllegalArgumentException] if provided [context] contains a [Job] instance.
 */


@ Deprecated ( message = "<STR_LIT>" , level = DeprecationLevel . HIDDEN , replaceWith = ReplaceWith ( "<STR_LIT>" ) ) <EOL> public fun < T > CoroutineScope . rxMaybe ( context : CoroutineContext = EmptyCoroutineContext , block : suspend CoroutineScope . ( ) -> T ? <EOL> ) : Maybe < T >

= rxMaybeInternal ( this , context , block )


fun EditText . afterTextChanged ( afterTextChanged : ( String ) -> Unit )

{ <EOL> this . addTextChangedListener ( object : TextWatcher { <EOL> override fun afterTextChanged ( editable : Editable ? ) { <EOL> afterTextChanged . invoke ( editable . toString ( ) ) <EOL> } <EOL> override fun beforeTextChanged ( s : CharSequence , start : Int , count : Int , after : Int ) { } <EOL> override fun onTextChanged ( s : CharSequence , start : Int , before : Int , count : Int ) { } <EOL> } ) <EOL> }

/**
 * Extension function to simplify setting an afterTextChanged action to EditText components.
 */


@ SinceKotlin ( "<STR_LIT:1.5>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V , R : Any > Map < out K , V > . firstNotNullOf ( transform : ( Map . Entry < K , V > ) -> R ? ) : R

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

/**
 * Returns the first non-null value produced by [transform] function being applied to entries of this map 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 < K , V , R : Any > Map < out K , V > . firstNotNullOfOrNull ( transform : ( Map . Entry < K , V > ) -> 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 entries of this map in iteration order,
 * or `null` if no non-null value was produced.
 *
 * @sample samples.collections.Collections.Transformations.firstNotNullOf
 */


public fun < K , V > Map < out K , V > . toList ( ) : List < Pair < K , V > >

{ <EOL> if ( size == <NUM_LIT:0> ) <EOL> return emptyList ( ) <EOL> val iterator = entries . iterator ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> return emptyList ( ) <EOL> val first = iterator . next ( ) <EOL> if ( ! iterator . hasNext ( ) ) <EOL> return listOf ( first . toPair ( ) ) <EOL> val result = ArrayList < Pair < K , V > > ( size ) <EOL> result . add ( first . toPair ( ) ) <EOL> do { <EOL> result . add ( iterator . next ( ) . toPair ( ) ) <EOL> } while ( iterator . hasNext ( ) ) <EOL> return result <EOL> }

/**
 * Returns a [List] containing all key-value pairs.
 */


public inline fun < K , V , R > Map < out K , V > . flatMap ( transform : ( Map . Entry < K , V > ) -> 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 entry of original map.
 *
 * @sample samples.collections.Maps.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 < K , V , R > Map < out K , V > . flatMap ( transform : ( Map . Entry < K , V > ) -> Sequence < R > ) : List < R >

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


public inline fun < K , V , R , C : MutableCollection < in R > > Map < out K , V > . flatMapTo ( destination : C , transform : ( Map . Entry < K , V > ) -> 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 entry of original map, 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 < K , V , R , C : MutableCollection < in R > > Map < out K , V > . flatMapTo ( destination : C , transform : ( Map . Entry < K , V > ) -> Sequence < R > ) : C


public inline fun < K , V , R > Map < out K , V > . map ( transform : ( Map . Entry < K , V > ) -> R ) : List < R >

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

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


public inline fun < K , V , R : Any > Map < out K , V > . mapNotNull ( transform : ( Map . Entry < K , V > ) -> R ? ) : List < R >

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

/**
 * Returns a list containing only the non-null results of applying the given [transform] function
 * to each entry in the original map.
 *
 * @sample samples.collections.Maps.Transformations.mapNotNull
 */


public inline fun < K , V , R : Any , C : MutableCollection < in R > > Map < out K , V > . mapNotNullTo ( destination : C , transform : ( Map . Entry < K , V > ) -> R ? ) : C

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

/**
 * Applies the given [transform] function to each entry in the original map
 * and appends only the non-null results to the given [destination].
 */


public inline fun < K , V , R , C : MutableCollection < in R > > Map < out K , V > . mapTo ( destination : C , transform : ( Map . Entry < K , V > ) -> R ) : C

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

/**
 * Applies the given [transform] function to each entry of the original map
 * and appends the results to the given [destination].
 */


public inline fun < K , V > Map < out K , V > . all ( predicate : ( Map . Entry < K , V > ) -> Boolean ) : Boolean

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

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


public fun < K , V > Map < out K , V > . any ( ) : Boolean

{ <EOL> return ! isEmpty ( ) <EOL> }

/**
 * Returns `true` if map has at least one entry.
 *
 * @sample samples.collections.Collections.Aggregates.any
 */


public inline fun < K , V > Map < out K , V > . any ( predicate : ( Map . Entry < K , V > ) -> Boolean ) : Boolean

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

/**
 * Returns `true` if at least one entry matches the given [predicate].
 *
 * @sample samples.collections.Collections.Aggregates.anyWithPredicate
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . count ( ) : Int

{ <EOL> return size <EOL> }

/**
 * Returns the number of entries in this map.
 */


public inline fun < K , V > Map < out K , V > . count ( predicate : ( Map . Entry < K , V > ) -> Boolean ) : Int

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

/**
 * Returns the number of entries matching the given [predicate].
 */


@ kotlin . internal . HidesMembers <EOL> public inline fun < K , V > Map < out K , V > . forEach ( action : ( Map . Entry < K , V > ) -> Unit ) : Unit

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

/**
 * Performs the given [action] on each entry.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < K , V , R : Comparable < R > > Map < out K , V > . maxBy ( selector : ( Map . Entry < K , V > ) -> R ) : Map . Entry < K , V >

{ <EOL> return entries . maxBy ( selector ) <EOL> }

/**
 * Returns the first entry yielding the largest value of the given function.
 *
 * @throws NoSuchElementException if the map is empty.
 *
 * @sample samples.collections.Collections.Aggregates.maxBy
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V , R : Comparable < R > > Map < out K , V > . maxByOrNull ( selector : ( Map . Entry < K , V > ) -> R ) : Map . Entry < K , V > ?

{ <EOL> return entries . maxByOrNull ( selector ) <EOL> }

/**
 * Returns the first entry yielding the largest value of the given function or `null` if there are no entries.
 *
 * @sample samples.collections.Collections.Aggregates.maxByOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . maxOf ( selector : ( Map . Entry < K , V > ) -> Double ) : Double

{ <EOL> return entries . maxOf ( selector ) <EOL> }

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


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . maxOf ( selector : ( Map . Entry < K , V > ) -> Float ) : Float


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

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each entry in the map.
 *
 * @throws NoSuchElementException if the map is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . maxOfOrNull ( selector : ( Map . Entry < K , V > ) -> Double ) : Double ?

{ <EOL> return entries . maxOfOrNull ( selector ) <EOL> }

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each entry in the map or `null` if there are no entries.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . maxOfOrNull ( selector : ( Map . Entry < K , V > ) -> Float ) : Float ?


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

/**
 * Returns the largest value among all values produced by [selector] function
 * applied to each entry in the map or `null` if there are no entries.
 */


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

{ <EOL> return entries . maxOfWith ( comparator , selector ) <EOL> }

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


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

{ <EOL> return entries . maxOfWithOrNull ( comparator , selector ) <EOL> }

/**
 * Returns the largest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each entry in the map or `null` if there are no entries.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < K , V > Map < out K , V > . maxWith ( comparator : Comparator < in Map . Entry < K , V > > ) : Map . Entry < K , V >

{ <EOL> return entries . maxWith ( comparator ) <EOL> }

/**
 * Returns the first entry having the largest value according to the provided [comparator].
 *
 * @throws NoSuchElementException if the map is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . maxWithOrNull ( comparator : Comparator < in Map . Entry < K , V > > ) : Map . Entry < K , V > ?

{ <EOL> return entries . maxWithOrNull ( comparator ) <EOL> }

/**
 * Returns the first entry having the largest value according to the provided [comparator] or `null` if there are no entries.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < K , V , R : Comparable < R > > Map < out K , V > . minBy ( selector : ( Map . Entry < K , V > ) -> R ) : Map . Entry < K , V >

{ <EOL> return entries . minBy ( selector ) <EOL> }

/**
 * Returns the first entry yielding the smallest value of the given function.
 *
 * @throws NoSuchElementException if the map is empty.
 *
 * @sample samples.collections.Collections.Aggregates.minBy
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V , R : Comparable < R > > Map < out K , V > . minByOrNull ( selector : ( Map . Entry < K , V > ) -> R ) : Map . Entry < K , V > ?

{ <EOL> return entries . minByOrNull ( selector ) <EOL> }

/**
 * Returns the first entry yielding the smallest value of the given function or `null` if there are no entries.
 *
 * @sample samples.collections.Collections.Aggregates.minByOrNull
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . minOf ( selector : ( Map . Entry < K , V > ) -> Double ) : Double

{ <EOL> return entries . minOf ( selector ) <EOL> }

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


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . minOf ( selector : ( Map . Entry < K , V > ) -> Float ) : Float


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

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each entry in the map.
 *
 * @throws NoSuchElementException if the map is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . minOfOrNull ( selector : ( Map . Entry < K , V > ) -> Double ) : Double ?

{ <EOL> return entries . minOfOrNull ( selector ) <EOL> }

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each entry in the map or `null` if there are no entries.
 *
 * If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ OptIn ( kotlin . experimental . ExperimentalTypeInference :: class ) <EOL> @ OverloadResolutionByLambdaReturnType <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . minOfOrNull ( selector : ( Map . Entry < K , V > ) -> Float ) : Float ?


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

/**
 * Returns the smallest value among all values produced by [selector] function
 * applied to each entry in the map or `null` if there are no entries.
 */


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

{ <EOL> return entries . minOfWith ( comparator , selector ) <EOL> }

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


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

{ <EOL> return entries . minOfWithOrNull ( comparator , selector ) <EOL> }

/**
 * Returns the smallest value according to the provided [comparator]
 * among all values produced by [selector] function applied to each entry in the map or `null` if there are no entries.
 */


@ SinceKotlin ( "<STR_LIT:1.7>" ) <EOL> @ kotlin . jvm . JvmName ( "<STR_LIT>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> @ Suppress ( "<STR_LIT:CONFLICTING_OVERLOADS>" ) <EOL> public inline fun < K , V > Map < out K , V > . minWith ( comparator : Comparator < in Map . Entry < K , V > > ) : Map . Entry < K , V >

{ <EOL> return entries . minWith ( comparator ) <EOL> }

/**
 * Returns the first entry having the smallest value according to the provided [comparator].
 *
 * @throws NoSuchElementException if the map is empty.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . minWithOrNull ( comparator : Comparator < in Map . Entry < K , V > > ) : Map . Entry < K , V > ?

{ <EOL> return entries . minWithOrNull ( comparator ) <EOL> }

/**
 * Returns the first entry having the smallest value according to the provided [comparator] or `null` if there are no entries.
 */


public fun < K , V > Map < out K , V > . none ( ) : Boolean

{ <EOL> return isEmpty ( ) <EOL> }

/**
 * Returns `true` if the map has no entries.
 *
 * @sample samples.collections.Collections.Aggregates.none
 */


public inline fun < K , V > Map < out K , V > . none ( predicate : ( Map . Entry < K , V > ) -> Boolean ) : Boolean

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

/**
 * Returns `true` if no entries match the given [predicate].
 *
 * @sample samples.collections.Collections.Aggregates.noneWithPredicate
 */


@ SinceKotlin ( "<STR_LIT:1.1>" ) <EOL> public inline fun < K , V , M : Map < out K , V > > M . onEach ( action : ( Map . Entry < K , V > ) -> Unit ) : M

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

/**
 * Performs the given [action] on each entry and returns the map itself afterwards.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public inline fun < K , V , M : Map < out K , V > > M . onEachIndexed ( action : ( index : Int , Map . Entry < K , V > ) -> Unit ) : M

{ <EOL> return apply { entries . forEachIndexed ( action ) } <EOL> }

/**
 * Performs the given [action] on each entry, providing sequential index with the entry,
 * and returns the map itself afterwards.
 * @param [action] function that takes the index of an entry and the entry itself
 * and performs the action on the entry.
 */


@ kotlin . internal . InlineOnly <EOL> public inline fun < K , V > Map < out K , V > . asIterable ( ) : Iterable < Map . Entry < K , V > >

{ <EOL> return entries <EOL> }

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


public fun < K , V > Map < out K , V > . asSequence ( ) : Sequence < Map . Entry < K , V > >

{ <EOL> return entries . asSequence ( ) <EOL> }

/**
 * Creates a [Sequence] instance that wraps the original map returning its entries when being iterated.
 *
 * @sample samples.collections.Sequences.Building.sequenceFromMap
 */


{ <EOL> _builder . clearExtras ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.IdeaExtrasProto extras = 1;
 */


{ <EOL> return _builder . hasExtras ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.IdeaExtrasProto extras = 1;
 * @return Whether the extras field is set.
 */


{ <EOL> _builder . clearCoordinates ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinBinaryCoordinatesProto coordinates = 2;
 */


fun hasCoordinates ( ) : kotlin . Boolean

{ <EOL> return _builder . hasCoordinates ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinBinaryCoordinatesProto coordinates = 2;
 * @return Whether the coordinates field is set.
 */


{ <EOL> _builder . clearBinaryType ( ) <EOL> }

/**
 * optional string binary_type = 3;
 */


fun hasBinaryType ( ) : kotlin . Boolean

{ <EOL> return _builder . hasBinaryType ( ) <EOL> }

/**
 * optional string binary_type = 3;
 * @return Whether the binaryType field is set.
 */


{ <EOL> _builder . clearClasspath ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinClasspathProto classpath = 4;
 */


{ <EOL> return _builder . hasClasspath ( ) <EOL> }

/**
 * optional .org.jetbrains.kotlin.gradle.idea.proto.generated.tcs.IdeaKotlinClasspathProto classpath = 4;
 * @return Whether the classpath field is set.
 */


suspend fun syncMutedTestsOnTeamCityWithDatabase ( )

{ <EOL> val remotelyMutedTests = RemotelyMutedTests ( ) <EOL> val locallyMutedTests = LocallyMutedTests ( ) <EOL> syncMutedTests ( remotelyMutedTests . projectTests , locallyMutedTests . projectTests ) <EOL> }

/**
 * Synchronize muted tests on teamcity with flaky tests in database
 *
 * Purpose: possibility to run flaky tests on teamcity that will not affect on build status
 */


override fun shouldSkipValidityCheck ( session : KtAnalysisSession ) : Boolean

= <EOL> when ( modificationEventKind ) { <EOL> ModificationEventKind . GLOBAL_SOURCE_MODULE_STATE_MODIFICATION , <EOL> ModificationEventKind . GLOBAL_SOURCE_OUT_OF_BLOCK_MODIFICATION <EOL> -> { <EOL> session . useSiteModule is KtBinaryModule || session . useSiteModule is KtLibrarySourceModule <EOL> } <EOL> else -> false <EOL> }

/**
 * The analysis session cache disregards whether libraries were invalidated during global invalidation, so some valid library analysis
 * sessions may have been evicted from the cache and should not be checked for validity.
 */