Files
kotlin-fork/libraries/stdlib/common/src/generated/_UArrays.kt
T
2021-09-16 19:38:35 +03:00

10521 lines
340 KiB
Kotlin

/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("UArraysKt")
@file:kotlin.jvm.JvmPackageName("kotlin.collections.unsigned")
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.random.*
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns 1st *element* from the array.
*
* If the size of this array is less than 1, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.component1(): UInt {
return get(0)
}
/**
* Returns 1st *element* from the array.
*
* If the size of this array is less than 1, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.component1(): ULong {
return get(0)
}
/**
* Returns 1st *element* from the array.
*
* If the size of this array is less than 1, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.component1(): UByte {
return get(0)
}
/**
* Returns 1st *element* from the array.
*
* If the size of this array is less than 1, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.component1(): UShort {
return get(0)
}
/**
* Returns 2nd *element* from the array.
*
* If the size of this array is less than 2, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.component2(): UInt {
return get(1)
}
/**
* Returns 2nd *element* from the array.
*
* If the size of this array is less than 2, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.component2(): ULong {
return get(1)
}
/**
* Returns 2nd *element* from the array.
*
* If the size of this array is less than 2, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.component2(): UByte {
return get(1)
}
/**
* Returns 2nd *element* from the array.
*
* If the size of this array is less than 2, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.component2(): UShort {
return get(1)
}
/**
* Returns 3rd *element* from the array.
*
* If the size of this array is less than 3, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.component3(): UInt {
return get(2)
}
/**
* Returns 3rd *element* from the array.
*
* If the size of this array is less than 3, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.component3(): ULong {
return get(2)
}
/**
* Returns 3rd *element* from the array.
*
* If the size of this array is less than 3, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.component3(): UByte {
return get(2)
}
/**
* Returns 3rd *element* from the array.
*
* If the size of this array is less than 3, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.component3(): UShort {
return get(2)
}
/**
* Returns 4th *element* from the array.
*
* If the size of this array is less than 4, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.component4(): UInt {
return get(3)
}
/**
* Returns 4th *element* from the array.
*
* If the size of this array is less than 4, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.component4(): ULong {
return get(3)
}
/**
* Returns 4th *element* from the array.
*
* If the size of this array is less than 4, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.component4(): UByte {
return get(3)
}
/**
* Returns 4th *element* from the array.
*
* If the size of this array is less than 4, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.component4(): UShort {
return get(3)
}
/**
* Returns 5th *element* from the array.
*
* If the size of this array is less than 5, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.component5(): UInt {
return get(4)
}
/**
* Returns 5th *element* from the array.
*
* If the size of this array is less than 5, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.component5(): ULong {
return get(4)
}
/**
* Returns 5th *element* from the array.
*
* If the size of this array is less than 5, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.component5(): UByte {
return get(4)
}
/**
* Returns 5th *element* from the array.
*
* If the size of this array is less than 5, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.component5(): UShort {
return get(4)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UIntArray.elementAt(index: Int): UInt
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun ULongArray.elementAt(index: Int): ULong
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UByteArray.elementAt(index: Int): UByte
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UShortArray.elementAt(index: Int): UShort
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrElse
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.elementAtOrElse(index: Int, defaultValue: (Int) -> UInt): UInt {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrElse
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.elementAtOrElse(index: Int, defaultValue: (Int) -> ULong): ULong {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrElse
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.elementAtOrElse(index: Int, defaultValue: (Int) -> UByte): UByte {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrElse
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> UShort): UShort {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.elementAtOrNull(index: Int): UInt? {
return this.getOrNull(index)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.elementAtOrNull(index: Int): ULong? {
return this.getOrNull(index)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.elementAtOrNull(index: Int): UByte? {
return this.getOrNull(index)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAtOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.elementAtOrNull(index: Int): UShort? {
return this.getOrNull(index)
}
/**
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.find(predicate: (UInt) -> Boolean): UInt? {
return firstOrNull(predicate)
}
/**
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.find(predicate: (ULong) -> Boolean): ULong? {
return firstOrNull(predicate)
}
/**
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.find(predicate: (UByte) -> Boolean): UByte? {
return firstOrNull(predicate)
}
/**
* Returns the first element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.find(predicate: (UShort) -> Boolean): UShort? {
return firstOrNull(predicate)
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.findLast(predicate: (UInt) -> Boolean): UInt? {
return lastOrNull(predicate)
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.findLast(predicate: (ULong) -> Boolean): ULong? {
return lastOrNull(predicate)
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.findLast(predicate: (UByte) -> Boolean): UByte? {
return lastOrNull(predicate)
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.find
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.findLast(predicate: (UShort) -> Boolean): UShort? {
return lastOrNull(predicate)
}
/**
* Returns first element.
* @throws [NoSuchElementException] if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.first(): UInt {
return storage.first().toUInt()
}
/**
* Returns first element.
* @throws [NoSuchElementException] if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.first(): ULong {
return storage.first().toULong()
}
/**
* Returns first element.
* @throws [NoSuchElementException] if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.first(): UByte {
return storage.first().toUByte()
}
/**
* Returns first element.
* @throws [NoSuchElementException] if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.first(): UShort {
return storage.first().toUShort()
}
/**
* Returns the first element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.first(predicate: (UInt) -> Boolean): UInt {
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the first element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.first(predicate: (ULong) -> Boolean): ULong {
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the first element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.first(predicate: (UByte) -> Boolean): UByte {
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the first element matching the given [predicate].
* @throws [NoSuchElementException] if no such element is found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.first(predicate: (UShort) -> Boolean): UShort {
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the first element, or `null` if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.firstOrNull(): UInt? {
return if (isEmpty()) null else this[0]
}
/**
* Returns the first element, or `null` if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.firstOrNull(): ULong? {
return if (isEmpty()) null else this[0]
}
/**
* Returns the first element, or `null` if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.firstOrNull(): UByte? {
return if (isEmpty()) null else this[0]
}
/**
* Returns the first element, or `null` if the array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.firstOrNull(): UShort? {
return if (isEmpty()) null else this[0]
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.firstOrNull(predicate: (UInt) -> Boolean): UInt? {
for (element in this) if (predicate(element)) return element
return null
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.firstOrNull(predicate: (ULong) -> Boolean): ULong? {
for (element in this) if (predicate(element)) return element
return null
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.firstOrNull(predicate: (UByte) -> Boolean): UByte? {
for (element in this) if (predicate(element)) return element
return null
}
/**
* Returns the first element matching the given [predicate], or `null` if element was not found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.firstOrNull(predicate: (UShort) -> Boolean): UShort? {
for (element in this) if (predicate(element)) return element
return null
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.getOrElse(index: Int, defaultValue: (Int) -> UInt): UInt {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.getOrElse(index: Int, defaultValue: (Int) -> ULong): ULong {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.getOrElse(index: Int, defaultValue: (Int) -> UByte): UByte {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.getOrElse(index: Int, defaultValue: (Int) -> UShort): UShort {
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.getOrNull(index: Int): UInt? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.getOrNull(index: Int): ULong? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.getOrNull(index: Int): UByte? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.getOrNull
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.getOrNull(index: Int): UShort? {
return if (index >= 0 && index <= lastIndex) get(index) else null
}
/**
* Returns first index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.indexOf(element: UInt): Int {
return storage.indexOf(element.toInt())
}
/**
* Returns first index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.indexOf(element: ULong): Int {
return storage.indexOf(element.toLong())
}
/**
* Returns first index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.indexOf(element: UByte): Int {
return storage.indexOf(element.toByte())
}
/**
* Returns first index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.indexOf(element: UShort): Int {
return storage.indexOf(element.toShort())
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.indexOfFirst(predicate: (UInt) -> Boolean): Int {
return storage.indexOfFirst { predicate(it.toUInt()) }
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.indexOfFirst(predicate: (ULong) -> Boolean): Int {
return storage.indexOfFirst { predicate(it.toULong()) }
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.indexOfFirst(predicate: (UByte) -> Boolean): Int {
return storage.indexOfFirst { predicate(it.toUByte()) }
}
/**
* Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.indexOfFirst(predicate: (UShort) -> Boolean): Int {
return storage.indexOfFirst { predicate(it.toUShort()) }
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.indexOfLast(predicate: (UInt) -> Boolean): Int {
return storage.indexOfLast { predicate(it.toUInt()) }
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.indexOfLast(predicate: (ULong) -> Boolean): Int {
return storage.indexOfLast { predicate(it.toULong()) }
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.indexOfLast(predicate: (UByte) -> Boolean): Int {
return storage.indexOfLast { predicate(it.toUByte()) }
}
/**
* Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.indexOfLast(predicate: (UShort) -> Boolean): Int {
return storage.indexOfLast { predicate(it.toUShort()) }
}
/**
* Returns the last element.
*
* @throws NoSuchElementException if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.last(): UInt {
return storage.last().toUInt()
}
/**
* Returns the last element.
*
* @throws NoSuchElementException if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.last(): ULong {
return storage.last().toULong()
}
/**
* Returns the last element.
*
* @throws NoSuchElementException if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.last(): UByte {
return storage.last().toUByte()
}
/**
* Returns the last element.
*
* @throws NoSuchElementException if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.last(): UShort {
return storage.last().toUShort()
}
/**
* Returns the last element matching the given [predicate].
*
* @throws NoSuchElementException if no such element is found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.last(predicate: (UInt) -> Boolean): UInt {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the last element matching the given [predicate].
*
* @throws NoSuchElementException if no such element is found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.last(predicate: (ULong) -> Boolean): ULong {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the last element matching the given [predicate].
*
* @throws NoSuchElementException if no such element is found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.last(predicate: (UByte) -> Boolean): UByte {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns the last element matching the given [predicate].
*
* @throws NoSuchElementException if no such element is found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.last(predicate: (UShort) -> Boolean): UShort {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
throw NoSuchElementException("Array contains no element matching the predicate.")
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.lastIndexOf(element: UInt): Int {
return storage.lastIndexOf(element.toInt())
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.lastIndexOf(element: ULong): Int {
return storage.lastIndexOf(element.toLong())
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.lastIndexOf(element: UByte): Int {
return storage.lastIndexOf(element.toByte())
}
/**
* Returns last index of [element], or -1 if the array does not contain element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.lastIndexOf(element: UShort): Int {
return storage.lastIndexOf(element.toShort())
}
/**
* Returns the last element, or `null` if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.lastOrNull(): UInt? {
return if (isEmpty()) null else this[size - 1]
}
/**
* Returns the last element, or `null` if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.lastOrNull(): ULong? {
return if (isEmpty()) null else this[size - 1]
}
/**
* Returns the last element, or `null` if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.lastOrNull(): UByte? {
return if (isEmpty()) null else this[size - 1]
}
/**
* Returns the last element, or `null` if the array is empty.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.lastOrNull(): UShort? {
return if (isEmpty()) null else this[size - 1]
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.lastOrNull(predicate: (UInt) -> Boolean): UInt? {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
return null
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.lastOrNull(predicate: (ULong) -> Boolean): ULong? {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
return null
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.lastOrNull(predicate: (UByte) -> Boolean): UByte? {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
return null
}
/**
* Returns the last element matching the given [predicate], or `null` if no such element was found.
*
* @sample samples.collections.Collections.Elements.last
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.lastOrNull(predicate: (UShort) -> Boolean): UShort? {
for (index in this.indices.reversed()) {
val element = this[index]
if (predicate(element)) return element
}
return null
}
/**
* Returns a random element from this array.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.random(): UInt {
return random(Random)
}
/**
* Returns a random element from this array.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.random(): ULong {
return random(Random)
}
/**
* Returns a random element from this array.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.random(): UByte {
return random(Random)
}
/**
* Returns a random element from this array.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.random(): UShort {
return random(Random)
}
/**
* Returns a random element from this array using the specified source of randomness.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.random(random: Random): UInt {
if (isEmpty())
throw NoSuchElementException("Array is empty.")
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.random(random: Random): ULong {
if (isEmpty())
throw NoSuchElementException("Array is empty.")
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.random(random: Random): UByte {
if (isEmpty())
throw NoSuchElementException("Array is empty.")
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness.
*
* @throws NoSuchElementException if this array is empty.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.random(random: Random): UShort {
if (isEmpty())
throw NoSuchElementException("Array is empty.")
return get(random.nextInt(size))
}
/**
* Returns a random element from this array, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UIntArray.randomOrNull(): UInt? {
return randomOrNull(Random)
}
/**
* Returns a random element from this array, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun ULongArray.randomOrNull(): ULong? {
return randomOrNull(Random)
}
/**
* Returns a random element from this array, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UByteArray.randomOrNull(): UByte? {
return randomOrNull(Random)
}
/**
* Returns a random element from this array, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UShortArray.randomOrNull(): UShort? {
return randomOrNull(Random)
}
/**
* Returns a random element from this array using the specified source of randomness, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
public fun UIntArray.randomOrNull(random: Random): UInt? {
if (isEmpty())
return null
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
public fun ULongArray.randomOrNull(random: Random): ULong? {
if (isEmpty())
return null
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
public fun UByteArray.randomOrNull(random: Random): UByte? {
if (isEmpty())
return null
return get(random.nextInt(size))
}
/**
* Returns a random element from this array using the specified source of randomness, or `null` if this array is empty.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
public fun UShortArray.randomOrNull(random: Random): UShort? {
if (isEmpty())
return null
return get(random.nextInt(size))
}
/**
* Returns the single element, or throws an exception if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.single(): UInt {
return storage.single().toUInt()
}
/**
* Returns the single element, or throws an exception if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.single(): ULong {
return storage.single().toULong()
}
/**
* Returns the single element, or throws an exception if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.single(): UByte {
return storage.single().toUByte()
}
/**
* Returns the single element, or throws an exception if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.single(): UShort {
return storage.single().toUShort()
}
/**
* Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.single(predicate: (UInt) -> Boolean): UInt {
var single: UInt? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
single = element
found = true
}
}
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as UInt
}
/**
* Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.single(predicate: (ULong) -> Boolean): ULong {
var single: ULong? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
single = element
found = true
}
}
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as ULong
}
/**
* Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.single(predicate: (UByte) -> Boolean): UByte {
var single: UByte? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
single = element
found = true
}
}
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as UByte
}
/**
* Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.single(predicate: (UShort) -> Boolean): UShort {
var single: UShort? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
single = element
found = true
}
}
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
@Suppress("UNCHECKED_CAST")
return single as UShort
}
/**
* Returns single element, or `null` if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.singleOrNull(): UInt? {
return if (size == 1) this[0] else null
}
/**
* Returns single element, or `null` if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.singleOrNull(): ULong? {
return if (size == 1) this[0] else null
}
/**
* Returns single element, or `null` if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.singleOrNull(): UByte? {
return if (size == 1) this[0] else null
}
/**
* Returns single element, or `null` if the array is empty or has more than one element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.singleOrNull(): UShort? {
return if (size == 1) this[0] else null
}
/**
* Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.singleOrNull(predicate: (UInt) -> Boolean): UInt? {
var single: UInt? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) return null
single = element
found = true
}
}
if (!found) return null
return single
}
/**
* Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.singleOrNull(predicate: (ULong) -> Boolean): ULong? {
var single: ULong? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) return null
single = element
found = true
}
}
if (!found) return null
return single
}
/**
* Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.singleOrNull(predicate: (UByte) -> Boolean): UByte? {
var single: UByte? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) return null
single = element
found = true
}
}
if (!found) return null
return single
}
/**
* Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.singleOrNull(predicate: (UShort) -> Boolean): UShort? {
var single: UShort? = null
var found = false
for (element in this) {
if (predicate(element)) {
if (found) return null
single = element
found = true
}
}
if (!found) return null
return single
}
/**
* Returns a list containing all elements except first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.drop(n: Int): List<UInt> {
require(n >= 0) { "Requested element count $n is less than zero." }
return takeLast((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.drop(n: Int): List<ULong> {
require(n >= 0) { "Requested element count $n is less than zero." }
return takeLast((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.drop(n: Int): List<UByte> {
require(n >= 0) { "Requested element count $n is less than zero." }
return takeLast((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.drop(n: Int): List<UShort> {
require(n >= 0) { "Requested element count $n is less than zero." }
return takeLast((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.dropLast(n: Int): List<UInt> {
require(n >= 0) { "Requested element count $n is less than zero." }
return take((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.dropLast(n: Int): List<ULong> {
require(n >= 0) { "Requested element count $n is less than zero." }
return take((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.dropLast(n: Int): List<UByte> {
require(n >= 0) { "Requested element count $n is less than zero." }
return take((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.dropLast(n: Int): List<UShort> {
require(n >= 0) { "Requested element count $n is less than zero." }
return take((size - n).coerceAtLeast(0))
}
/**
* Returns a list containing all elements except last elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.dropLastWhile(predicate: (UInt) -> Boolean): List<UInt> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return take(index + 1)
}
}
return emptyList()
}
/**
* Returns a list containing all elements except last elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.dropLastWhile(predicate: (ULong) -> Boolean): List<ULong> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return take(index + 1)
}
}
return emptyList()
}
/**
* Returns a list containing all elements except last elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.dropLastWhile(predicate: (UByte) -> Boolean): List<UByte> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return take(index + 1)
}
}
return emptyList()
}
/**
* Returns a list containing all elements except last elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.dropLastWhile(predicate: (UShort) -> Boolean): List<UShort> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return take(index + 1)
}
}
return emptyList()
}
/**
* Returns a list containing all elements except first elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.dropWhile(predicate: (UInt) -> Boolean): List<UInt> {
var yielding = false
val list = ArrayList<UInt>()
for (item in this)
if (yielding)
list.add(item)
else if (!predicate(item)) {
list.add(item)
yielding = true
}
return list
}
/**
* Returns a list containing all elements except first elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.dropWhile(predicate: (ULong) -> Boolean): List<ULong> {
var yielding = false
val list = ArrayList<ULong>()
for (item in this)
if (yielding)
list.add(item)
else if (!predicate(item)) {
list.add(item)
yielding = true
}
return list
}
/**
* Returns a list containing all elements except first elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.dropWhile(predicate: (UByte) -> Boolean): List<UByte> {
var yielding = false
val list = ArrayList<UByte>()
for (item in this)
if (yielding)
list.add(item)
else if (!predicate(item)) {
list.add(item)
yielding = true
}
return list
}
/**
* Returns a list containing all elements except first elements that satisfy the given [predicate].
*
* @sample samples.collections.Collections.Transformations.drop
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.dropWhile(predicate: (UShort) -> Boolean): List<UShort> {
var yielding = false
val list = ArrayList<UShort>()
for (item in this)
if (yielding)
list.add(item)
else if (!predicate(item)) {
list.add(item)
yielding = true
}
return list
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.filter(predicate: (UInt) -> Boolean): List<UInt> {
return filterTo(ArrayList<UInt>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.filter(predicate: (ULong) -> Boolean): List<ULong> {
return filterTo(ArrayList<ULong>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.filter(predicate: (UByte) -> Boolean): List<UByte> {
return filterTo(ArrayList<UByte>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.filter(predicate: (UShort) -> Boolean): List<UShort> {
return filterTo(ArrayList<UShort>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexed
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.filterIndexed(predicate: (index: Int, UInt) -> Boolean): List<UInt> {
return filterIndexedTo(ArrayList<UInt>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexed
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.filterIndexed(predicate: (index: Int, ULong) -> Boolean): List<ULong> {
return filterIndexedTo(ArrayList<ULong>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexed
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.filterIndexed(predicate: (index: Int, UByte) -> Boolean): List<UByte> {
return filterIndexedTo(ArrayList<UByte>(), predicate)
}
/**
* Returns a list containing only elements matching the given [predicate].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexed
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.filterIndexed(predicate: (index: Int, UShort) -> Boolean): List<UShort> {
return filterIndexedTo(ArrayList<UShort>(), predicate)
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexedTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UInt>> UIntArray.filterIndexedTo(destination: C, predicate: (index: Int, UInt) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexedTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in ULong>> ULongArray.filterIndexedTo(destination: C, predicate: (index: Int, ULong) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexedTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UByte>> UByteArray.filterIndexedTo(destination: C, predicate: (index: Int, UByte) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
* @param [predicate] function that takes the index of an element and the element itself
* and returns the result of predicate evaluation on the element.
*
* @sample samples.collections.Collections.Filtering.filterIndexedTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UShort>> UShortArray.filterIndexedTo(destination: C, predicate: (index: Int, UShort) -> Boolean): C {
forEachIndexed { index, element ->
if (predicate(index, element)) destination.add(element)
}
return destination
}
/**
* Returns a list containing all elements not matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.filterNot(predicate: (UInt) -> Boolean): List<UInt> {
return filterNotTo(ArrayList<UInt>(), predicate)
}
/**
* Returns a list containing all elements not matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.filterNot(predicate: (ULong) -> Boolean): List<ULong> {
return filterNotTo(ArrayList<ULong>(), predicate)
}
/**
* Returns a list containing all elements not matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.filterNot(predicate: (UByte) -> Boolean): List<UByte> {
return filterNotTo(ArrayList<UByte>(), predicate)
}
/**
* Returns a list containing all elements not matching the given [predicate].
*
* @sample samples.collections.Collections.Filtering.filter
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.filterNot(predicate: (UShort) -> Boolean): List<UShort> {
return filterNotTo(ArrayList<UShort>(), predicate)
}
/**
* Appends all elements not matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UInt>> UIntArray.filterNotTo(destination: C, predicate: (UInt) -> Boolean): C {
for (element in this) if (!predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements not matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in ULong>> ULongArray.filterNotTo(destination: C, predicate: (ULong) -> Boolean): C {
for (element in this) if (!predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements not matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UByte>> UByteArray.filterNotTo(destination: C, predicate: (UByte) -> Boolean): C {
for (element in this) if (!predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements not matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UShort>> UShortArray.filterNotTo(destination: C, predicate: (UShort) -> Boolean): C {
for (element in this) if (!predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UInt>> UIntArray.filterTo(destination: C, predicate: (UInt) -> Boolean): C {
for (element in this) if (predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in ULong>> ULongArray.filterTo(destination: C, predicate: (ULong) -> Boolean): C {
for (element in this) if (predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UByte>> UByteArray.filterTo(destination: C, predicate: (UByte) -> Boolean): C {
for (element in this) if (predicate(element)) destination.add(element)
return destination
}
/**
* Appends all elements matching the given [predicate] to the given [destination].
*
* @sample samples.collections.Collections.Filtering.filterTo
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <C : MutableCollection<in UShort>> UShortArray.filterTo(destination: C, predicate: (UShort) -> Boolean): C {
for (element in this) if (predicate(element)) destination.add(element)
return destination
}
/**
* Returns a list containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.slice(indices: IntRange): List<UInt> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
* Returns a list containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.slice(indices: IntRange): List<ULong> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
* Returns a list containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.slice(indices: IntRange): List<UByte> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
* Returns a list containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.slice(indices: IntRange): List<UShort> {
if (indices.isEmpty()) return listOf()
return copyOfRange(indices.start, indices.endInclusive + 1).asList()
}
/**
* Returns a list containing elements at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.slice(indices: Iterable<Int>): List<UInt> {
val size = indices.collectionSizeOrDefault(10)
if (size == 0) return emptyList()
val list = ArrayList<UInt>(size)
for (index in indices) {
list.add(get(index))
}
return list
}
/**
* Returns a list containing elements at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.slice(indices: Iterable<Int>): List<ULong> {
val size = indices.collectionSizeOrDefault(10)
if (size == 0) return emptyList()
val list = ArrayList<ULong>(size)
for (index in indices) {
list.add(get(index))
}
return list
}
/**
* Returns a list containing elements at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.slice(indices: Iterable<Int>): List<UByte> {
val size = indices.collectionSizeOrDefault(10)
if (size == 0) return emptyList()
val list = ArrayList<UByte>(size)
for (index in indices) {
list.add(get(index))
}
return list
}
/**
* Returns a list containing elements at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.slice(indices: Iterable<Int>): List<UShort> {
val size = indices.collectionSizeOrDefault(10)
if (size == 0) return emptyList()
val list = ArrayList<UShort>(size)
for (index in indices) {
list.add(get(index))
}
return list
}
/**
* Returns an array containing elements of this array at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sliceArray(indices: Collection<Int>): UIntArray {
return UIntArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements of this array at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sliceArray(indices: Collection<Int>): ULongArray {
return ULongArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements of this array at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sliceArray(indices: Collection<Int>): UByteArray {
return UByteArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements of this array at specified [indices].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sliceArray(indices: Collection<Int>): UShortArray {
return UShortArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sliceArray(indices: IntRange): UIntArray {
return UIntArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sliceArray(indices: IntRange): ULongArray {
return ULongArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sliceArray(indices: IntRange): UByteArray {
return UByteArray(storage.sliceArray(indices))
}
/**
* Returns an array containing elements at indices in the specified [indices] range.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sliceArray(indices: IntRange): UShortArray {
return UShortArray(storage.sliceArray(indices))
}
/**
* Returns a list containing first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.take(n: Int): List<UInt> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
if (n >= size) return toList()
if (n == 1) return listOf(this[0])
var count = 0
val list = ArrayList<UInt>(n)
for (item in this) {
list.add(item)
if (++count == n)
break
}
return list
}
/**
* Returns a list containing first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.take(n: Int): List<ULong> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
if (n >= size) return toList()
if (n == 1) return listOf(this[0])
var count = 0
val list = ArrayList<ULong>(n)
for (item in this) {
list.add(item)
if (++count == n)
break
}
return list
}
/**
* Returns a list containing first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.take(n: Int): List<UByte> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
if (n >= size) return toList()
if (n == 1) return listOf(this[0])
var count = 0
val list = ArrayList<UByte>(n)
for (item in this) {
list.add(item)
if (++count == n)
break
}
return list
}
/**
* Returns a list containing first [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.take(n: Int): List<UShort> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
if (n >= size) return toList()
if (n == 1) return listOf(this[0])
var count = 0
val list = ArrayList<UShort>(n)
for (item in this) {
list.add(item)
if (++count == n)
break
}
return list
}
/**
* Returns a list containing last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.takeLast(n: Int): List<UInt> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
val size = size
if (n >= size) return toList()
if (n == 1) return listOf(this[size - 1])
val list = ArrayList<UInt>(n)
for (index in size - n until size)
list.add(this[index])
return list
}
/**
* Returns a list containing last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.takeLast(n: Int): List<ULong> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
val size = size
if (n >= size) return toList()
if (n == 1) return listOf(this[size - 1])
val list = ArrayList<ULong>(n)
for (index in size - n until size)
list.add(this[index])
return list
}
/**
* Returns a list containing last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.takeLast(n: Int): List<UByte> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
val size = size
if (n >= size) return toList()
if (n == 1) return listOf(this[size - 1])
val list = ArrayList<UByte>(n)
for (index in size - n until size)
list.add(this[index])
return list
}
/**
* Returns a list containing last [n] elements.
*
* @throws IllegalArgumentException if [n] is negative.
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.takeLast(n: Int): List<UShort> {
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
val size = size
if (n >= size) return toList()
if (n == 1) return listOf(this[size - 1])
val list = ArrayList<UShort>(n)
for (index in size - n until size)
list.add(this[index])
return list
}
/**
* Returns a list containing last elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.takeLastWhile(predicate: (UInt) -> Boolean): List<UInt> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return drop(index + 1)
}
}
return toList()
}
/**
* Returns a list containing last elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.takeLastWhile(predicate: (ULong) -> Boolean): List<ULong> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return drop(index + 1)
}
}
return toList()
}
/**
* Returns a list containing last elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.takeLastWhile(predicate: (UByte) -> Boolean): List<UByte> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return drop(index + 1)
}
}
return toList()
}
/**
* Returns a list containing last elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.takeLastWhile(predicate: (UShort) -> Boolean): List<UShort> {
for (index in lastIndex downTo 0) {
if (!predicate(this[index])) {
return drop(index + 1)
}
}
return toList()
}
/**
* Returns a list containing first elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.takeWhile(predicate: (UInt) -> Boolean): List<UInt> {
val list = ArrayList<UInt>()
for (item in this) {
if (!predicate(item))
break
list.add(item)
}
return list
}
/**
* Returns a list containing first elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.takeWhile(predicate: (ULong) -> Boolean): List<ULong> {
val list = ArrayList<ULong>()
for (item in this) {
if (!predicate(item))
break
list.add(item)
}
return list
}
/**
* Returns a list containing first elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.takeWhile(predicate: (UByte) -> Boolean): List<UByte> {
val list = ArrayList<UByte>()
for (item in this) {
if (!predicate(item))
break
list.add(item)
}
return list
}
/**
* Returns a list containing first elements satisfying the given [predicate].
*
* @sample samples.collections.Collections.Transformations.take
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.takeWhile(predicate: (UShort) -> Boolean): List<UShort> {
val list = ArrayList<UShort>()
for (item in this) {
if (!predicate(item))
break
list.add(item)
}
return list
}
/**
* Reverses elements in the array in-place.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reverse(): Unit {
storage.reverse()
}
/**
* Reverses elements in the array in-place.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reverse(): Unit {
storage.reverse()
}
/**
* Reverses elements in the array in-place.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reverse(): Unit {
storage.reverse()
}
/**
* Reverses elements in the array in-place.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reverse(): Unit {
storage.reverse()
}
/**
* Reverses elements of the array in the specified range in-place.
*
* @param fromIndex the start of the range (inclusive) to reverse.
* @param toIndex the end of the range (exclusive) to reverse.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reverse(fromIndex: Int, toIndex: Int): Unit {
storage.reverse(fromIndex, toIndex)
}
/**
* Reverses elements of the array in the specified range in-place.
*
* @param fromIndex the start of the range (inclusive) to reverse.
* @param toIndex the end of the range (exclusive) to reverse.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reverse(fromIndex: Int, toIndex: Int): Unit {
storage.reverse(fromIndex, toIndex)
}
/**
* Reverses elements of the array in the specified range in-place.
*
* @param fromIndex the start of the range (inclusive) to reverse.
* @param toIndex the end of the range (exclusive) to reverse.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reverse(fromIndex: Int, toIndex: Int): Unit {
storage.reverse(fromIndex, toIndex)
}
/**
* Reverses elements of the array in the specified range in-place.
*
* @param fromIndex the start of the range (inclusive) to reverse.
* @param toIndex the end of the range (exclusive) to reverse.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reverse(fromIndex: Int, toIndex: Int): Unit {
storage.reverse(fromIndex, toIndex)
}
/**
* Returns a list with elements in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.reversed(): List<UInt> {
if (isEmpty()) return emptyList()
val list = toMutableList()
list.reverse()
return list
}
/**
* Returns a list with elements in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.reversed(): List<ULong> {
if (isEmpty()) return emptyList()
val list = toMutableList()
list.reverse()
return list
}
/**
* Returns a list with elements in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.reversed(): List<UByte> {
if (isEmpty()) return emptyList()
val list = toMutableList()
list.reverse()
return list
}
/**
* Returns a list with elements in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.reversed(): List<UShort> {
if (isEmpty()) return emptyList()
val list = toMutableList()
list.reverse()
return list
}
/**
* Returns an array with elements of this array in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reversedArray(): UIntArray {
return UIntArray(storage.reversedArray())
}
/**
* Returns an array with elements of this array in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reversedArray(): ULongArray {
return ULongArray(storage.reversedArray())
}
/**
* Returns an array with elements of this array in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reversedArray(): UByteArray {
return UByteArray(storage.reversedArray())
}
/**
* Returns an array with elements of this array in reversed order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reversedArray(): UShortArray {
return UShortArray(storage.reversedArray())
}
/**
* Randomly shuffles elements in this array in-place.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.shuffle(): Unit {
shuffle(Random)
}
/**
* Randomly shuffles elements in this array in-place.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.shuffle(): Unit {
shuffle(Random)
}
/**
* Randomly shuffles elements in this array in-place.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.shuffle(): Unit {
shuffle(Random)
}
/**
* Randomly shuffles elements in this array in-place.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.shuffle(): Unit {
shuffle(Random)
}
/**
* Randomly shuffles elements in this array in-place using the specified [random] instance as the source of randomness.
*
* See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.shuffle(random: Random): Unit {
for (i in lastIndex downTo 1) {
val j = random.nextInt(i + 1)
val copy = this[i]
this[i] = this[j]
this[j] = copy
}
}
/**
* Randomly shuffles elements in this array in-place using the specified [random] instance as the source of randomness.
*
* See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.shuffle(random: Random): Unit {
for (i in lastIndex downTo 1) {
val j = random.nextInt(i + 1)
val copy = this[i]
this[i] = this[j]
this[j] = copy
}
}
/**
* Randomly shuffles elements in this array in-place using the specified [random] instance as the source of randomness.
*
* See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.shuffle(random: Random): Unit {
for (i in lastIndex downTo 1) {
val j = random.nextInt(i + 1)
val copy = this[i]
this[i] = this[j]
this[j] = copy
}
}
/**
* Randomly shuffles elements in this array in-place using the specified [random] instance as the source of randomness.
*
* See: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.shuffle(random: Random): Unit {
for (i in lastIndex downTo 1) {
val j = random.nextInt(i + 1)
val copy = this[i]
this[i] = this[j]
this[j] = copy
}
}
/**
* Sorts elements in the array in-place descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sortDescending(): Unit {
if (size > 1) {
sort()
reverse()
}
}
/**
* Sorts elements in the array in-place descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sortDescending(): Unit {
if (size > 1) {
sort()
reverse()
}
}
/**
* Sorts elements in the array in-place descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sortDescending(): Unit {
if (size > 1) {
sort()
reverse()
}
}
/**
* Sorts elements in the array in-place descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sortDescending(): Unit {
if (size > 1) {
sort()
reverse()
}
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sorted(): List<UInt> {
return copyOf().apply { sort() }.asList()
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sorted(): List<ULong> {
return copyOf().apply { sort() }.asList()
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sorted(): List<UByte> {
return copyOf().apply { sort() }.asList()
}
/**
* Returns a list of all elements sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sorted(): List<UShort> {
return copyOf().apply { sort() }.asList()
}
/**
* Returns an array with all elements of this array sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sortedArray(): UIntArray {
if (isEmpty()) return this
return this.copyOf().apply { sort() }
}
/**
* Returns an array with all elements of this array sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sortedArray(): ULongArray {
if (isEmpty()) return this
return this.copyOf().apply { sort() }
}
/**
* Returns an array with all elements of this array sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sortedArray(): UByteArray {
if (isEmpty()) return this
return this.copyOf().apply { sort() }
}
/**
* Returns an array with all elements of this array sorted according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sortedArray(): UShortArray {
if (isEmpty()) return this
return this.copyOf().apply { sort() }
}
/**
* Returns an array with all elements of this array sorted descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sortedArrayDescending(): UIntArray {
if (isEmpty()) return this
return this.copyOf().apply { sortDescending() }
}
/**
* Returns an array with all elements of this array sorted descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sortedArrayDescending(): ULongArray {
if (isEmpty()) return this
return this.copyOf().apply { sortDescending() }
}
/**
* Returns an array with all elements of this array sorted descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sortedArrayDescending(): UByteArray {
if (isEmpty()) return this
return this.copyOf().apply { sortDescending() }
}
/**
* Returns an array with all elements of this array sorted descending according to their natural sort order.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sortedArrayDescending(): UShortArray {
if (isEmpty()) return this
return this.copyOf().apply { sortDescending() }
}
/**
* Returns a list of all elements sorted descending according to their natural sort order.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sortedDescending(): List<UInt> {
return copyOf().apply { sort() }.reversed()
}
/**
* Returns a list of all elements sorted descending according to their natural sort order.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sortedDescending(): List<ULong> {
return copyOf().apply { sort() }.reversed()
}
/**
* Returns a list of all elements sorted descending according to their natural sort order.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sortedDescending(): List<UByte> {
return copyOf().apply { sort() }.reversed()
}
/**
* Returns a list of all elements sorted descending according to their natural sort order.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sortedDescending(): List<UShort> {
return copyOf().apply { sort() }.reversed()
}
/**
* Returns an array of type [ByteArray], which is a view of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.asByteArray(): ByteArray {
return storage
}
/**
* Returns an array of type [IntArray], which is a view of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.asIntArray(): IntArray {
return storage
}
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UIntArray.asList(): List<UInt>
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun ULongArray.asList(): List<ULong>
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UByteArray.asList(): List<UByte>
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public expect fun UShortArray.asList(): List<UShort>
/**
* Returns an array of type [LongArray], which is a view of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.asLongArray(): LongArray {
return storage
}
/**
* Returns an array of type [ShortArray], which is a view of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.asShortArray(): ShortArray {
return storage
}
/**
* Returns an array of type [UByteArray], which is a view of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ByteArray.asUByteArray(): UByteArray {
return UByteArray(this)
}
/**
* Returns an array of type [UIntArray], which is a view of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun IntArray.asUIntArray(): UIntArray {
return UIntArray(this)
}
/**
* Returns an array of type [ULongArray], which is a view of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun LongArray.asULongArray(): ULongArray {
return ULongArray(this)
}
/**
* Returns an array of type [UShortArray], which is a view of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ShortArray.asUShortArray(): UShortArray {
return UShortArray(this)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public infix fun UIntArray.contentEquals(other: UIntArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public infix fun ULongArray.contentEquals(other: ULongArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public infix fun UByteArray.contentEquals(other: UByteArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public infix fun UShortArray.contentEquals(other: UShortArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public infix fun UIntArray?.contentEquals(other: UIntArray?): Boolean {
return this?.storage.contentEquals(other?.storage)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public infix fun ULongArray?.contentEquals(other: ULongArray?): Boolean {
return this?.storage.contentEquals(other?.storage)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public infix fun UByteArray?.contentEquals(other: UByteArray?): Boolean {
return this?.storage.contentEquals(other?.storage)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public infix fun UShortArray?.contentEquals(other: UShortArray?): Boolean {
return this?.storage.contentEquals(other?.storage)
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray?.contentHashCode(): Int {
return this?.storage.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray?.contentHashCode(): Int {
return this?.storage.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray?.contentHashCode(): Int {
return this?.storage.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray?.contentHashCode(): Int {
return this?.storage.contentHashCode()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.contentToString(): String {
return this.contentToString()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.contentToString(): String {
return this.contentToString()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.contentToString(): String {
return this.contentToString()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@Deprecated("Use Kotlin compiler 1.4 to avoid deprecation warning.")
@SinceKotlin("1.3")
@DeprecatedSinceKotlin(hiddenSince = "1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.contentToString(): String {
return this.contentToString()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Copies this array or its subrange into the [destination] array and returns that array.
*
* It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the [destination] array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
* @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.copyInto(destination: UIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UIntArray {
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
* Copies this array or its subrange into the [destination] array and returns that array.
*
* It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the [destination] array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
* @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.copyInto(destination: ULongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ULongArray {
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
* Copies this array or its subrange into the [destination] array and returns that array.
*
* It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the [destination] array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
* @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UByteArray {
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
* Copies this array or its subrange into the [destination] array and returns that array.
*
* It's allowed to pass the same array in the [destination] and even specify the subrange so that it overlaps with the destination range.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the [destination] array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
* @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.copyInto(destination: UShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UShortArray {
storage.copyInto(destination.storage, destinationOffset, startIndex, endIndex)
return destination
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.copyOf(): UIntArray {
return UIntArray(storage.copyOf())
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.copyOf(): ULongArray {
return ULongArray(storage.copyOf())
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.copyOf(): UByteArray {
return UByteArray(storage.copyOf())
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.copyOf(): UShortArray {
return UShortArray(storage.copyOf())
}
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
* The copy is either truncated or padded at the end with zero values if necessary.
*
* - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
* - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.copyOf(newSize: Int): UIntArray {
return UIntArray(storage.copyOf(newSize))
}
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
* The copy is either truncated or padded at the end with zero values if necessary.
*
* - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
* - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.copyOf(newSize: Int): ULongArray {
return ULongArray(storage.copyOf(newSize))
}
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
* The copy is either truncated or padded at the end with zero values if necessary.
*
* - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
* - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.copyOf(newSize: Int): UByteArray {
return UByteArray(storage.copyOf(newSize))
}
/**
* Returns new array which is a copy of the original array, resized to the given [newSize].
* The copy is either truncated or padded at the end with zero values if necessary.
*
* - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
* - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.copyOf(newSize: Int): UShortArray {
return UShortArray(storage.copyOf(newSize))
}
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.copyOfRange(fromIndex: Int, toIndex: Int): UIntArray {
return UIntArray(storage.copyOfRange(fromIndex, toIndex))
}
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.copyOfRange(fromIndex: Int, toIndex: Int): ULongArray {
return ULongArray(storage.copyOfRange(fromIndex, toIndex))
}
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.copyOfRange(fromIndex: Int, toIndex: Int): UByteArray {
return UByteArray(storage.copyOfRange(fromIndex, toIndex))
}
/**
* Returns a new array which is a copy of the specified range of the original array.
*
* @param fromIndex the start of the range (inclusive) to copy.
* @param toIndex the end of the range (exclusive) to copy.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.copyOfRange(fromIndex: Int, toIndex: Int): UShortArray {
return UShortArray(storage.copyOfRange(fromIndex, toIndex))
}
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.fill(element: UInt, fromIndex: Int = 0, toIndex: Int = size): Unit {
storage.fill(element.toInt(), fromIndex, toIndex)
}
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.fill(element: ULong, fromIndex: Int = 0, toIndex: Int = size): Unit {
storage.fill(element.toLong(), fromIndex, toIndex)
}
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.fill(element: UByte, fromIndex: Int = 0, toIndex: Int = size): Unit {
storage.fill(element.toByte(), fromIndex, toIndex)
}
/**
* Fills this array or its subrange with the specified [element] value.
*
* @param fromIndex the start of the range (inclusive) to fill, 0 by default.
* @param toIndex the end of the range (exclusive) to fill, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.fill(element: UShort, fromIndex: Int = 0, toIndex: Int = size): Unit {
storage.fill(element.toShort(), fromIndex, toIndex)
}
/**
* Returns the range of valid indices for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UIntArray.indices: IntRange
get() = storage.indices
/**
* Returns the range of valid indices for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val ULongArray.indices: IntRange
get() = storage.indices
/**
* Returns the range of valid indices for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UByteArray.indices: IntRange
get() = storage.indices
/**
* Returns the range of valid indices for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UShortArray.indices: IntRange
get() = storage.indices
/**
* Returns the last valid index for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UIntArray.lastIndex: Int
get() = storage.lastIndex
/**
* Returns the last valid index for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val ULongArray.lastIndex: Int
get() = storage.lastIndex
/**
* Returns the last valid index for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UByteArray.lastIndex: Int
get() = storage.lastIndex
/**
* Returns the last valid index for the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline val UShortArray.lastIndex: Int
get() = storage.lastIndex
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.plus(element: UInt): UIntArray {
return UIntArray(storage + element.toInt())
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.plus(element: ULong): ULongArray {
return ULongArray(storage + element.toLong())
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.plus(element: UByte): UByteArray {
return UByteArray(storage + element.toByte())
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.plus(element: UShort): UShortArray {
return UShortArray(storage + element.toShort())
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public operator fun UIntArray.plus(elements: Collection<UInt>): UIntArray {
var index = size
val result = storage.copyOf(size + elements.size)
for (element in elements) result[index++] = element.toInt()
return UIntArray(result)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public operator fun ULongArray.plus(elements: Collection<ULong>): ULongArray {
var index = size
val result = storage.copyOf(size + elements.size)
for (element in elements) result[index++] = element.toLong()
return ULongArray(result)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public operator fun UByteArray.plus(elements: Collection<UByte>): UByteArray {
var index = size
val result = storage.copyOf(size + elements.size)
for (element in elements) result[index++] = element.toByte()
return UByteArray(result)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public operator fun UShortArray.plus(elements: Collection<UShort>): UShortArray {
var index = size
val result = storage.copyOf(size + elements.size)
for (element in elements) result[index++] = element.toShort()
return UShortArray(result)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UIntArray.plus(elements: UIntArray): UIntArray {
return UIntArray(storage + elements.storage)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun ULongArray.plus(elements: ULongArray): ULongArray {
return ULongArray(storage + elements.storage)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UByteArray.plus(elements: UByteArray): UByteArray {
return UByteArray(storage + elements.storage)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline operator fun UShortArray.plus(elements: UShortArray): UShortArray {
return UShortArray(storage + elements.storage)
}
/**
* Sorts the array in-place.
*
* @sample samples.collections.Arrays.Sorting.sortArray
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.sort(): Unit {
if (size > 1) sortArray(this, 0, size)
}
/**
* Sorts the array in-place.
*
* @sample samples.collections.Arrays.Sorting.sortArray
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.sort(): Unit {
if (size > 1) sortArray(this, 0, size)
}
/**
* Sorts the array in-place.
*
* @sample samples.collections.Arrays.Sorting.sortArray
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.sort(): Unit {
if (size > 1) sortArray(this, 0, size)
}
/**
* Sorts the array in-place.
*
* @sample samples.collections.Arrays.Sorting.sortArray
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.sort(): Unit {
if (size > 1) sortArray(this, 0, size)
}
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
sortArray(this, fromIndex, toIndex)
}
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
sortArray(this, fromIndex, toIndex)
}
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
sortArray(this, fromIndex, toIndex)
}
/**
* Sorts a range in the array in-place.
*
* @param fromIndex the start of the range (inclusive) to sort, 0 by default.
* @param toIndex the end of the range (exclusive) to sort, size of this array by default.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*
* @sample samples.collections.Arrays.Sorting.sortRangeOfArray
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
sortArray(this, fromIndex, toIndex)
}
/**
* Sorts elements of the array in the specified range in-place.
* The elements are sorted descending according to their natural sort order.
*
* @param fromIndex the start of the range (inclusive) to sort.
* @param toIndex the end of the range (exclusive) to sort.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.sortDescending(fromIndex: Int, toIndex: Int): Unit {
sort(fromIndex, toIndex)
reverse(fromIndex, toIndex)
}
/**
* Sorts elements of the array in the specified range in-place.
* The elements are sorted descending according to their natural sort order.
*
* @param fromIndex the start of the range (inclusive) to sort.
* @param toIndex the end of the range (exclusive) to sort.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.sortDescending(fromIndex: Int, toIndex: Int): Unit {
sort(fromIndex, toIndex)
reverse(fromIndex, toIndex)
}
/**
* Sorts elements of the array in the specified range in-place.
* The elements are sorted descending according to their natural sort order.
*
* @param fromIndex the start of the range (inclusive) to sort.
* @param toIndex the end of the range (exclusive) to sort.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.sortDescending(fromIndex: Int, toIndex: Int): Unit {
sort(fromIndex, toIndex)
reverse(fromIndex, toIndex)
}
/**
* Sorts elements of the array in the specified range in-place.
* The elements are sorted descending according to their natural sort order.
*
* @param fromIndex the start of the range (inclusive) to sort.
* @param toIndex the end of the range (exclusive) to sort.
*
* @throws IndexOutOfBoundsException if [fromIndex] is less than zero or [toIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [fromIndex] is greater than [toIndex].
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.sortDescending(fromIndex: Int, toIndex: Int): Unit {
sort(fromIndex, toIndex)
reverse(fromIndex, toIndex)
}
/**
* Returns an array of type [ByteArray], which is a copy of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.toByteArray(): ByteArray {
return storage.copyOf()
}
/**
* Returns an array of type [IntArray], which is a copy of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.toIntArray(): IntArray {
return storage.copyOf()
}
/**
* Returns an array of type [LongArray], which is a copy of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.toLongArray(): LongArray {
return storage.copyOf()
}
/**
* Returns an array of type [ShortArray], which is a copy of this array where each element is a signed reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.toShortArray(): ShortArray {
return storage.copyOf()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.toTypedArray(): Array<UInt> {
return Array(size) { index -> this[index] }
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.toTypedArray(): Array<ULong> {
return Array(size) { index -> this[index] }
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.toTypedArray(): Array<UByte> {
return Array(size) { index -> this[index] }
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.toTypedArray(): Array<UShort> {
return Array(size) { index -> this[index] }
}
/**
* Returns an array of UByte containing all of the elements of this generic array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Array<out UByte>.toUByteArray(): UByteArray {
return UByteArray(size) { index -> this[index] }
}
/**
* Returns an array of type [UByteArray], which is a copy of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ByteArray.toUByteArray(): UByteArray {
return UByteArray(this.copyOf())
}
/**
* Returns an array of UInt containing all of the elements of this generic array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Array<out UInt>.toUIntArray(): UIntArray {
return UIntArray(size) { index -> this[index] }
}
/**
* Returns an array of type [UIntArray], which is a copy of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun IntArray.toUIntArray(): UIntArray {
return UIntArray(this.copyOf())
}
/**
* Returns an array of ULong containing all of the elements of this generic array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Array<out ULong>.toULongArray(): ULongArray {
return ULongArray(size) { index -> this[index] }
}
/**
* Returns an array of type [ULongArray], which is a copy of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun LongArray.toULongArray(): ULongArray {
return ULongArray(this.copyOf())
}
/**
* Returns an array of UShort containing all of the elements of this generic array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Array<out UShort>.toUShortArray(): UShortArray {
return UShortArray(size) { index -> this[index] }
}
/**
* Returns an array of type [UShortArray], which is a copy of this array where each element is an unsigned reinterpretation
* of the corresponding element of this array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ShortArray.toUShortArray(): UShortArray {
return UShortArray(this.copyOf())
}
/**
* Returns a [Map] where keys are elements from the given array and values are
* produced by the [valueSelector] function applied to each element.
*
* If any two elements are equal, the last one gets added to the map.
*
* The returned map preserves the entry iteration order of the original array.
*
* @sample samples.collections.Collections.Transformations.associateWith
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UIntArray.associateWith(valueSelector: (UInt) -> V): Map<UInt, V> {
val result = LinkedHashMap<UInt, V>(mapCapacity(size).coerceAtLeast(16))
return associateWithTo(result, valueSelector)
}
/**
* Returns a [Map] where keys are elements from the given array and values are
* produced by the [valueSelector] function applied to each element.
*
* If any two elements are equal, the last one gets added to the map.
*
* The returned map preserves the entry iteration order of the original array.
*
* @sample samples.collections.Collections.Transformations.associateWith
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> ULongArray.associateWith(valueSelector: (ULong) -> V): Map<ULong, V> {
val result = LinkedHashMap<ULong, V>(mapCapacity(size).coerceAtLeast(16))
return associateWithTo(result, valueSelector)
}
/**
* Returns a [Map] where keys are elements from the given array and values are
* produced by the [valueSelector] function applied to each element.
*
* If any two elements are equal, the last one gets added to the map.
*
* The returned map preserves the entry iteration order of the original array.
*
* @sample samples.collections.Collections.Transformations.associateWith
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UByteArray.associateWith(valueSelector: (UByte) -> V): Map<UByte, V> {
val result = LinkedHashMap<UByte, V>(mapCapacity(size).coerceAtLeast(16))
return associateWithTo(result, valueSelector)
}
/**
* Returns a [Map] where keys are elements from the given array and values are
* produced by the [valueSelector] function applied to each element.
*
* If any two elements are equal, the last one gets added to the map.
*
* The returned map preserves the entry iteration order of the original array.
*
* @sample samples.collections.Collections.Transformations.associateWith
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UShortArray.associateWith(valueSelector: (UShort) -> V): Map<UShort, V> {
val result = LinkedHashMap<UShort, V>(mapCapacity(size).coerceAtLeast(16))
return associateWithTo(result, valueSelector)
}
/**
* Populates and returns the [destination] mutable map with key-value pairs for each element of the given array,
* where key is the element itself and value is provided by the [valueSelector] function applied to that key.
*
* If any two elements are equal, the last one overwrites the former value in the map.
*
* @sample samples.collections.Collections.Transformations.associateWithTo
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V, M : MutableMap<in UInt, in V>> UIntArray.associateWithTo(destination: M, valueSelector: (UInt) -> V): M {
for (element in this) {
destination.put(element, valueSelector(element))
}
return destination
}
/**
* Populates and returns the [destination] mutable map with key-value pairs for each element of the given array,
* where key is the element itself and value is provided by the [valueSelector] function applied to that key.
*
* If any two elements are equal, the last one overwrites the former value in the map.
*
* @sample samples.collections.Collections.Transformations.associateWithTo
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V, M : MutableMap<in ULong, in V>> ULongArray.associateWithTo(destination: M, valueSelector: (ULong) -> V): M {
for (element in this) {
destination.put(element, valueSelector(element))
}
return destination
}
/**
* Populates and returns the [destination] mutable map with key-value pairs for each element of the given array,
* where key is the element itself and value is provided by the [valueSelector] function applied to that key.
*
* If any two elements are equal, the last one overwrites the former value in the map.
*
* @sample samples.collections.Collections.Transformations.associateWithTo
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V, M : MutableMap<in UByte, in V>> UByteArray.associateWithTo(destination: M, valueSelector: (UByte) -> V): M {
for (element in this) {
destination.put(element, valueSelector(element))
}
return destination
}
/**
* Populates and returns the [destination] mutable map with key-value pairs for each element of the given array,
* where key is the element itself and value is provided by the [valueSelector] function applied to that key.
*
* If any two elements are equal, the last one overwrites the former value in the map.
*
* @sample samples.collections.Collections.Transformations.associateWithTo
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V, M : MutableMap<in UShort, in V>> UShortArray.associateWithTo(destination: M, valueSelector: (UShort) -> V): M {
for (element in this) {
destination.put(element, valueSelector(element))
}
return destination
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
*
* @sample samples.collections.Collections.Transformations.flatMap
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.flatMap(transform: (UInt) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
*
* @sample samples.collections.Collections.Transformations.flatMap
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.flatMap(transform: (ULong) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
*
* @sample samples.collections.Collections.Transformations.flatMap
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.flatMap(transform: (UByte) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
*
* @sample samples.collections.Collections.Transformations.flatMap
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.flatMap(transform: (UShort) -> Iterable<R>): List<R> {
return flatMapTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array.
*
* @sample samples.collections.Collections.Transformations.flatMapIndexed
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.flatMapIndexed(transform: (index: Int, UInt) -> Iterable<R>): List<R> {
return flatMapIndexedTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array.
*
* @sample samples.collections.Collections.Transformations.flatMapIndexed
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.flatMapIndexed(transform: (index: Int, ULong) -> Iterable<R>): List<R> {
return flatMapIndexedTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array.
*
* @sample samples.collections.Collections.Transformations.flatMapIndexed
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.flatMapIndexed(transform: (index: Int, UByte) -> Iterable<R>): List<R> {
return flatMapIndexedTo(ArrayList<R>(), transform)
}
/**
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array.
*
* @sample samples.collections.Collections.Transformations.flatMapIndexed
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.flatMapIndexed(transform: (index: Int, UShort) -> Iterable<R>): List<R> {
return flatMapIndexedTo(ArrayList<R>(), transform)
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array, to the given [destination].
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UIntArray.flatMapIndexedTo(destination: C, transform: (index: Int, UInt) -> Iterable<R>): C {
var index = 0
for (element in this) {
val list = transform(index++, element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array, to the given [destination].
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> ULongArray.flatMapIndexedTo(destination: C, transform: (index: Int, ULong) -> Iterable<R>): C {
var index = 0
for (element in this) {
val list = transform(index++, element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array, to the given [destination].
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UByteArray.flatMapIndexedTo(destination: C, transform: (index: Int, UByte) -> Iterable<R>): C {
var index = 0
for (element in this) {
val list = transform(index++, element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element
* and its index in the original array, to the given [destination].
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UShortArray.flatMapIndexedTo(destination: C, transform: (index: Int, UShort) -> Iterable<R>): C {
var index = 0
for (element in this) {
val list = transform(index++, element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UIntArray.flatMapTo(destination: C, transform: (UInt) -> Iterable<R>): C {
for (element in this) {
val list = transform(element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> ULongArray.flatMapTo(destination: C, transform: (ULong) -> Iterable<R>): C {
for (element in this) {
val list = transform(element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UByteArray.flatMapTo(destination: C, transform: (UByte) -> Iterable<R>): C {
for (element in this) {
val list = transform(element)
destination.addAll(list)
}
return destination
}
/**
* Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UShortArray.flatMapTo(destination: C, transform: (UShort) -> Iterable<R>): C {
for (element in this) {
val list = transform(element)
destination.addAll(list)
}
return destination
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and returns a map where each group key is associated with a list of corresponding elements.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K> UIntArray.groupBy(keySelector: (UInt) -> K): Map<K, List<UInt>> {
return groupByTo(LinkedHashMap<K, MutableList<UInt>>(), keySelector)
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and returns a map where each group key is associated with a list of corresponding elements.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K> ULongArray.groupBy(keySelector: (ULong) -> K): Map<K, List<ULong>> {
return groupByTo(LinkedHashMap<K, MutableList<ULong>>(), keySelector)
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and returns a map where each group key is associated with a list of corresponding elements.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K> UByteArray.groupBy(keySelector: (UByte) -> K): Map<K, List<UByte>> {
return groupByTo(LinkedHashMap<K, MutableList<UByte>>(), keySelector)
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and returns a map where each group key is associated with a list of corresponding elements.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K> UShortArray.groupBy(keySelector: (UShort) -> K): Map<K, List<UShort>> {
return groupByTo(LinkedHashMap<K, MutableList<UShort>>(), keySelector)
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and returns a map where each group key is associated with a list of corresponding values.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V> UIntArray.groupBy(keySelector: (UInt) -> K, valueTransform: (UInt) -> V): Map<K, List<V>> {
return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and returns a map where each group key is associated with a list of corresponding values.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V> ULongArray.groupBy(keySelector: (ULong) -> K, valueTransform: (ULong) -> V): Map<K, List<V>> {
return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and returns a map where each group key is associated with a list of corresponding values.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V> UByteArray.groupBy(keySelector: (UByte) -> K, valueTransform: (UByte) -> V): Map<K, List<V>> {
return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and returns a map where each group key is associated with a list of corresponding values.
*
* The returned map preserves the entry iteration order of the keys produced from the original array.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V> UShortArray.groupBy(keySelector: (UShort) -> K, valueTransform: (UShort) -> V): Map<K, List<V>> {
return groupByTo(LinkedHashMap<K, MutableList<V>>(), keySelector, valueTransform)
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, M : MutableMap<in K, MutableList<UInt>>> UIntArray.groupByTo(destination: M, keySelector: (UInt) -> K): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<UInt>() }
list.add(element)
}
return destination
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, M : MutableMap<in K, MutableList<ULong>>> ULongArray.groupByTo(destination: M, keySelector: (ULong) -> K): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<ULong>() }
list.add(element)
}
return destination
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, M : MutableMap<in K, MutableList<UByte>>> UByteArray.groupByTo(destination: M, keySelector: (UByte) -> K): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<UByte>() }
list.add(element)
}
return destination
}
/**
* Groups elements of the original array by the key returned by the given [keySelector] function
* applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupBy
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, M : MutableMap<in K, MutableList<UShort>>> UShortArray.groupByTo(destination: M, keySelector: (UShort) -> K): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<UShort>() }
list.add(element)
}
return destination
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and puts to the [destination] map each group key associated with a list of corresponding values.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UIntArray.groupByTo(destination: M, keySelector: (UInt) -> K, valueTransform: (UInt) -> V): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<V>() }
list.add(valueTransform(element))
}
return destination
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and puts to the [destination] map each group key associated with a list of corresponding values.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V, M : MutableMap<in K, MutableList<V>>> ULongArray.groupByTo(destination: M, keySelector: (ULong) -> K, valueTransform: (ULong) -> V): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<V>() }
list.add(valueTransform(element))
}
return destination
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and puts to the [destination] map each group key associated with a list of corresponding values.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UByteArray.groupByTo(destination: M, keySelector: (UByte) -> K, valueTransform: (UByte) -> V): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<V>() }
list.add(valueTransform(element))
}
return destination
}
/**
* Groups values returned by the [valueTransform] function applied to each element of the original array
* by the key returned by the given [keySelector] function applied to the element
* and puts to the [destination] map each group key associated with a list of corresponding values.
*
* @return The [destination] map.
*
* @sample samples.collections.Collections.Transformations.groupByKeysAndValues
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <K, V, M : MutableMap<in K, MutableList<V>>> UShortArray.groupByTo(destination: M, keySelector: (UShort) -> K, valueTransform: (UShort) -> V): M {
for (element in this) {
val key = keySelector(element)
val list = destination.getOrPut(key) { ArrayList<V>() }
list.add(valueTransform(element))
}
return destination
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.map(transform: (UInt) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.map(transform: (ULong) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.map(transform: (UByte) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element in the original array.
*
* @sample samples.collections.Collections.Transformations.map
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.map(transform: (UShort) -> R): List<R> {
return mapTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element and its index in the original array.
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.mapIndexed(transform: (index: Int, UInt) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element and its index in the original array.
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.mapIndexed(transform: (index: Int, ULong) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element and its index in the original array.
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.mapIndexed(transform: (index: Int, UByte) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(size), transform)
}
/**
* Returns a list containing the results of applying the given [transform] function
* to each element and its index in the original array.
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.mapIndexed(transform: (index: Int, UShort) -> R): List<R> {
return mapIndexedTo(ArrayList<R>(size), transform)
}
/**
* Applies the given [transform] function to each element and its index in the original array
* and appends the results to the given [destination].
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UIntArray.mapIndexedTo(destination: C, transform: (index: Int, UInt) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
return destination
}
/**
* Applies the given [transform] function to each element and its index in the original array
* and appends the results to the given [destination].
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> ULongArray.mapIndexedTo(destination: C, transform: (index: Int, ULong) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
return destination
}
/**
* Applies the given [transform] function to each element and its index in the original array
* and appends the results to the given [destination].
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UByteArray.mapIndexedTo(destination: C, transform: (index: Int, UByte) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
return destination
}
/**
* Applies the given [transform] function to each element and its index in the original array
* and appends the results to the given [destination].
* @param [transform] function that takes the index of an element and the element itself
* and returns the result of the transform applied to the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UShortArray.mapIndexedTo(destination: C, transform: (index: Int, UShort) -> R): C {
var index = 0
for (item in this)
destination.add(transform(index++, item))
return destination
}
/**
* Applies the given [transform] function to each element of the original array
* and appends the results to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UIntArray.mapTo(destination: C, transform: (UInt) -> R): C {
for (item in this)
destination.add(transform(item))
return destination
}
/**
* Applies the given [transform] function to each element of the original array
* and appends the results to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> ULongArray.mapTo(destination: C, transform: (ULong) -> R): C {
for (item in this)
destination.add(transform(item))
return destination
}
/**
* Applies the given [transform] function to each element of the original array
* and appends the results to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UByteArray.mapTo(destination: C, transform: (UByte) -> R): C {
for (item in this)
destination.add(transform(item))
return destination
}
/**
* Applies the given [transform] function to each element of the original array
* and appends the results to the given [destination].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, C : MutableCollection<in R>> UShortArray.mapTo(destination: C, transform: (UShort) -> R): C {
for (item in this)
destination.add(transform(item))
return destination
}
/**
* Returns a lazy [Iterable] that wraps each element of the original array
* into an [IndexedValue] containing the index of that element and the element itself.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.withIndex(): Iterable<IndexedValue<UInt>> {
return IndexingIterable { iterator() }
}
/**
* Returns a lazy [Iterable] that wraps each element of the original array
* into an [IndexedValue] containing the index of that element and the element itself.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.withIndex(): Iterable<IndexedValue<ULong>> {
return IndexingIterable { iterator() }
}
/**
* Returns a lazy [Iterable] that wraps each element of the original array
* into an [IndexedValue] containing the index of that element and the element itself.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.withIndex(): Iterable<IndexedValue<UByte>> {
return IndexingIterable { iterator() }
}
/**
* Returns a lazy [Iterable] that wraps each element of the original array
* into an [IndexedValue] containing the index of that element and the element itself.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.withIndex(): Iterable<IndexedValue<UShort>> {
return IndexingIterable { iterator() }
}
/**
* Returns `true` if all elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.all
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.all(predicate: (UInt) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
return true
}
/**
* Returns `true` if all elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.all
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.all(predicate: (ULong) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
return true
}
/**
* Returns `true` if all elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.all
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.all(predicate: (UByte) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
return true
}
/**
* Returns `true` if all elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.all
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.all(predicate: (UShort) -> Boolean): Boolean {
for (element in this) if (!predicate(element)) return false
return true
}
/**
* Returns `true` if array has at least one element.
*
* @sample samples.collections.Collections.Aggregates.any
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.any(): Boolean {
return storage.any()
}
/**
* Returns `true` if array has at least one element.
*
* @sample samples.collections.Collections.Aggregates.any
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.any(): Boolean {
return storage.any()
}
/**
* Returns `true` if array has at least one element.
*
* @sample samples.collections.Collections.Aggregates.any
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.any(): Boolean {
return storage.any()
}
/**
* Returns `true` if array has at least one element.
*
* @sample samples.collections.Collections.Aggregates.any
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.any(): Boolean {
return storage.any()
}
/**
* Returns `true` if at least one element matches the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.any(predicate: (UInt) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
return false
}
/**
* Returns `true` if at least one element matches the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.any(predicate: (ULong) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
return false
}
/**
* Returns `true` if at least one element matches the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.any(predicate: (UByte) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
return false
}
/**
* Returns `true` if at least one element matches the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.anyWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.any(predicate: (UShort) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return true
return false
}
/**
* Returns the number of elements matching the given [predicate].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.count(predicate: (UInt) -> Boolean): Int {
var count = 0
for (element in this) if (predicate(element)) ++count
return count
}
/**
* Returns the number of elements matching the given [predicate].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.count(predicate: (ULong) -> Boolean): Int {
var count = 0
for (element in this) if (predicate(element)) ++count
return count
}
/**
* Returns the number of elements matching the given [predicate].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.count(predicate: (UByte) -> Boolean): Int {
var count = 0
for (element in this) if (predicate(element)) ++count
return count
}
/**
* Returns the number of elements matching the given [predicate].
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.count(predicate: (UShort) -> Boolean): Int {
var count = 0
for (element in this) if (predicate(element)) ++count
return count
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.fold(initial: R, operation: (acc: R, UInt) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.fold(initial: R, operation: (acc: R, ULong) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.fold(initial: R, operation: (acc: R, UByte) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.fold(initial: R, operation: (acc: R, UShort) -> R): R {
var accumulator = initial
for (element in this) accumulator = operation(accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.foldIndexed(initial: R, operation: (index: Int, acc: R, UInt) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.foldIndexed(initial: R, operation: (index: Int, acc: R, ULong) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.foldIndexed(initial: R, operation: (index: Int, acc: R, UByte) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.foldIndexed(initial: R, operation: (index: Int, acc: R, UShort) -> R): R {
var index = 0
var accumulator = initial
for (element in this) accumulator = operation(index++, accumulator, element)
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.foldRight(initial: R, operation: (UInt, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.foldRight(initial: R, operation: (ULong, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.foldRight(initial: R, operation: (UByte, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.foldRight(initial: R, operation: (UShort, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.foldRightIndexed(initial: R, operation: (index: Int, UInt, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.foldRightIndexed(initial: R, operation: (index: Int, ULong, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.foldRightIndexed(initial: R, operation: (index: Int, UByte, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.foldRightIndexed(initial: R, operation: (index: Int, UShort, acc: R) -> R): R {
var index = lastIndex
var accumulator = initial
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Performs the given [action] on each element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.forEach(action: (UInt) -> Unit): Unit {
for (element in this) action(element)
}
/**
* Performs the given [action] on each element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.forEach(action: (ULong) -> Unit): Unit {
for (element in this) action(element)
}
/**
* Performs the given [action] on each element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.forEach(action: (UByte) -> Unit): Unit {
for (element in this) action(element)
}
/**
* Performs the given [action] on each element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.forEach(action: (UShort) -> Unit): Unit {
for (element in this) action(element)
}
/**
* Performs the given [action] on each element, providing sequential index with the element.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.forEachIndexed(action: (index: Int, UInt) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
/**
* Performs the given [action] on each element, providing sequential index with the element.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.forEachIndexed(action: (index: Int, ULong) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
/**
* Performs the given [action] on each element, providing sequential index with the element.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.forEachIndexed(action: (index: Int, UByte) -> Unit): Unit {
var index = 0
for (item in this) action(index++, item)
}
/**
* Performs the given [action] on each element, providing sequential index with the element.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.forEachIndexed(action: (index: Int, UShort) -> Unit): Unit {
var index = 0
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")
@ExperimentalUnsignedTypes
public fun UIntArray.max(): UInt? {
return maxOrNull()
}
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.max(): ULong? {
return maxOrNull()
}
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.max(): UByte? {
return maxOrNull()
}
@Deprecated("Use maxOrNull instead.", ReplaceWith("this.maxOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.max(): UShort? {
return maxOrNull()
}
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.maxBy(selector: (UInt) -> R): UInt? {
return maxByOrNull(selector)
}
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.maxBy(selector: (ULong) -> R): ULong? {
return maxByOrNull(selector)
}
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.maxBy(selector: (UByte) -> R): UByte? {
return maxByOrNull(selector)
}
@Deprecated("Use maxByOrNull instead.", ReplaceWith("this.maxByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.maxBy(selector: (UShort) -> R): UShort? {
return maxByOrNull(selector)
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.maxByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.maxByOrNull(selector: (UInt) -> R): UInt? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.maxByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.maxByOrNull(selector: (ULong) -> R): ULong? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.maxByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.maxByOrNull(selector: (UByte) -> R): UByte? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the largest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.maxByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.maxByOrNull(selector: (UShort) -> R): UShort? {
if (isEmpty()) return null
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
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.maxOf(selector: (UInt) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.maxOf(selector: (ULong) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.maxOf(selector: (UByte) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.maxOf(selector: (UShort) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.maxOf(selector: (UInt) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.maxOf(selector: (ULong) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.maxOf(selector: (UByte) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.maxOf(selector: (UShort) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.maxOf(selector: (UInt) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.maxOf(selector: (ULong) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.maxOf(selector: (UByte) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.maxOf(selector: (UShort) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.maxOfOrNull(selector: (UInt) -> Double): Double? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.maxOfOrNull(selector: (ULong) -> Double): Double? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.maxOfOrNull(selector: (UByte) -> Double): Double? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.maxOfOrNull(selector: (UShort) -> Double): Double? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.maxOfOrNull(selector: (UInt) -> Float): Float? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.maxOfOrNull(selector: (ULong) -> Float): Float? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.maxOfOrNull(selector: (UByte) -> Float): Float? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.maxOfOrNull(selector: (UShort) -> Float): Float? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
maxValue = maxOf(maxValue, v)
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.maxOfOrNull(selector: (UInt) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.maxOfOrNull(selector: (ULong) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.maxOfOrNull(selector: (UByte) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.maxOfOrNull(selector: (UShort) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (maxValue < v) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.maxOfWith(comparator: Comparator<in R>, selector: (UInt) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.maxOfWith(comparator: Comparator<in R>, selector: (ULong) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.maxOfWith(comparator: Comparator<in R>, selector: (UByte) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.maxOfWith(comparator: Comparator<in R>, selector: (UShort) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.maxOfWithOrNull(comparator: Comparator<in R>, selector: (UInt) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.maxOfWithOrNull(comparator: Comparator<in R>, selector: (ULong) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.maxOfWithOrNull(comparator: Comparator<in R>, selector: (UByte) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.maxOfWithOrNull(comparator: Comparator<in R>, selector: (UShort) -> R): R? {
if (isEmpty()) return null
var maxValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(maxValue, v) < 0) {
maxValue = v
}
}
return maxValue
}
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.maxOrNull(): UInt? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (max < e) max = e
}
return max
}
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.maxOrNull(): ULong? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (max < e) max = e
}
return max
}
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.maxOrNull(): UByte? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (max < e) max = e
}
return max
}
/**
* Returns the largest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.maxOrNull(): UShort? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (max < e) 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")
@ExperimentalUnsignedTypes
public fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt? {
return maxWithOrNull(comparator)
}
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.maxWith(comparator: Comparator<in ULong>): ULong? {
return maxWithOrNull(comparator)
}
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.maxWith(comparator: Comparator<in UByte>): UByte? {
return maxWithOrNull(comparator)
}
@Deprecated("Use maxWithOrNull instead.", ReplaceWith("this.maxWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.maxWith(comparator: Comparator<in UShort>): UShort? {
return maxWithOrNull(comparator)
}
/**
* Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.maxWithOrNull(comparator: Comparator<in UInt>): UInt? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(max, e) < 0) max = e
}
return max
}
/**
* Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.maxWithOrNull(comparator: Comparator<in ULong>): ULong? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(max, e) < 0) max = e
}
return max
}
/**
* Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.maxWithOrNull(comparator: Comparator<in UByte>): UByte? {
if (isEmpty()) return null
var max = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(max, e) < 0) max = e
}
return max
}
/**
* Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.maxWithOrNull(comparator: Comparator<in UShort>): UShort? {
if (isEmpty()) return null
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 minOrNull instead.", ReplaceWith("this.minOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UIntArray.min(): UInt? {
return minOrNull()
}
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.min(): ULong? {
return minOrNull()
}
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.min(): UByte? {
return minOrNull()
}
@Deprecated("Use minOrNull instead.", ReplaceWith("this.minOrNull()"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.min(): UShort? {
return minOrNull()
}
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.minBy(selector: (UInt) -> R): UInt? {
return minByOrNull(selector)
}
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.minBy(selector: (ULong) -> R): ULong? {
return minByOrNull(selector)
}
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.minBy(selector: (UByte) -> R): UByte? {
return minByOrNull(selector)
}
@Deprecated("Use minByOrNull instead.", ReplaceWith("this.minByOrNull(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.minBy(selector: (UShort) -> R): UShort? {
return minByOrNull(selector)
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.minByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.minByOrNull(selector: (UInt) -> R): UInt? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.minByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.minByOrNull(selector: (ULong) -> R): ULong? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.minByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.minByOrNull(selector: (UByte) -> R): UByte? {
if (isEmpty()) return null
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
}
/**
* Returns the first element yielding the smallest value of the given function or `null` if there are no elements.
*
* @sample samples.collections.Collections.Aggregates.minByOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.minByOrNull(selector: (UShort) -> R): UShort? {
if (isEmpty()) return null
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
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.minOf(selector: (UInt) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.minOf(selector: (ULong) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.minOf(selector: (UByte) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.minOf(selector: (UShort) -> Double): Double {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.minOf(selector: (UInt) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.minOf(selector: (ULong) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.minOf(selector: (UByte) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.minOf(selector: (UShort) -> Float): Float {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.minOf(selector: (UInt) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.minOf(selector: (ULong) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.minOf(selector: (UByte) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.minOf(selector: (UShort) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.minOfOrNull(selector: (UInt) -> Double): Double? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.minOfOrNull(selector: (ULong) -> Double): Double? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.minOfOrNull(selector: (UByte) -> Double): Double? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.minOfOrNull(selector: (UShort) -> Double): Double? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.minOfOrNull(selector: (UInt) -> Float): Float? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.minOfOrNull(selector: (ULong) -> Float): Float? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.minOfOrNull(selector: (UByte) -> Float): Float? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*
* If any of values produced by [selector] function is `NaN`, the returned result is `NaN`.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.minOfOrNull(selector: (UShort) -> Float): Float? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
minValue = minOf(minValue, v)
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UIntArray.minOfOrNull(selector: (UInt) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> ULongArray.minOfOrNull(selector: (ULong) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UByteArray.minOfOrNull(selector: (UByte) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value among all values produced by [selector] function
* applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R : Comparable<R>> UShortArray.minOfOrNull(selector: (UShort) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (minValue > v) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.minOfWith(comparator: Comparator<in R>, selector: (UInt) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.minOfWith(comparator: Comparator<in R>, selector: (ULong) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.minOfWith(comparator: Comparator<in R>, selector: (UByte) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array.
*
* @throws NoSuchElementException if the array is empty.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.minOfWith(comparator: Comparator<in R>, selector: (UShort) -> R): R {
if (isEmpty()) throw NoSuchElementException()
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.minOfWithOrNull(comparator: Comparator<in R>, selector: (UInt) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.minOfWithOrNull(comparator: Comparator<in R>, selector: (ULong) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.minOfWithOrNull(comparator: Comparator<in R>, selector: (UByte) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest value according to the provided [comparator]
* among all values produced by [selector] function applied to each element in the array or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.minOfWithOrNull(comparator: Comparator<in R>, selector: (UShort) -> R): R? {
if (isEmpty()) return null
var minValue = selector(this[0])
for (i in 1..lastIndex) {
val v = selector(this[i])
if (comparator.compare(minValue, v) > 0) {
minValue = v
}
}
return minValue
}
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.minOrNull(): UInt? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (min > e) min = e
}
return min
}
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.minOrNull(): ULong? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (min > e) min = e
}
return min
}
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.minOrNull(): UByte? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (min > e) min = e
}
return min
}
/**
* Returns the smallest element or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.minOrNull(): UShort? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (min > e) 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")
@ExperimentalUnsignedTypes
public fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt? {
return minWithOrNull(comparator)
}
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun ULongArray.minWith(comparator: Comparator<in ULong>): ULong? {
return minWithOrNull(comparator)
}
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UByteArray.minWith(comparator: Comparator<in UByte>): UByte? {
return minWithOrNull(comparator)
}
@Deprecated("Use minWithOrNull instead.", ReplaceWith("this.minWithOrNull(comparator)"))
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5", hiddenSince = "1.6")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun UShortArray.minWith(comparator: Comparator<in UShort>): UShort? {
return minWithOrNull(comparator)
}
/**
* Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UIntArray.minWithOrNull(comparator: Comparator<in UInt>): UInt? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(min, e) > 0) min = e
}
return min
}
/**
* Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun ULongArray.minWithOrNull(comparator: Comparator<in ULong>): ULong? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(min, e) > 0) min = e
}
return min
}
/**
* Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UByteArray.minWithOrNull(comparator: Comparator<in UByte>): UByte? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(min, e) > 0) min = e
}
return min
}
/**
* Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
public fun UShortArray.minWithOrNull(comparator: Comparator<in UShort>): UShort? {
if (isEmpty()) return null
var min = this[0]
for (i in 1..lastIndex) {
val e = this[i]
if (comparator.compare(min, e) > 0) min = e
}
return min
}
/**
* Returns `true` if the array has no elements.
*
* @sample samples.collections.Collections.Aggregates.none
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.none(): Boolean {
return isEmpty()
}
/**
* Returns `true` if the array has no elements.
*
* @sample samples.collections.Collections.Aggregates.none
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.none(): Boolean {
return isEmpty()
}
/**
* Returns `true` if the array has no elements.
*
* @sample samples.collections.Collections.Aggregates.none
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.none(): Boolean {
return isEmpty()
}
/**
* Returns `true` if the array has no elements.
*
* @sample samples.collections.Collections.Aggregates.none
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.none(): Boolean {
return isEmpty()
}
/**
* Returns `true` if no elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.none(predicate: (UInt) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
return true
}
/**
* Returns `true` if no elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.none(predicate: (ULong) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
return true
}
/**
* Returns `true` if no elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.none(predicate: (UByte) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
return true
}
/**
* Returns `true` if no elements match the given [predicate].
*
* @sample samples.collections.Collections.Aggregates.noneWithPredicate
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.none(predicate: (UShort) -> Boolean): Boolean {
for (element in this) if (predicate(element)) return false
return true
}
/**
* Performs the given [action] on each element and returns the array itself afterwards.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.onEach(action: (UInt) -> Unit): UIntArray {
return apply { for (element in this) action(element) }
}
/**
* Performs the given [action] on each element and returns the array itself afterwards.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.onEach(action: (ULong) -> Unit): ULongArray {
return apply { for (element in this) action(element) }
}
/**
* Performs the given [action] on each element and returns the array itself afterwards.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.onEach(action: (UByte) -> Unit): UByteArray {
return apply { for (element in this) action(element) }
}
/**
* Performs the given [action] on each element and returns the array itself afterwards.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.onEach(action: (UShort) -> Unit): UShortArray {
return apply { for (element in this) action(element) }
}
/**
* Performs the given [action] on each element, providing sequential index with the element,
* and returns the array itself afterwards.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.onEachIndexed(action: (index: Int, UInt) -> Unit): UIntArray {
return apply { forEachIndexed(action) }
}
/**
* Performs the given [action] on each element, providing sequential index with the element,
* and returns the array itself afterwards.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.onEachIndexed(action: (index: Int, ULong) -> Unit): ULongArray {
return apply { forEachIndexed(action) }
}
/**
* Performs the given [action] on each element, providing sequential index with the element,
* and returns the array itself afterwards.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.onEachIndexed(action: (index: Int, UByte) -> Unit): UByteArray {
return apply { forEachIndexed(action) }
}
/**
* Performs the given [action] on each element, providing sequential index with the element,
* and returns the array itself afterwards.
* @param [action] function that takes the index of an element and the element itself
* and performs the action on the element.
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.onEachIndexed(action: (index: Int, UShort) -> Unit): UShortArray {
return apply { forEachIndexed(action) }
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduce(operation: (acc: UInt, UInt) -> UInt): UInt {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduce(operation: (acc: ULong, ULong) -> ULong): ULong {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduce(operation: (acc: UByte, UByte) -> UByte): UByte {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduce(operation: (acc: UShort, UShort) -> UShort): UShort {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceIndexed(operation: (index: Int, acc: UInt, UInt) -> UInt): UInt {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceIndexed(operation: (index: Int, acc: ULong, ULong) -> ULong): ULong {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceIndexed(operation: (index: Int, acc: UByte, UByte) -> UByte): UByte {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceIndexed(operation: (index: Int, acc: UShort, UShort) -> UShort): UShort {
if (isEmpty())
throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceIndexedOrNull(operation: (index: Int, acc: UInt, UInt) -> UInt): UInt? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceIndexedOrNull(operation: (index: Int, acc: ULong, ULong) -> ULong): ULong? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceIndexedOrNull(operation: (index: Int, acc: UByte, UByte) -> UByte): UByte? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceIndexedOrNull(operation: (index: Int, acc: UShort, UShort) -> UShort): UShort? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(index, accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceOrNull(operation: (acc: UInt, UInt) -> UInt): UInt? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceOrNull(operation: (acc: ULong, ULong) -> ULong): ULong? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceOrNull(operation: (acc: UByte, UByte) -> UByte): UByte? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceOrNull(operation: (acc: UShort, UShort) -> UShort): UShort? {
if (isEmpty())
return null
var accumulator = this[0]
for (index in 1..lastIndex) {
accumulator = operation(accumulator, this[index])
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceRight(operation: (UInt, acc: UInt) -> UInt): UInt {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceRight(operation: (ULong, acc: ULong) -> ULong): ULong {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceRight(operation: (UByte, acc: UByte) -> UByte): UByte {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceRight(operation: (UShort, acc: UShort) -> UShort): UShort {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceRightIndexed(operation: (index: Int, UInt, acc: UInt) -> UInt): UInt {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceRightIndexed(operation: (index: Int, ULong, acc: ULong) -> ULong): ULong {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceRightIndexed(operation: (index: Int, UByte, acc: UByte) -> UByte): UByte {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceRightIndexed(operation: (index: Int, UShort, acc: UShort) -> UShort): UShort {
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceRightIndexedOrNull(operation: (index: Int, UInt, acc: UInt) -> UInt): UInt? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceRightIndexedOrNull(operation: (index: Int, ULong, acc: ULong) -> ULong): ULong? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceRightIndexedOrNull(operation: (index: Int, UByte, acc: UByte) -> UByte): UByte? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceRightIndexedOrNull(operation: (index: Int, UShort, acc: UShort) -> UShort): UShort? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(index, get(index), accumulator)
--index
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UIntArray.reduceRightOrNull(operation: (UInt, acc: UInt) -> UInt): UInt? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun ULongArray.reduceRightOrNull(operation: (ULong, acc: ULong) -> ULong): ULong? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UByteArray.reduceRightOrNull(operation: (UByte, acc: UByte) -> UByte): UByte? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun UShortArray.reduceRightOrNull(operation: (UShort, acc: UShort) -> UShort): UShort? {
var index = lastIndex
if (index < 0) return null
var accumulator = get(index--)
while (index >= 0) {
accumulator = operation(get(index--), accumulator)
}
return accumulator
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.runningFold(initial: R, operation: (acc: R, UInt) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (element in this) {
accumulator = operation(accumulator, element)
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.runningFold(initial: R, operation: (acc: R, ULong) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (element in this) {
accumulator = operation(accumulator, element)
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.runningFold(initial: R, operation: (acc: R, UByte) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (element in this) {
accumulator = operation(accumulator, element)
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.runningFold(initial: R, operation: (acc: R, UShort) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (element in this) {
accumulator = operation(accumulator, element)
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, UInt) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (index in indices) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, ULong) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (index in indices) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, UByte) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (index in indices) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningFold
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.runningFoldIndexed(initial: R, operation: (index: Int, acc: R, UShort) -> R): List<R> {
if (isEmpty()) return listOf(initial)
val result = ArrayList<R>(size + 1).apply { add(initial) }
var accumulator = initial
for (index in indices) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.runningReduce(operation: (acc: UInt, UInt) -> UInt): List<UInt> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UInt>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.runningReduce(operation: (acc: ULong, ULong) -> ULong): List<ULong> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<ULong>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.runningReduce(operation: (acc: UByte, UByte) -> UByte): List<UByte> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UByte>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.runningReduce(operation: (acc: UShort, UShort) -> UShort): List<UShort> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UShort>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.runningReduceIndexed(operation: (index: Int, acc: UInt, UInt) -> UInt): List<UInt> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UInt>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.runningReduceIndexed(operation: (index: Int, acc: ULong, ULong) -> ULong): List<ULong> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<ULong>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.runningReduceIndexed(operation: (index: Int, acc: UByte, UByte) -> UByte): List<UByte> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UByte>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with the first element of this array.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.runningReduce
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.runningReduceIndexed(operation: (index: Int, acc: UShort, UShort) -> UShort): List<UShort> {
if (isEmpty()) return emptyList()
var accumulator = this[0]
val result = ArrayList<UShort>(size).apply { add(accumulator) }
for (index in 1 until size) {
accumulator = operation(index, accumulator, this[index])
result.add(accumulator)
}
return result
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.scan(initial: R, operation: (acc: R, UInt) -> R): List<R> {
return runningFold(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.scan(initial: R, operation: (acc: R, ULong) -> R): List<R> {
return runningFold(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.scan(initial: R, operation: (acc: R, UByte) -> R): List<R> {
return runningFold(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.scan(initial: R, operation: (acc: R, UShort) -> R): List<R> {
return runningFold(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UIntArray.scanIndexed(initial: R, operation: (index: Int, acc: R, UInt) -> R): List<R> {
return runningFoldIndexed(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> ULongArray.scanIndexed(initial: R, operation: (index: Int, acc: R, ULong) -> R): List<R> {
return runningFoldIndexed(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UByteArray.scanIndexed(initial: R, operation: (index: Int, acc: R, UByte) -> R): List<R> {
return runningFoldIndexed(initial, operation)
}
/**
* Returns a list containing successive accumulation values generated by applying [operation] from left to right
* to each element, its index in the original array and current accumulator value that starts with [initial] value.
*
* Note that `acc` value passed to [operation] function should not be mutated;
* otherwise it would affect the previous value in resulting list.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.scan
*/
@SinceKotlin("1.4")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalStdlibApi::class)
@kotlin.internal.InlineOnly
public inline fun <R> UShortArray.scanIndexed(initial: R, operation: (index: Int, acc: R, UShort) -> R): List<R> {
return runningFoldIndexed(initial, operation)
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumBy(selector: (UInt) -> UInt): UInt {
var sum: UInt = 0u
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumBy(selector: (ULong) -> UInt): UInt {
var sum: UInt = 0u
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumBy(selector: (UByte) -> UInt): UInt {
var sum: UInt = 0u
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumBy(selector: (UShort) -> UInt): UInt {
var sum: UInt = 0u
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumByDouble(selector: (UInt) -> Double): Double {
var sum: Double = 0.0
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumByDouble(selector: (ULong) -> Double): Double {
var sum: Double = 0.0
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumByDouble(selector: (UByte) -> Double): Double {
var sum: Double = 0.0
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@Deprecated("Use sumOf instead.", ReplaceWith("this.sumOf(selector)"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumByDouble(selector: (UShort) -> Double): Double {
var sum: Double = 0.0
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfDouble")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumOf(selector: (UInt) -> Double): Double {
var sum: Double = 0.toDouble()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfDouble")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumOf(selector: (ULong) -> Double): Double {
var sum: Double = 0.toDouble()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfDouble")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumOf(selector: (UByte) -> Double): Double {
var sum: Double = 0.toDouble()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfDouble")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> Double): Double {
var sum: Double = 0.toDouble()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfInt")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumOf(selector: (UInt) -> Int): Int {
var sum: Int = 0.toInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfInt")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumOf(selector: (ULong) -> Int): Int {
var sum: Int = 0.toInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfInt")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumOf(selector: (UByte) -> Int): Int {
var sum: Int = 0.toInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfInt")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> Int): Int {
var sum: Int = 0.toInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfLong")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumOf(selector: (UInt) -> Long): Long {
var sum: Long = 0.toLong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfLong")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumOf(selector: (ULong) -> Long): Long {
var sum: Long = 0.toLong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfLong")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumOf(selector: (UByte) -> Long): Long {
var sum: Long = 0.toLong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.4")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfLong")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> Long): Long {
var sum: Long = 0.toLong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfUInt")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumOf(selector: (UInt) -> UInt): UInt {
var sum: UInt = 0.toUInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfUInt")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumOf(selector: (ULong) -> UInt): UInt {
var sum: UInt = 0.toUInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfUInt")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumOf(selector: (UByte) -> UInt): UInt {
var sum: UInt = 0.toUInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfUInt")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> UInt): UInt {
var sum: UInt = 0.toUInt()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfULong")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UIntArray.sumOf(selector: (UInt) -> ULong): ULong {
var sum: ULong = 0.toULong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfULong")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun ULongArray.sumOf(selector: (ULong) -> ULong): ULong {
var sum: ULong = 0.toULong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfULong")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UByteArray.sumOf(selector: (UByte) -> ULong): ULong {
var sum: ULong = 0.toULong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns the sum of all values produced by [selector] function applied to each element in the array.
*/
@SinceKotlin("1.5")
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@OverloadResolutionByLambdaReturnType
@Suppress("INAPPLICABLE_JVM_NAME")
@kotlin.jvm.JvmName("sumOfULong")
@ExperimentalUnsignedTypes
@WasExperimental(ExperimentalUnsignedTypes::class)
@kotlin.internal.InlineOnly
public inline fun UShortArray.sumOf(selector: (UShort) -> ULong): ULong {
var sum: ULong = 0.toULong()
for (element in this) {
sum += selector(element)
}
return sum
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UIntArray.zip(other: Array<out R>): List<Pair<UInt, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> ULongArray.zip(other: Array<out R>): List<Pair<ULong, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UByteArray.zip(other: Array<out R>): List<Pair<UByte, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UShortArray.zip(other: Array<out R>): List<Pair<UShort, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UIntArray.zip(other: Array<out R>, transform: (a: UInt, b: R) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> ULongArray.zip(other: Array<out R>, transform: (a: ULong, b: R) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UByteArray.zip(other: Array<out R>, transform: (a: UByte, b: R) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UShortArray.zip(other: Array<out R>, transform: (a: UShort, b: R) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of pairs built from the elements of `this` collection and [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UIntArray.zip(other: Iterable<R>): List<Pair<UInt, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` collection and [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> ULongArray.zip(other: Iterable<R>): List<Pair<ULong, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` collection and [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UByteArray.zip(other: Iterable<R>): List<Pair<UByte, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` collection and [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun <R> UShortArray.zip(other: Iterable<R>): List<Pair<UShort, R>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of values built from the elements of `this` array and the [other] collection with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UIntArray.zip(other: Iterable<R>, transform: (a: UInt, b: R) -> V): List<V> {
val arraySize = size
val list = ArrayList<V>(minOf(other.collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in other) {
if (i >= arraySize) break
list.add(transform(this[i++], element))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] collection with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> ULongArray.zip(other: Iterable<R>, transform: (a: ULong, b: R) -> V): List<V> {
val arraySize = size
val list = ArrayList<V>(minOf(other.collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in other) {
if (i >= arraySize) break
list.add(transform(this[i++], element))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] collection with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UByteArray.zip(other: Iterable<R>, transform: (a: UByte, b: R) -> V): List<V> {
val arraySize = size
val list = ArrayList<V>(minOf(other.collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in other) {
if (i >= arraySize) break
list.add(transform(this[i++], element))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] collection with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <R, V> UShortArray.zip(other: Iterable<R>, transform: (a: UShort, b: R) -> V): List<V> {
val arraySize = size
val list = ArrayList<V>(minOf(other.collectionSizeOrDefault(10), arraySize))
var i = 0
for (element in other) {
if (i >= arraySize) break
list.add(transform(this[i++], element))
}
return list
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun UIntArray.zip(other: UIntArray): List<Pair<UInt, UInt>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun ULongArray.zip(other: ULongArray): List<Pair<ULong, ULong>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun UByteArray.zip(other: UByteArray): List<Pair<UByte, UByte>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
* The returned list has length of the shortest collection.
*
* @sample samples.collections.Iterables.Operations.zipIterable
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public infix fun UShortArray.zip(other: UShortArray): List<Pair<UShort, UShort>> {
return zip(other) { t1, t2 -> t1 to t2 }
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest array.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UIntArray.zip(other: UIntArray, transform: (a: UInt, b: UInt) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest array.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> ULongArray.zip(other: ULongArray, transform: (a: ULong, b: ULong) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest array.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UByteArray.zip(other: UByteArray, transform: (a: UByte, b: UByte) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns a list of values built from the elements of `this` array and the [other] array with the same index
* using the provided [transform] function applied to each pair of elements.
* The returned list has length of the shortest array.
*
* @sample samples.collections.Iterables.Operations.zipIterableWithTransform
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun <V> UShortArray.zip(other: UShortArray, transform: (a: UShort, b: UShort) -> V): List<V> {
val size = minOf(size, other.size)
val list = ArrayList<V>(size)
for (i in 0 until size) {
list.add(transform(this[i], other[i]))
}
return list
}
/**
* Returns the sum of all elements in the array.
*/
@kotlin.jvm.JvmName("sumOfUInt")
@SinceKotlin("1.5")
@WasExperimental(ExperimentalUnsignedTypes::class)
public fun Array<out UInt>.sum(): UInt {
var sum: UInt = 0u
for (element in this) {
sum += element
}
return sum
}
/**
* Returns the sum of all elements in the array.
*/
@kotlin.jvm.JvmName("sumOfULong")
@SinceKotlin("1.5")
@WasExperimental(ExperimentalUnsignedTypes::class)
public fun Array<out ULong>.sum(): ULong {
var sum: ULong = 0uL
for (element in this) {
sum += element
}
return sum
}
/**
* Returns the sum of all elements in the array.
*/
@kotlin.jvm.JvmName("sumOfUByte")
@SinceKotlin("1.5")
@WasExperimental(ExperimentalUnsignedTypes::class)
public fun Array<out UByte>.sum(): UInt {
var sum: UInt = 0u
for (element in this) {
sum += element
}
return sum
}
/**
* Returns the sum of all elements in the array.
*/
@kotlin.jvm.JvmName("sumOfUShort")
@SinceKotlin("1.5")
@WasExperimental(ExperimentalUnsignedTypes::class)
public fun Array<out UShort>.sum(): UInt {
var sum: UInt = 0u
for (element in this) {
sum += element
}
return sum
}
/**
* Returns the sum of all elements in the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UIntArray.sum(): UInt {
return storage.sum().toUInt()
}
/**
* Returns the sum of all elements in the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun ULongArray.sum(): ULong {
return storage.sum().toULong()
}
/**
* Returns the sum of all elements in the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UByteArray.sum(): UInt {
return sumOf { it.toUInt() }
}
/**
* Returns the sum of all elements in the array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public inline fun UShortArray.sum(): UInt {
return sumOf { it.toUInt() }
}