Introduce minOf/maxOf in kotlin.comparisons. #KT-7417
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
@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.comparisons.*
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T: Comparable<T>> maxOf(a: T, b: T): T
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Byte, b: Byte): Byte
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Short, b: Short): Short
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Int, b: Int): Int
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Long, b: Long): Long
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Float, b: Float): Float
|
||||
|
||||
/**
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Double, b: Double): Double
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Short, b: Short, c: Short): Short
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Int, b: Int, c: Int): Int
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Long, b: Long, c: Long): Long
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun maxOf(a: Float, b: Float, c: Float): Float
|
||||
|
||||
/**
|
||||
* Returns the greater of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header 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 header fun <T> maxOf(a: T, b: T, c: T, comparator: Comparator<in T>): T
|
||||
|
||||
/**
|
||||
* 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 header fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
* If values are equal, returns the first one.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T: Comparable<T>> minOf(a: T, b: T): T
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Byte, b: Byte): Byte
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Short, b: Short): Short
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Int, b: Int): Int
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Long, b: Long): Long
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Float, b: Float): Float
|
||||
|
||||
/**
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Double, b: Double): Double
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
public header fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Byte, b: Byte, c: Byte): Byte
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Short, b: Short, c: Short): Short
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Int, b: Int, c: Int): Int
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Long, b: Long, c: Long): Long
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header inline fun minOf(a: Float, b: Float, c: Float): Float
|
||||
|
||||
/**
|
||||
* Returns the smaller of three values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
public header 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 header fun <T> minOf(a: T, b: T, c: T, comparator: Comparator<in T>): T
|
||||
|
||||
/**
|
||||
* 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 header fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
@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.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
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
@file:kotlin.jvm.JvmName("ComparisonsKt")
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
|
||||
package kotlin.comparisons
|
||||
|
||||
|
||||
Reference in New Issue
Block a user