Reintroduce min/max operations for non-empty collections KT-50146
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1861,30 +1861,92 @@ public inline fun <T> Iterable<T>.forEachIndexed(action: (index: Int, T) -> Unit
|
||||
for (item in this) action(checkIndexOverflow(index++), item)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Iterable<Double>.max(): Double? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Iterable<Double>.max(): Double {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
max = maxOf(max, e)
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Iterable<Float>.max(): Float? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Iterable<Float>.max(): Float {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
max = maxOf(max, e)
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T : Comparable<T>> Iterable<T>.max(): T? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T : Comparable<T>> Iterable<T>.max(): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T? {
|
||||
return maxByOrNull(selector)
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T) -> R): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var maxElem = iterator.next()
|
||||
if (!iterator.hasNext()) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
do {
|
||||
val e = iterator.next()
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
} while (iterator.hasNext())
|
||||
return maxElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2135,10 +2197,23 @@ public fun <T : Comparable<T>> Iterable<T>.maxOrNull(): T? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T? {
|
||||
return maxWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2156,30 +2231,92 @@ public fun <T> Iterable<T>.maxWithOrNull(comparator: Comparator<in T>): T? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Iterable<Double>.min(): Double? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Iterable<Double>.min(): Double {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
min = minOf(min, e)
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Iterable<Float>.min(): Float? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Iterable<Float>.min(): Float {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
min = minOf(min, e)
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T : Comparable<T>> Iterable<T>.min(): T? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T : Comparable<T>> Iterable<T>.min(): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T? {
|
||||
return minByOrNull(selector)
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <T, R : Comparable<R>> Iterable<T>.minBy(selector: (T) -> R): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var minElem = iterator.next()
|
||||
if (!iterator.hasNext()) return minElem
|
||||
var minValue = selector(minElem)
|
||||
do {
|
||||
val e = iterator.next()
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
} while (iterator.hasNext())
|
||||
return minElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2430,10 +2567,23 @@ public fun <T : Comparable<T>> Iterable<T>.minOrNull(): T? {
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T? {
|
||||
return minWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,11 +211,19 @@ public inline fun <K, V> Map<out K, V>.forEach(action: (Map.Entry<K, V>) -> Unit
|
||||
for (element in this) action(element)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
/**
|
||||
* Returns the first entry yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the map is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow")
|
||||
@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 maxByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,11 +349,17 @@ public inline fun <K, V, R> Map<out K, V>.maxOfWithOrNull(comparator: Comparator
|
||||
return entries.maxOfWithOrNull(comparator, selector)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
/**
|
||||
* Returns the first entry having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the map is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow")
|
||||
@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 maxWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,10 +371,19 @@ public inline fun <K, V> Map<out K, V>.maxWithOrNull(comparator: Comparator<in M
|
||||
return entries.maxWithOrNull(comparator)
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <K, V, R : Comparable<R>> Map<out K, V>.minBy(selector: (Map.Entry<K, V>) -> R): Map.Entry<K, V>? {
|
||||
return minByOrNull(selector)
|
||||
/**
|
||||
* Returns the first entry yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the map is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,10 +509,17 @@ public inline fun <K, V, R> Map<out K, V>.minOfWithOrNull(comparator: Comparator
|
||||
return entries.minOfWithOrNull(comparator, selector)
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>? {
|
||||
return minWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first entry having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the map is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <K, V> Map<out K, V>.minWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V> {
|
||||
return entries.minWith(comparator)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1303,30 +1303,100 @@ public inline fun <T> Sequence<T>.forEachIndexed(action: (index: Int, T) -> Unit
|
||||
for (item in this) action(checkIndexOverflow(index++), item)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Sequence<Double>.max(): Double? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Sequence<Double>.max(): Double {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
max = maxOf(max, e)
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Sequence<Float>.max(): Float? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Sequence<Float>.max(): Float {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
max = maxOf(max, e)
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T : Comparable<T>> Sequence<T>.max(): T? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T : Comparable<T>> Sequence<T>.max(): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(selector: (T) -> R): T? {
|
||||
return maxByOrNull(selector)
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <T, R : Comparable<R>> Sequence<T>.maxBy(selector: (T) -> R): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var maxElem = iterator.next()
|
||||
if (!iterator.hasNext()) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
do {
|
||||
val e = iterator.next()
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
} while (iterator.hasNext())
|
||||
return maxElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1359,10 +1429,10 @@ public inline fun <T, R : Comparable<R>> Sequence<T>.maxByOrNull(selector: (T) -
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1384,10 +1454,10 @@ public inline fun <T> Sequence<T>.maxOf(selector: (T) -> Double): Double {
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1407,10 +1477,10 @@ public inline fun <T> Sequence<T>.maxOf(selector: (T) -> Float): Float {
|
||||
/**
|
||||
* Returns the largest value among all values produced by [selector] function
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1601,10 +1671,25 @@ public fun <T : Comparable<T>> Sequence<T>.maxOrNull(): T? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T? {
|
||||
return maxWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T> Sequence<T>.maxWith(comparator: Comparator<in T>): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var max = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1624,30 +1709,100 @@ public fun <T> Sequence<T>.maxWithOrNull(comparator: Comparator<in T>): T? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Sequence<Double>.min(): Double? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Sequence<Double>.min(): Double {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
min = minOf(min, e)
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.1")
|
||||
public fun Sequence<Float>.min(): Float? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* If any of elements is `NaN` returns `NaN`.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun Sequence<Float>.min(): Float {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
min = minOf(min, e)
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T : Comparable<T>> Sequence<T>.min(): T? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T : Comparable<T>> Sequence<T>.min(): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <T, R : Comparable<R>> Sequence<T>.minBy(selector: (T) -> R): T? {
|
||||
return minByOrNull(selector)
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <T, R : Comparable<R>> Sequence<T>.minBy(selector: (T) -> R): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var minElem = iterator.next()
|
||||
if (!iterator.hasNext()) return minElem
|
||||
var minValue = selector(minElem)
|
||||
do {
|
||||
val e = iterator.next()
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
} while (iterator.hasNext())
|
||||
return minElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1680,10 +1835,10 @@ public inline fun <T, R : Comparable<R>> Sequence<T>.minByOrNull(selector: (T) -
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1705,10 +1860,10 @@ public inline fun <T> Sequence<T>.minOf(selector: (T) -> Double): Double {
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1728,10 +1883,10 @@ public inline fun <T> Sequence<T>.minOf(selector: (T) -> Float): Float {
|
||||
/**
|
||||
* Returns the smallest value among all values produced by [selector] function
|
||||
* applied to each element in the sequence.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@@ -1922,10 +2077,25 @@ public fun <T : Comparable<T>> Sequence<T>.minOrNull(): T? {
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T? {
|
||||
return minWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*
|
||||
* @throws NoSuchElementException if the sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun <T> Sequence<T>.minWith(comparator: Comparator<in T>): T {
|
||||
val iterator = iterator()
|
||||
if (!iterator.hasNext()) throw NoSuchElementException()
|
||||
var min = iterator.next()
|
||||
while (iterator.hasNext()) {
|
||||
val e = iterator.next()
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1180,16 +1180,49 @@ public inline fun CharSequence.forEachIndexed(action: (index: Int, Char) -> Unit
|
||||
for (item in this) action(index++, item)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun CharSequence.max(): Char? {
|
||||
return maxOrNull()
|
||||
/**
|
||||
* Returns the largest character.
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun CharSequence.max(): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <R : Comparable<R>> CharSequence.maxBy(selector: (Char) -> R): Char? {
|
||||
return maxByOrNull(selector)
|
||||
/**
|
||||
* Returns the first character yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> CharSequence.maxBy(selector: (Char) -> R): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var maxElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1397,10 +1430,22 @@ public fun CharSequence.maxOrNull(): Char? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun CharSequence.maxWith(comparator: Comparator<in Char>): Char? {
|
||||
return maxWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first character having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun CharSequence.maxWith(comparator: Comparator<in Char>): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1417,16 +1462,49 @@ public fun CharSequence.maxWithOrNull(comparator: Comparator<in Char>): Char? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun CharSequence.min(): Char? {
|
||||
return minOrNull()
|
||||
/**
|
||||
* Returns the smallest character.
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun CharSequence.min(): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public inline fun <R : Comparable<R>> CharSequence.minBy(selector: (Char) -> R): Char? {
|
||||
return minByOrNull(selector)
|
||||
/**
|
||||
* Returns the first character yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> CharSequence.minBy(selector: (Char) -> R): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var minElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return minElem
|
||||
var minValue = selector(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1634,10 +1712,22 @@ public fun CharSequence.minOrNull(): Char? {
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
public fun CharSequence.minWith(comparator: Comparator<in Char>): Char? {
|
||||
return minWithOrNull(comparator)
|
||||
/**
|
||||
* Returns the first character having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the char sequence is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow")
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun CharSequence.minWith(comparator: Comparator<in Char>): Char {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5946,72 +5946,196 @@ public inline fun UShortArray.forEachIndexed(action: (index: Int, UShort) -> Uni
|
||||
for (item in this) action(index++, item)
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UIntArray.max(): UInt? {
|
||||
return maxOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UIntArray.max(): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun ULongArray.max(): ULong? {
|
||||
return maxOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun ULongArray.max(): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UByteArray.max(): UByte? {
|
||||
return maxOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UByteArray.max(): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the largest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UShortArray.max(): UShort? {
|
||||
return maxOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UShortArray.max(): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (max < e) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UIntArray.maxBy(selector: (UInt) -> R): UInt? {
|
||||
return maxByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UIntArray.maxBy(selector: (UInt) -> R): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var maxElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> ULongArray.maxBy(selector: (ULong) -> R): ULong? {
|
||||
return maxByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> ULongArray.maxBy(selector: (ULong) -> R): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var maxElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UByteArray.maxBy(selector: (UByte) -> R): UByte? {
|
||||
return maxByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UByteArray.maxBy(selector: (UByte) -> R): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var maxElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
}
|
||||
|
||||
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the largest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.maxBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UShortArray.maxBy(selector: (UShort) -> R): UShort? {
|
||||
return maxByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UShortArray.maxBy(selector: (UShort) -> R): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var maxElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return maxElem
|
||||
var maxValue = selector(maxElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (maxValue < v) {
|
||||
maxElem = e
|
||||
maxValue = v
|
||||
}
|
||||
}
|
||||
return maxElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6878,36 +7002,80 @@ public fun UShortArray.maxOrNull(): UShort? {
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt? {
|
||||
return maxWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun ULongArray.maxWith(comparator: Comparator<in ULong>): ULong? {
|
||||
return maxWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun ULongArray.maxWith(comparator: Comparator<in ULong>): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UByteArray.maxWith(comparator: Comparator<in UByte>): UByte? {
|
||||
return maxWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UByteArray.maxWith(comparator: Comparator<in UByte>): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the largest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("maxWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UShortArray.maxWith(comparator: Comparator<in UShort>): UShort? {
|
||||
return maxWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UShortArray.maxWith(comparator: Comparator<in UShort>): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var max = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(max, e) < 0) max = e
|
||||
}
|
||||
return max
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6970,72 +7138,196 @@ public fun UShortArray.maxWithOrNull(comparator: Comparator<in UShort>): UShort?
|
||||
return max
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UIntArray.min(): UInt? {
|
||||
return minOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UIntArray.min(): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun ULongArray.min(): ULong? {
|
||||
return minOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun ULongArray.min(): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UByteArray.min(): UByte? {
|
||||
return minOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UByteArray.min(): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the smallest element.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UShortArray.min(): UShort? {
|
||||
return minOrNull()
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UShortArray.min(): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (min > e) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UIntArray.minBy(selector: (UInt) -> R): UInt? {
|
||||
return minByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UIntArray.minBy(selector: (UInt) -> R): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var minElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return minElem
|
||||
var minValue = selector(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> ULongArray.minBy(selector: (ULong) -> R): ULong? {
|
||||
return minByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> ULongArray.minBy(selector: (ULong) -> R): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var minElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return minElem
|
||||
var minValue = selector(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UByteArray.minBy(selector: (UByte) -> R): UByte? {
|
||||
return minByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UByteArray.minBy(selector: (UByte) -> R): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var minElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return minElem
|
||||
var minValue = selector(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
}
|
||||
|
||||
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element yielding the smallest value of the given function.
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*
|
||||
* @sample samples.collections.Collections.Aggregates.minBy
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minByOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R : Comparable<R>> UShortArray.minBy(selector: (UShort) -> R): UShort? {
|
||||
return minByOrNull(selector)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public inline fun <R : Comparable<R>> UShortArray.minBy(selector: (UShort) -> R): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var minElem = this[0]
|
||||
val lastIndex = this.lastIndex
|
||||
if (lastIndex == 0) return minElem
|
||||
var minValue = selector(minElem)
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
val v = selector(e)
|
||||
if (minValue > v) {
|
||||
minElem = e
|
||||
minValue = v
|
||||
}
|
||||
}
|
||||
return minElem
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7902,36 +8194,80 @@ public fun UShortArray.minOrNull(): UShort? {
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt? {
|
||||
return minWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun ULongArray.minWith(comparator: Comparator<in ULong>): ULong? {
|
||||
return minWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun ULongArray.minWith(comparator: Comparator<in ULong>): ULong {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UByteArray.minWith(comparator: Comparator<in UByte>): UByte? {
|
||||
return minWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UByteArray.minWith(comparator: Comparator<in UByte>): UByte {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
|
||||
@SinceKotlin("1.3")
|
||||
/**
|
||||
* Returns the first element having the smallest value according to the provided [comparator].
|
||||
*
|
||||
* @throws NoSuchElementException if the array is empty.
|
||||
*/
|
||||
@SinceKotlin("1.7")
|
||||
@kotlin.jvm.JvmName("minWithOrThrow-U")
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UShortArray.minWith(comparator: Comparator<in UShort>): UShort? {
|
||||
return minWithOrNull(comparator)
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
public fun UShortArray.minWith(comparator: Comparator<in UShort>): UShort {
|
||||
if (isEmpty()) throw NoSuchElementException()
|
||||
var min = this[0]
|
||||
for (i in 1..lastIndex) {
|
||||
val e = this[i]
|
||||
if (comparator.compare(min, e) > 0) min = e
|
||||
}
|
||||
return min
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user