UByteArray

Constructors

Link copied to clipboard
constructor(size: Int)

Creates a new array of the specified size, with all elements initialized to zero.

Properties

Link copied to clipboard

Returns the range of valid indices for the array.

Since Kotlin 1.3

Returns an IntRange of the valid indices for this collection.

Since Kotlin 1.0
Link copied to clipboard

Returns the last valid index for the array.

Since Kotlin 1.3
Link copied to clipboard
open override val size: Int

Returns the number of elements in the array.

Since Kotlin 1.3

Functions

Link copied to clipboard

Returns true if all elements match the given predicate.

Since Kotlin 1.3
inline fun <T> Iterable<T>.all(predicate: (T) -> Boolean): Boolean

Returns true if all elements match the given predicate.

Since Kotlin 1.0
Link copied to clipboard

Returns true if array has at least one element.

Since Kotlin 1.3
fun <T> Iterable<T>.any(): Boolean

Returns true if collection has at least one element.

Since Kotlin 1.0

Returns true if at least one element matches the given predicate.

Since Kotlin 1.3
inline fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean

Returns true if at least one element matches the given predicate.

Since Kotlin 1.0
Link copied to clipboard

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.

Since Kotlin 1.3
Link copied to clipboard
inline fun <T> Iterable<T>.asIterable(): Iterable<T>

Returns this collection as an Iterable.

Since Kotlin 1.0
Link copied to clipboard

Returns a List that wraps the original array.

Since Kotlin 1.3

Returns a List that wraps the original array.

Since Kotlin 1.3

Returns a List that wraps the original array.

Since Kotlin 1.3

Returns a List that wraps the original array.

Since Kotlin 1.3
Link copied to clipboard

Creates a Sequence instance that wraps the original collection returning its elements when being iterated.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T, K, V> Iterable<T>.associate(transform: (T) -> Pair<K, V>): Map<K, V>

Returns a Map containing key-value pairs provided by transform function applied to elements of the given collection.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T, K> Iterable<T>.associateBy(keySelector: (T) -> K): Map<K, T>

Returns a Map containing the elements from the given collection indexed by the key returned from keySelector function applied to each element.

Since Kotlin 1.0
inline fun <T, K, V> Iterable<T>.associateBy(keySelector: (T) -> K, valueTransform: (T) -> V): Map<K, V>

Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given collection.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K): M

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given collection and value is the element itself.

Since Kotlin 1.0
inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and and value is provided by the valueTransform function applied to elements of the given collection.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateTo(destination: M, transform: (T) -> Pair<K, V>): M

Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given collection.

Since Kotlin 1.0
Link copied to clipboard
inline fun <V> UByteArray.associateWith(valueSelector: (UByte) -> V): Map<UByte, V>

Returns a Map where keys are elements from the given array and values are produced by the valueSelector function applied to each element.

Since Kotlin 1.4
inline fun <K, V> Iterable<K>.associateWith(valueSelector: (K) -> V): Map<K, V>

Returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.

Since Kotlin 1.3
Link copied to clipboard
inline fun <V, M : MutableMap<in UByte, in V>> UByteArray.associateWithTo(destination: M, valueSelector: (UByte) -> V): M

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.

Since Kotlin 1.4
inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(destination: M, valueSelector: (K) -> V): M

Populates and returns the destination mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the valueSelector function applied to that key.

Since Kotlin 1.3
Link copied to clipboard
@JvmName(name = "averageOfByte")
fun Iterable<Byte>.average(): Double
@JvmName(name = "averageOfDouble")
fun Iterable<Double>.average(): Double
@JvmName(name = "averageOfFloat")
fun Iterable<Float>.average(): Double
@JvmName(name = "averageOfInt")
fun Iterable<Int>.average(): Double
@JvmName(name = "averageOfLong")
fun Iterable<Long>.average(): Double
@JvmName(name = "averageOfShort")
fun Iterable<Short>.average(): Double

Returns an average value of elements in the collection.

Since Kotlin 1.0
Link copied to clipboard
fun UByteArray.binarySearch(element: UByte, fromIndex: Int = 0, toIndex: Int = size): Int

Searches the array or the range of the array for the provided element using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined.

Since Kotlin 1.3
Link copied to clipboard
fun <T> Iterable<T>.chunked(size: Int): List<List<T>>

Splits this collection into a list of lists each not exceeding the given