maxWith

@JvmName(name = "maxWithOrThrow")
fun <T> Array<out T>.maxWith(comparator: Comparator<in T>): T(source)
@JvmName(name = "maxWithOrThrow")
fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte(source)
@JvmName(name = "maxWithOrThrow")
fun ShortArray.maxWith(comparator: Comparator<in Short>): Short(source)
@JvmName(name = "maxWithOrThrow")
fun IntArray.maxWith(comparator: Comparator<in Int>): Int(source)
@JvmName(name = "maxWithOrThrow")
fun LongArray.maxWith(comparator: Comparator<in Long>): Long(source)
@JvmName(name = "maxWithOrThrow")
fun FloatArray.maxWith(comparator: Comparator<in Float>): Float(source)
@JvmName(name = "maxWithOrThrow")
fun DoubleArray.maxWith(comparator: Comparator<in Double>): Double(source)
@JvmName(name = "maxWithOrThrow")
fun BooleanArray.maxWith(comparator: Comparator<in Boolean>): Boolean(source)
@JvmName(name = "maxWithOrThrow")
fun CharArray.maxWith(comparator: Comparator<in Char>): Char(source)
@JvmName(name = "maxWithOrThrow-U")
fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt(source)
@JvmName(name = "maxWithOrThrow-U")
fun ULongArray.maxWith(comparator: Comparator<in ULong>): ULong(source)
@JvmName(name = "maxWithOrThrow-U")
fun UByteArray.maxWith(comparator: Comparator<in UByte>): UByte(source)
@JvmName(name = "maxWithOrThrow-U")
fun UShortArray.maxWith(comparator: Comparator<in UShort>): UShort(source)

Returns the first element having the largest value according to the provided comparator.

Since Kotlin

1.7

Throws

if the array is empty.


@JvmName(name = "maxWithOrThrow")
fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T(source)

Returns the first element having the largest value according to the provided comparator.

Since Kotlin

1.7

Throws

if the collection is empty.


@JvmName(name = "maxWithOrThrow")
inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>(source)

Returns the first entry having the largest value according to the provided comparator.

Since Kotlin

1.7

Throws

if the map is empty.

fun <T> Array<out T>.maxWith(comparator: Comparator<in T>): T?(source)
fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte?(source)
fun ShortArray.maxWith(comparator: Comparator<in Short>): Short?(source)
fun IntArray.maxWith(comparator: Comparator<in Int>): Int?(source)
fun LongArray.maxWith(comparator: Comparator<in Long>): Long?(source)
fun FloatArray.maxWith(comparator: Comparator<in Float>): Float?(source)
fun CharArray.maxWith(comparator: Comparator<in Char>): Char?(source)
fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T?(source)
inline fun <K, V> Map<out K, V>.maxWith(comparator: Comparator<in Map.Entry<K, V>>): Map.Entry<K, V>?(source)

Deprecated

Warning since 1.4

Error since 1.5

Hidden since 1.6

Use maxWithOrNull instead.

Replace with

this.maxWithOrNull(comparator)

Since Kotlin

1.0

Deprecated

Warning since 1.4

Error since 1.5

Hidden since 1.6

Use maxWithOrNull instead.

Replace with

this.maxWithOrNull(comparator)

Since Kotlin

1.3