Introduce new overloads of max and min to fix NaN propagation behavior on JVM.

This commit is contained in:
Ilya Gorbunov
2016-12-28 04:08:05 +03:00
parent 74331f8eaa
commit 0bf2ba8701
11 changed files with 557 additions and 61 deletions
@@ -765,6 +765,18 @@ public header inline fun <T> Iterable<T>.forEach(action: (T) -> Unit): Unit
*/
public header inline fun <T> Iterable<T>.forEachIndexed(action: (Int, T) -> Unit): Unit
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.1")
public header fun Iterable<Double>.max(): Double?
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.1")
public header fun Iterable<Float>.max(): Float?
/**
* Returns the largest element or `null` if there are no elements.
*/
@@ -780,6 +792,18 @@ public header inline fun <T, R : Comparable<R>> Iterable<T>.maxBy(selector: (T)
*/
public header fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T?
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.1")
public header fun Iterable<Double>.min(): Double?
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.1")
public header fun Iterable<Float>.min(): Float?
/**
* Returns the smallest element or `null` if there are no elements.
*/