Switch to the new stdlib source generation scheme
Remove old generated sources for stdlib-jvm and stdlib-js
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,299 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("ComparisonsKt")
|
||||
|
||||
package kotlin.comparisons
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Short, b: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Int, b: Int): Int {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun maxOf(a: Long, b: Long): Long {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Float, b: Float): Float {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Double, b: Double): Double {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return maxOf(a, maxOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) >= 0) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Short, b: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Int, b: Int): Int {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun minOf(a: Long, b: Long): Long {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Float, b: Float): Float {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Double, b: Double): Double {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return minOf(a, minOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) <= 0) a else b
|
||||
}
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("MapsKt")
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a [List] containing all key-value pairs.
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> {
|
||||
if (size == 0)
|
||||
return emptyList()
|
||||
val iterator = entries.iterator()
|
||||
if (!iterator.hasNext())
|
||||
return emptyList()
|
||||
val first = iterator.next()
|
||||
if (!iterator.hasNext())
|
||||
return listOf(first.toPair())
|
||||
val result = ArrayList<Pair<K, V>>(size)
|
||||
result.add(first.toPair())
|
||||
do {
|
||||
result.add(iterator.next().toPair())
|
||||
} while (iterator.hasNext())
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
|
||||
*/
|
||||
public inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of [transform] function being invoked on each entry of original map, to the given [destination].
|
||||
*/
|
||||
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 {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing the results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public inline fun <K, V, R> Map<out K, V>.map(transform: (Map.Entry<K, V>) -> R): List<R> {
|
||||
return mapTo(ArrayList<R>(size), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(transform: (Map.Entry<K, V>) -> R?): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(destination: C, transform: (Map.Entry<K, V>) -> R?): C {
|
||||
forEach { element -> transform(element)?.let { destination.add(it) } }
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C {
|
||||
for (item in this)
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if all entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.all
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (!predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if map has at least one entry.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.any
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.any(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if at least one entry matches the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return false
|
||||
for (element in this) if (predicate(element)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries in this map.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.count(): Int {
|
||||
return size
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries matching the given [predicate].
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean): Int {
|
||||
if (isEmpty()) return 0
|
||||
var count = 0
|
||||
for (element in this) if (predicate(element)) count++
|
||||
return count
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry.
|
||||
*/
|
||||
@kotlin.internal.HidesMembers
|
||||
public inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit): Unit {
|
||||
for (element in this) action(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the largest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.maxBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry having the largest value according to the provided [comparator] or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.maxWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the smallest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.minBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.minWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the map has no entries.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.none
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.none(): Boolean {
|
||||
return isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if no entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry and returns the map itself afterwards.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <K, V, M : Map<out K, V>> M.onEach(action: (Map.Entry<K, V>) -> Unit): M {
|
||||
return apply { for (element in this) action(element) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an [Iterable] instance that wraps the original map returning its entries when being iterated.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.asIterable(): Iterable<Map.Entry<K, V>> {
|
||||
return entries
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [Sequence] 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>> {
|
||||
return entries.asSequence()
|
||||
}
|
||||
|
||||
@@ -1,961 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("RangesKt")
|
||||
|
||||
package kotlin.ranges
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Byte): Boolean {
|
||||
return contains(value.toInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Byte): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Byte): Boolean {
|
||||
return contains(value.toShort())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Byte): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Byte): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Double): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Double): Boolean {
|
||||
return value.toLongExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Double): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Double): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Double): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Float): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Float): Boolean {
|
||||
return value.toLongExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Float): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Float): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Float): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Int): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Int): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Int): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Int): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Int): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Long): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Long): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Long): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Long): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Long): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Short): Boolean {
|
||||
return contains(value.toInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Short): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Short): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Short): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Short): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Byte): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Char.downTo(to: Char): CharProgression {
|
||||
return CharProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Int): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Short): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun IntProgression.reversed(): IntProgression {
|
||||
return IntProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun LongProgression.reversed(): LongProgression {
|
||||
return LongProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun CharProgression.reversed(): CharProgression {
|
||||
return CharProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun IntProgression.step(step: Int): IntProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return IntProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun LongProgression.step(step: Long): LongProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun CharProgression.step(step: Int): CharProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
internal fun Int.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toInt()..Byte.MAX_VALUE.toInt()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Long.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toLong()..Byte.MAX_VALUE.toLong()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Short.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toShort()..Byte.MAX_VALUE.toShort()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Double.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toDouble()..Byte.MAX_VALUE.toDouble()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Float.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toFloat()..Byte.MAX_VALUE.toFloat()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Long.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toLong()..Int.MAX_VALUE.toLong()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Double.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toDouble()..Int.MAX_VALUE.toDouble()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Float.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toFloat()..Int.MAX_VALUE.toFloat()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Double.toLongExactOrNull(): Long? {
|
||||
return if (this in Long.MIN_VALUE.toDouble()..Long.MAX_VALUE.toDouble()) this.toLong() else null
|
||||
}
|
||||
|
||||
internal fun Float.toLongExactOrNull(): Long? {
|
||||
return if (this in Long.MIN_VALUE.toFloat()..Long.MAX_VALUE.toFloat()) this.toLong() else null
|
||||
}
|
||||
|
||||
internal fun Int.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toInt()..Short.MAX_VALUE.toInt()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Long.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toLong()..Short.MAX_VALUE.toLong()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Double.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toDouble()..Short.MAX_VALUE.toDouble()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Float.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toFloat()..Short.MAX_VALUE.toFloat()) this.toShort() else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Int.until(to: Byte): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Byte): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Byte.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Short.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `'\u0000'` the returned range is empty.
|
||||
*/
|
||||
public infix fun Char.until(to: Char): CharRange {
|
||||
if (to <= '\u0000') return CharRange.EMPTY
|
||||
return this .. (to - 1).toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Int): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Int.until(to: Short): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Short): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Byte.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Short.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeastComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceAtLeast(minimumValue: T): T {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Byte.coerceAtLeast(minimumValue: Byte): Byte {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Short.coerceAtLeast(minimumValue: Short): Short {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Int.coerceAtLeast(minimumValue: Int): Int {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Long.coerceAtLeast(minimumValue: Long): Long {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Float.coerceAtLeast(minimumValue: Float): Float {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Double.coerceAtLeast(minimumValue: Double): Double {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMostComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceAtMost(maximumValue: T): T {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Byte.coerceAtMost(maximumValue: Byte): Byte {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Short.coerceAtMost(maximumValue: Short): Short {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Int.coerceAtMost(maximumValue: Int): Int {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Long.coerceAtMost(maximumValue: Long): Long {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Float.coerceAtMost(maximumValue: Float): Float {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Double.coerceAtMost(maximumValue: Double): Double {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceInComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceIn(minimumValue: T?, maximumValue: T?): T {
|
||||
if (minimumValue !== null && maximumValue !== null) {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
}
|
||||
else {
|
||||
if (minimumValue !== null && this < minimumValue) return minimumValue
|
||||
if (maximumValue !== null && this > maximumValue) return maximumValue
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Byte.coerceIn(minimumValue: Byte, maximumValue: Byte): Byte {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Long.coerceIn(minimumValue: Long, maximumValue: Long): Long {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceInFloatingPointRange
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
// this < start equiv to this <= start && !(this >= start)
|
||||
range.lessThanOrEquals(this, range.start) && !range.lessThanOrEquals(range.start, this) -> range.start
|
||||
// this > end equiv to this >= end && !(this <= end)
|
||||
range.lessThanOrEquals(range.endInclusive, this) && !range.lessThanOrEquals(this, range.endInclusive) -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceInComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<T>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Int.coerceIn(range: ClosedRange<Int>): Int {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<Int>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Long.coerceIn(range: ClosedRange<Long>): Long {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<Long>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("SetsKt")
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size))
|
||||
var removed = false
|
||||
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] array.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] collection.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> {
|
||||
val other = elements.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toSet()
|
||||
if (other is Set)
|
||||
return this.filterNotTo(LinkedHashSet<T>()) { it in other }
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(other)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] sequence.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Set<T>.minusElement(element: T): Set<T> {
|
||||
return minus(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size + 1))
|
||||
result.addAll(this)
|
||||
result.add(element)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] array,
|
||||
* which aren't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size + elements.size))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] collection,
|
||||
* which aren't already in this set.
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(elements.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] sequence,
|
||||
* which aren't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Set<T>.plusElement(element: T): Set<T> {
|
||||
return plus(element)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,9 @@ import kotlin.comparisons.*
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T: Comparable<T>> maxOf(a: T, b: T): T
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
@@ -65,7 +67,9 @@ public expect inline fun maxOf(a: Double, b: Double): Double
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
@@ -93,7 +97,9 @@ public expect inline fun maxOf(a: Int, b: Int, c: Int): Int
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun maxOf(a: Long, b: Long, c: Long): Long
|
||||
public inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
@@ -113,21 +119,27 @@ public expect inline fun maxOf(a: Double, b: Double, c: Double): Double
|
||||
* Returns the greater of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T
|
||||
public fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return maxOf(a, maxOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T
|
||||
public fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) >= 0) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T: Comparable<T>> minOf(a: T, b: T): T
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
@@ -175,7 +187,9 @@ public expect inline fun minOf(a: Double, b: Double): Double
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
@@ -203,7 +217,9 @@ public expect inline fun minOf(a: Int, b: Int, c: Int): Int
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun minOf(a: Long, b: Long, c: Long): Long
|
||||
public inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
@@ -223,12 +239,16 @@ public expect inline fun minOf(a: Double, b: Double, c: Double): Double
|
||||
* Returns the smaller of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T
|
||||
public fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return minOf(a, minOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T
|
||||
public fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) <= 0) a else b
|
||||
}
|
||||
|
||||
|
||||
@@ -15,130 +15,203 @@ import kotlin.comparisons.*
|
||||
/**
|
||||
* Returns a [List] containing all key-value pairs.
|
||||
*/
|
||||
public expect fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>>
|
||||
public fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> {
|
||||
if (size == 0)
|
||||
return emptyList()
|
||||
val iterator = entries.iterator()
|
||||
if (!iterator.hasNext())
|
||||
return emptyList()
|
||||
val first = iterator.next()
|
||||
if (!iterator.hasNext())
|
||||
return listOf(first.toPair())
|
||||
val result = ArrayList<Pair<K, V>>(size)
|
||||
result.add(first.toPair())
|
||||
do {
|
||||
result.add(iterator.next().toPair())
|
||||
} while (iterator.hasNext())
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
|
||||
*/
|
||||
public expect inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R>
|
||||
public inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of [transform] function being invoked on each entry of original map, to the given [destination].
|
||||
*/
|
||||
public expect inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.flatMapTo(destination: C, transform: (Map.Entry<K, V>) -> Iterable<R>): C
|
||||
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 {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing the results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public expect inline fun <K, V, R> Map<out K, V>.map(transform: (Map.Entry<K, V>) -> R): List<R>
|
||||
public inline fun <K, V, R> Map<out K, V>.map(transform: (Map.Entry<K, V>) -> R): List<R> {
|
||||
return mapTo(ArrayList<R>(size), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public expect inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(transform: (Map.Entry<K, V>) -> R?): List<R>
|
||||
public inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(transform: (Map.Entry<K, V>) -> R?): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each entry in the original map
|
||||
* and appends only the non-null results to the given [destination].
|
||||
*/
|
||||
public expect inline fun <K, V, R : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(destination: C, transform: (Map.Entry<K, V>) -> R?): C
|
||||
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 {
|
||||
forEach { element -> transform(element)?.let { destination.add(it) } }
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given [transform] function to each entry of the original map
|
||||
* and appends the results to the given [destination].
|
||||
*/
|
||||
public expect inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C
|
||||
public inline fun <K, V, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C {
|
||||
for (item in this)
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if all entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.all
|
||||
*/
|
||||
public expect inline fun <K, V> Map<out K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean
|
||||
public inline fun <K, V> Map<out K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (!predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if map has at least one entry.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.any
|
||||
*/
|
||||
public expect fun <K, V> Map<out K, V>.any(): Boolean
|
||||
public fun <K, V> Map<out K, V>.any(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if at least one entry matches the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
|
||||
*/
|
||||
public expect inline fun <K, V> Map<out K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean): Boolean
|
||||
public inline fun <K, V> Map<out K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return false
|
||||
for (element in this) if (predicate(element)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries in this map.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <K, V> Map<out K, V>.count(): Int
|
||||
public inline fun <K, V> Map<out K, V>.count(): Int {
|
||||
return size
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries matching the given [predicate].
|
||||
*/
|
||||
public expect inline fun <K, V> Map<out K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean): Int
|
||||
public inline fun <K, V> Map<out K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean): Int {
|
||||
if (isEmpty()) return 0
|
||||
var count = 0
|
||||
for (element in this) if (predicate(element)) count++
|
||||
return count
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry.
|
||||
*/
|
||||
@kotlin.internal.HidesMembers
|
||||
public expect inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit): Unit
|
||||
public inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit): Unit {
|
||||
for (element in this) action(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the largest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.maxBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry having the largest value according to the provided [comparator] or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
|
||||
public inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.maxWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the smallest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
public expect inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>?
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.minBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry having the smallest value according to the provided [comparator] or `null` if there are no entries.
|
||||
*/
|
||||
public expect fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?
|
||||
public fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.minWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the map has no entries.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.none
|
||||
*/
|
||||
public expect fun <K, V> Map<out K, V>.none(): Boolean
|
||||
public fun <K, V> Map<out K, V>.none(): Boolean {
|
||||
return isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if no entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
|
||||
*/
|
||||
public expect inline fun <K, V> Map<out K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean
|
||||
public inline fun <K, V> Map<out K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry and returns the map itself afterwards.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public expect inline fun <K, V, M : Map<out K, V>> M.onEach(action: (Map.Entry<K, V>) -> Unit): M
|
||||
public inline fun <K, V, M : Map<out K, V>> M.onEach(action: (Map.Entry<K, V>) -> Unit): M {
|
||||
return apply { for (element in this) action(element) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an [Iterable] instance that wraps the original map returning its entries when being iterated.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <K, V> Map<out K, V>.asIterable(): Iterable<Map.Entry<K, V>>
|
||||
public inline fun <K, V> Map<out K, V>.asIterable(): Iterable<Map.Entry<K, V>> {
|
||||
return entries
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [Sequence] instance that wraps the original map returning its entries when being iterated.
|
||||
*/
|
||||
public expect fun <K, V> Map<out K, V>.asSequence(): Sequence<Map.Entry<K, V>>
|
||||
public fun <K, V> Map<out K, V>.asSequence(): Sequence<Map.Entry<K, V>> {
|
||||
return entries.asSequence()
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,28 +17,49 @@ import kotlin.comparisons.*
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.minus(element: T): Set<T>
|
||||
public operator fun <T> Set<T>.minus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size))
|
||||
var removed = false
|
||||
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] array.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T>
|
||||
public operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] collection.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T>
|
||||
public operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> {
|
||||
val other = elements.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toSet()
|
||||
if (other is Set)
|
||||
return this.filterNotTo(LinkedHashSet<T>()) { it in other }
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(other)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] sequence.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T>
|
||||
public operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
@@ -46,14 +67,21 @@ public expect operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T>
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <T> Set<T>.minusElement(element: T): Set<T>
|
||||
public inline fun <T> Set<T>.minusElement(element: T): Set<T> {
|
||||
return minus(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.plus(element: T): Set<T>
|
||||
public operator fun <T> Set<T>.plus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size + 1))
|
||||
result.addAll(this)
|
||||
result.add(element)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] array,
|
||||
@@ -61,14 +89,24 @@ public expect operator fun <T> Set<T>.plus(element: T): Set<T>
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T>
|
||||
public operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size + elements.size))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] collection,
|
||||
* which aren't already in this set.
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T>
|
||||
public operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(elements.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] sequence,
|
||||
@@ -76,7 +114,12 @@ public expect operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T>
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public expect operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T>
|
||||
public operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
@@ -84,5 +127,7 @@ public expect operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T>
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public expect inline fun <T> Set<T>.plusElement(element: T): Set<T>
|
||||
public inline fun <T> Set<T>.plusElement(element: T): Set<T> {
|
||||
return plus(element)
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("CollectionsKt")
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Reverses elements in the list in-place.
|
||||
*/
|
||||
public actual fun <T> MutableList<T>.reverse(): Unit {
|
||||
val midPoint = (size / 2) - 1
|
||||
if (midPoint < 0) return
|
||||
var reverseIndex = lastIndex
|
||||
for (index in 0..midPoint) {
|
||||
val tmp = this[index]
|
||||
this[index] = this[reverseIndex]
|
||||
this[reverseIndex] = tmp
|
||||
reverseIndex--
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("ComparisonsKt")
|
||||
|
||||
package kotlin.comparisons
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.js.*
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Short, b: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Int, b: Int): Int {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public actual inline fun maxOf(a: Long, b: Long): Long {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Float, b: Float): Float {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Double, b: Double): Double {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Short, b: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Int, b: Int): Int {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public actual inline fun minOf(a: Long, b: Long): Long {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Float, b: Float): Float {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Double, b: Double): Double {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("CollectionsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a list containing all elements that are instances of specified class.
|
||||
*/
|
||||
public fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R> {
|
||||
return filterIsInstanceTo(ArrayList<R>(), klass)
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class to the given [destination].
|
||||
*/
|
||||
public fun <C : MutableCollection<in R>, R> Iterable<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverses elements in the list in-place.
|
||||
*/
|
||||
public actual fun <T> MutableList<T>.reverse(): Unit {
|
||||
java.util.Collections.reverse(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all elements.
|
||||
*/
|
||||
public fun <T: Comparable<T>> Iterable<T>.toSortedSet(): java.util.SortedSet<T> {
|
||||
return toCollection(java.util.TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all elements.
|
||||
*
|
||||
* Elements in the set returned are sorted according to the given [comparator].
|
||||
*/
|
||||
public fun <T> Iterable<T>.toSortedSet(comparator: Comparator<in T>): java.util.SortedSet<T> {
|
||||
return toCollection(java.util.TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("ComparisonsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.comparisons
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt()).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Short, b: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt()).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Int, b: Int): Int {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Long, b: Long): Long {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Float, b: Float): Float {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Double, b: Double): Double {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt()).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Short, b: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt()).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Int, b: Int): Int {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Long, b: Long): Long {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Float, b: Float): Float {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Double, b: Double): Double {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("SequencesKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.sequences
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
import kotlin.coroutines.experimental.*
|
||||
|
||||
/**
|
||||
* Returns a sequence containing all elements that are instances of specified class.
|
||||
*
|
||||
* The operation is _intermediate_ and _stateless_.
|
||||
*/
|
||||
public fun <R> Sequence<*>.filterIsInstance(klass: Class<R>): Sequence<R> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return filter { klass.isInstance(it) } as Sequence<R>
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class to the given [destination].
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
public fun <C : MutableCollection<in R>, R> Sequence<*>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all elements.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
public fun <T: Comparable<T>> Sequence<T>.toSortedSet(): java.util.SortedSet<T> {
|
||||
return toCollection(java.util.TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all elements.
|
||||
*
|
||||
* Elements in the set returned are sorted according to the given [comparator].
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
public fun <T> Sequence<T>.toSortedSet(comparator: Comparator<in T>): java.util.SortedSet<T> {
|
||||
return toCollection(java.util.TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("StringsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.text
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet][java.util.SortedSet] of all characters.
|
||||
*/
|
||||
public fun CharSequence.toSortedSet(): java.util.SortedSet<Char> {
|
||||
return toCollection(java.util.TreeSet<Char>())
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,299 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("ComparisonsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.comparisons
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt()).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Short, b: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt()).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Int, b: Int): Int {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Long, b: Long): Long {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Float, b: Float): Float {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Double, b: Double): Double {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
||||
return maxOf(a, maxOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return maxOf(a, maxOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the greater of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) >= 0) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt()).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Short, b: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt()).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Int, b: Int): Int {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Long, b: Long): Long {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Float, b: Float): Float {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Double, b: Double): Double {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).toByte()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).toShort()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Int, b: Int, c: Int): Int {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun minOf(a: Double, b: Double, c: Double): Double {
|
||||
return minOf(a, minOf(b, c))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values according to the order specified by the given [comparator].
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T {
|
||||
return minOf(a, minOf(b, c, comparator), comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values according to the order specified by the given [comparator].
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T {
|
||||
return if (comparator.compare(a, b) <= 0) a else b
|
||||
}
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("MapsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a [List] containing all key-value pairs.
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.toList(): List<Pair<K, V>> {
|
||||
if (size == 0)
|
||||
return emptyList()
|
||||
val iterator = entries.iterator()
|
||||
if (!iterator.hasNext())
|
||||
return emptyList()
|
||||
val first = iterator.next()
|
||||
if (!iterator.hasNext())
|
||||
return listOf(first.toPair())
|
||||
val result = ArrayList<Pair<K, V>>(size)
|
||||
result.add(first.toPair())
|
||||
do {
|
||||
result.add(iterator.next().toPair())
|
||||
} while (iterator.hasNext())
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each entry of original map.
|
||||
*/
|
||||
public inline fun <K, V, R> Map<out K, V>.flatMap(transform: (Map.Entry<K, V>) -> Iterable<R>): List<R> {
|
||||
return flatMapTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of [transform] function being invoked on each entry of original map, to the given [destination].
|
||||
*/
|
||||
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 {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing the results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public inline fun <K, V, R> Map<out K, V>.map(transform: (Map.Entry<K, V>) -> R): List<R> {
|
||||
return mapTo(ArrayList<R>(size), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list containing only the non-null results of applying the given [transform] function
|
||||
* to each entry in the original map.
|
||||
*/
|
||||
public inline fun <K, V, R : Any> Map<out K, V>.mapNotNull(transform: (Map.Entry<K, V>) -> R?): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 : Any, C : MutableCollection<in R>> Map<out K, V>.mapNotNullTo(destination: C, transform: (Map.Entry<K, V>) -> R?): C {
|
||||
forEach { element -> transform(element)?.let { destination.add(it) } }
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, R, C : MutableCollection<in R>> Map<out K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C {
|
||||
for (item in this)
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if all entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.all
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.all(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (!predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if map has at least one entry.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.any
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.any(): Boolean {
|
||||
return !isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if at least one entry matches the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.any(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return false
|
||||
for (element in this) if (predicate(element)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries in this map.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.count(): Int {
|
||||
return size
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of entries matching the given [predicate].
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.count(predicate: (Map.Entry<K, V>) -> Boolean): Int {
|
||||
if (isEmpty()) return 0
|
||||
var count = 0
|
||||
for (element in this) if (predicate(element)) count++
|
||||
return count
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry.
|
||||
*/
|
||||
@kotlin.internal.HidesMembers
|
||||
public inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit): Unit {
|
||||
for (element in this) action(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the largest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.maxBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.maxBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry having the largest value according to the provided [comparator] or `null` if there are no entries.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.maxWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry yielding the smallest value of the given function or `null` if there are no entries.
|
||||
*/
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return entries.minBy(selector)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return entries.minWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the map has no entries.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.none
|
||||
*/
|
||||
public fun <K, V> Map<out K, V>.none(): Boolean {
|
||||
return isEmpty()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if no entries match the given [predicate].
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
|
||||
*/
|
||||
public inline fun <K, V> Map<out K, V>.none(predicate: (Map.Entry<K, V>) -> Boolean): Boolean {
|
||||
if (isEmpty()) return true
|
||||
for (element in this) if (predicate(element)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the given [action] on each entry and returns the map itself afterwards.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public inline fun <K, V, M : Map<out K, V>> M.onEach(action: (Map.Entry<K, V>) -> Unit): M {
|
||||
return apply { for (element in this) action(element) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an [Iterable] instance that wraps the original map returning its entries when being iterated.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <K, V> Map<out K, V>.asIterable(): Iterable<Map.Entry<K, V>> {
|
||||
return entries
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [Sequence] 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>> {
|
||||
return entries.asSequence()
|
||||
}
|
||||
|
||||
@@ -1,961 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("RangesKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.ranges
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Byte): Boolean {
|
||||
return contains(value.toInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Byte): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Byte): Boolean {
|
||||
return contains(value.toShort())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Byte): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Byte): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Double): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Double): Boolean {
|
||||
return value.toLongExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Double): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Double): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Double): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Float): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Float): Boolean {
|
||||
return value.toLongExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Float): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Float): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Float): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Int): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Int): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Int): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Int): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Int): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Long): Boolean {
|
||||
return value.toIntExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Long): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("shortRangeContains")
|
||||
public operator fun ClosedRange<Short>.contains(value: Long): Boolean {
|
||||
return value.toShortExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Long): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Long): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("intRangeContains")
|
||||
public operator fun ClosedRange<Int>.contains(value: Short): Boolean {
|
||||
return contains(value.toInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("longRangeContains")
|
||||
public operator fun ClosedRange<Long>.contains(value: Short): Boolean {
|
||||
return contains(value.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("byteRangeContains")
|
||||
public operator fun ClosedRange<Byte>.contains(value: Short): Boolean {
|
||||
return value.toByteExactOrNull().let { if (it != null) contains(it) else false }
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
public operator fun ClosedRange<Double>.contains(value: Short): Boolean {
|
||||
return contains(value.toDouble())
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to this range.
|
||||
*/
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
public operator fun ClosedRange<Float>.contains(value: Short): Boolean {
|
||||
return contains(value.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Byte): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Byte): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Char.downTo(to: Char): CharProgression {
|
||||
return CharProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Int): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Int): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Int.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Long.downTo(to: Short): LongProgression {
|
||||
return LongProgression.fromClosedRange(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Byte.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the step -1.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public infix fun Short.downTo(to: Short): IntProgression {
|
||||
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun IntProgression.reversed(): IntProgression {
|
||||
return IntProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun LongProgression.reversed(): LongProgression {
|
||||
return LongProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun CharProgression.reversed(): CharProgression {
|
||||
return CharProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun IntProgression.step(step: Int): IntProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return IntProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun LongProgression.step(step: Long): LongProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun CharProgression.step(step: Int): CharProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
internal fun Int.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toInt()..Byte.MAX_VALUE.toInt()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Long.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toLong()..Byte.MAX_VALUE.toLong()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Short.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toShort()..Byte.MAX_VALUE.toShort()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Double.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toDouble()..Byte.MAX_VALUE.toDouble()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Float.toByteExactOrNull(): Byte? {
|
||||
return if (this in Byte.MIN_VALUE.toFloat()..Byte.MAX_VALUE.toFloat()) this.toByte() else null
|
||||
}
|
||||
|
||||
internal fun Long.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toLong()..Int.MAX_VALUE.toLong()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Double.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toDouble()..Int.MAX_VALUE.toDouble()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Float.toIntExactOrNull(): Int? {
|
||||
return if (this in Int.MIN_VALUE.toFloat()..Int.MAX_VALUE.toFloat()) this.toInt() else null
|
||||
}
|
||||
|
||||
internal fun Double.toLongExactOrNull(): Long? {
|
||||
return if (this in Long.MIN_VALUE.toDouble()..Long.MAX_VALUE.toDouble()) this.toLong() else null
|
||||
}
|
||||
|
||||
internal fun Float.toLongExactOrNull(): Long? {
|
||||
return if (this in Long.MIN_VALUE.toFloat()..Long.MAX_VALUE.toFloat()) this.toLong() else null
|
||||
}
|
||||
|
||||
internal fun Int.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toInt()..Short.MAX_VALUE.toInt()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Long.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toLong()..Short.MAX_VALUE.toLong()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Double.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toDouble()..Short.MAX_VALUE.toDouble()) this.toShort() else null
|
||||
}
|
||||
|
||||
internal fun Float.toShortExactOrNull(): Short? {
|
||||
return if (this in Short.MIN_VALUE.toFloat()..Short.MAX_VALUE.toFloat()) this.toShort() else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Int.until(to: Byte): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Byte): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Byte.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Short.until(to: Byte): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to `'\u0000'` the returned range is empty.
|
||||
*/
|
||||
public infix fun Char.until(to: Char): CharRange {
|
||||
if (to <= '\u0000') return CharRange.EMPTY
|
||||
return this .. (to - 1).toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Int): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Int.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Int): IntRange {
|
||||
if (to <= Int.MIN_VALUE) return IntRange.EMPTY
|
||||
return this.toInt() .. (to - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Int.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Long.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Byte.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*
|
||||
* If the [to] value is less than or equal to [Long.MIN_VALUE] the returned range is empty.
|
||||
*/
|
||||
public infix fun Short.until(to: Long): LongRange {
|
||||
if (to <= Long.MIN_VALUE) return LongRange.EMPTY
|
||||
return this.toLong() .. (to - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Int.until(to: Short): IntRange {
|
||||
return this .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Long.until(to: Short): LongRange {
|
||||
return this .. (to.toLong() - 1).toLong()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Byte.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
public infix fun Short.until(to: Short): IntRange {
|
||||
return this.toInt() .. (to.toInt() - 1).toInt()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeastComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceAtLeast(minimumValue: T): T {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Byte.coerceAtLeast(minimumValue: Byte): Byte {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Short.coerceAtLeast(minimumValue: Short): Short {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Int.coerceAtLeast(minimumValue: Int): Int {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Long.coerceAtLeast(minimumValue: Long): Long {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Float.coerceAtLeast(minimumValue: Float): Float {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not less than the specified [minimumValue].
|
||||
*
|
||||
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtLeast
|
||||
*/
|
||||
public fun Double.coerceAtLeast(minimumValue: Double): Double {
|
||||
return if (this < minimumValue) minimumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMostComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceAtMost(maximumValue: T): T {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Byte.coerceAtMost(maximumValue: Byte): Byte {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Short.coerceAtMost(maximumValue: Short): Short {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Int.coerceAtMost(maximumValue: Int): Int {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Long.coerceAtMost(maximumValue: Long): Long {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Float.coerceAtMost(maximumValue: Float): Float {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value is not greater than the specified [maximumValue].
|
||||
*
|
||||
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
|
||||
* @sample samples.comparisons.ComparableOps.coerceAtMost
|
||||
*/
|
||||
public fun Double.coerceAtMost(maximumValue: Double): Double {
|
||||
return if (this > maximumValue) maximumValue else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceInComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceIn(minimumValue: T?, maximumValue: T?): T {
|
||||
if (minimumValue !== null && maximumValue !== null) {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
}
|
||||
else {
|
||||
if (minimumValue !== null && this < minimumValue) return minimumValue
|
||||
if (maximumValue !== null && this > maximumValue) return maximumValue
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Byte.coerceIn(minimumValue: Byte, maximumValue: Byte): Byte {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Long.coerceIn(minimumValue: Long, maximumValue: Long): Long {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
|
||||
*
|
||||
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
|
||||
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
|
||||
if (this < minimumValue) return minimumValue
|
||||
if (this > maximumValue) return maximumValue
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceInFloatingPointRange
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
// this < start equiv to this <= start && !(this >= start)
|
||||
range.lessThanOrEquals(this, range.start) && !range.lessThanOrEquals(range.start, this) -> range.start
|
||||
// this > end equiv to this >= end && !(this <= end)
|
||||
range.lessThanOrEquals(range.endInclusive, this) && !range.lessThanOrEquals(this, range.endInclusive) -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceInComparable
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<T>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Int.coerceIn(range: ClosedRange<Int>): Int {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<Int>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
*
|
||||
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
|
||||
* @sample samples.comparisons.ComparableOps.coerceIn
|
||||
*/
|
||||
public fun Long.coerceIn(range: ClosedRange<Long>): Long {
|
||||
if (range is ClosedFloatingPointRange) {
|
||||
return this.coerceIn<Long>(range)
|
||||
}
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return when {
|
||||
this < range.start -> range.start
|
||||
this > range.endInclusive -> range.endInclusive
|
||||
else -> this
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +0,0 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("SetsKt")
|
||||
@file:kotlin.jvm.JvmVersion
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.*
|
||||
import kotlin.text.*
|
||||
import kotlin.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size))
|
||||
var removed = false
|
||||
return this.filterTo(result) { if (!removed && it == element) { removed = true; false } else true }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] array.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] collection.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Iterable<T>): Set<T> {
|
||||
val other = elements.convertToSetForSetOperationWith(this)
|
||||
if (other.isEmpty())
|
||||
return this.toSet()
|
||||
if (other is Set)
|
||||
return this.filterNotTo(LinkedHashSet<T>()) { it in other }
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(other)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the elements contained in the given [elements] sequence.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.minus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(this)
|
||||
result.removeAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set except the given [element].
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Set<T>.minusElement(element: T): Set<T> {
|
||||
return minus(element)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(element: T): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(size + 1))
|
||||
result.addAll(this)
|
||||
result.add(element)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] array,
|
||||
* which aren't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Array<out T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size + elements.size))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] collection,
|
||||
* which aren't already in this set.
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Iterable<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(elements.collectionSizeOrNull()?.let { this.size + it } ?: this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and the given [elements] sequence,
|
||||
* which aren't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
public operator fun <T> Set<T>.plus(elements: Sequence<T>): Set<T> {
|
||||
val result = LinkedHashSet<T>(mapCapacity(this.size * 2))
|
||||
result.addAll(this)
|
||||
result.addAll(elements)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set containing all elements of the original set and then the given [element] if it isn't already in this set.
|
||||
*
|
||||
* The returned set preserves the element iteration order of the original set.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Set<T>.plusElement(element: T): Set<T> {
|
||||
return plus(element)
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,14 +37,14 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
val commonDir = baseDir.resolveExistingDir("libraries/stdlib/common/src/generated")
|
||||
val jvmDir = baseDir.resolveExistingDir("libraries/stdlib/src/generated")
|
||||
val jsDir = baseDir.resolveExistingDir("js/js.libraries/src/core/generated")
|
||||
val jvmDir = baseDir.resolveExistingDir("libraries/stdlib/jvm/src/generated")
|
||||
val jsDir = baseDir.resolveExistingDir("libraries/stdlib/js/src/generated")
|
||||
|
||||
templateGroups.groupByFileAndWrite { (platform, source) ->
|
||||
// File("build/out/$platform/$source.kt")
|
||||
when (platform) {
|
||||
Platform.Common -> commonDir.resolve("_${source.name.capitalize()}.kt")
|
||||
Platform.JVM -> jvmDir.resolve("_${source.name.capitalize()}.kt")
|
||||
Platform.JVM -> jvmDir.resolve("_${source.name.capitalize()}Jvm.kt")
|
||||
Platform.JS -> jsDir.resolve("_${source.name.capitalize()}Js.kt")
|
||||
Platform.Native -> error("Native is unsupported yet")
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class MemberBuilder(
|
||||
|
||||
val f get() = family
|
||||
|
||||
private val legacyMode = true
|
||||
private val legacyMode = false
|
||||
var hasPlatformSpecializations: Boolean = legacyMode
|
||||
private set
|
||||
|
||||
|
||||
Reference in New Issue
Block a user