IntArray
Constructors
Properties
size
Returns the number of elements in the array.
val size: IntFunctions
get
Returns the array element at the given index. This method can be called using the index operator.
operator fun get(index: Int): Intiterator
Creates an iterator over the elements of the array.
operator fun iterator(): IntIteratorExtension Properties
Extension Functions
associateBy
Returns a Map containing the elements from the given array indexed by the key returned from keySelector function applied to each element.
Returns a Map containing the values provided by valueTransform and indexed by keySelector functions applied to elements of the given array.
associateByTo
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 array and value is the element itself.
fun <K, M : MutableMap<in K, in Int>> IntArray.associateByTo(
destination: M,
keySelector: (Int) -> K
): MPopulates 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 array.
fun <K, V, M : MutableMap<in K, in V>> IntArray.associateByTo(
destination: M,
keySelector: (Int) -> K,
valueTransform: (Int) -> V
): MassociateTo
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given array.
fun <K, V, M : MutableMap<in K, in V>> IntArray.associateTo(
destination: M,
transform: (Int) -> Pair<K, V>
): MassociateWith
Returns a Map where keys are elements from the given array and values are produced by the valueSelector function applied to each element.
associateWithTo
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.
fun <V, M : MutableMap<in Int, in V>> IntArray.associateWithTo(
destination: M,
valueSelector: (Int) -> V
): Mcomponent1
Returns 1st element from the array.
operator fun IntArray.component1(): Intcomponent2
Returns 2nd element from the array.
operator fun IntArray.component2(): Intcomponent3
Returns 3rd element from the array.
operator fun IntArray.component3(): Intcomponent4
Returns 4th element from the array.
operator fun IntArray.component4(): Intcomponent5
Returns 5th element from the array.
operator fun IntArray.component5(): IntelementAtOrElse
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.
fun IntArray.elementAtOrElse(
index: Int,
defaultValue: (Int) -> Int
): IntfilterIndexedTo
Appends all elements matching the given predicate to the given destination.
fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(
destination: C,
predicate: (index: Int, Int) -> Boolean
): CfilterNotTo
Appends all elements not matching the given predicate to the given destination.
fun <C : MutableCollection<in Int>> IntArray.filterNotTo(
destination: C,
predicate: (Int) -> Boolean
): CfilterTo
Appends all elements matching the given predicate to the given destination.
fun <C : MutableCollection<in Int>> IntArray.filterTo(
destination: C,
predicate: (Int) -> Boolean
): CfirstOrNull
Returns the first element, or null if the array is empty.
fun IntArray.firstOrNull(): Int?flatMapIndexedTo
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.
fun <R, C : MutableCollection<in R>> IntArray.flatMapIndexedTo(
destination: C,
transform: (index: Int, Int) -> Iterable<R>
): CflatMapTo
Appends all elements yielded from results of transform function being invoked on each element of original array, to the given destination.
fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(
destination: C,
transform: (Int) -> Iterable<R>
): CgetOrElse
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.
fun IntArray.getOrElse(
index: Int,
defaultValue: (Int) -> Int
): IntgroupBy
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.
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.
groupByTo
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.
fun <K, M : MutableMap<in K, MutableList<Int>>> IntArray.groupByTo(
destination: M,
keySelector: (Int) -> K
): MGroups 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.
fun <K, V, M : MutableMap<in K, MutableList<V>>> IntArray.groupByTo(
destination: M,
keySelector: (Int) -> K,
valueTransform: (Int) -> V
): MisNotEmpty
Returns true if the array is not empty.
fun IntArray.isNotEmpty(): BooleanjoinTo
Appends the string from all the elements separated using separator and using the given prefix and postfix if supplied.
fun <A : Appendable> IntArray.joinTo(
buffer: A,
separator: CharSequence = ", ",
prefix: CharSequence = "",
postfix: CharSequence = "",
limit: Int = -1,
truncated: CharSequence = "...",
transform: ((Int) -> CharSequence)? = null
): AjoinToString
Creates a string from all the elements separated using separator and using the given prefix and postfix if supplied.
fun IntArray.joinToString(
separator: CharSequence = ", ",
prefix: CharSequence = "",
postfix: CharSequence = "",
limit: Int = -1,
truncated: CharSequence = "...",
transform: ((Int) -> CharSequence)? = null
): StringlastOrNull
Returns the last element, or null if the array is empty.
fun IntArray.lastOrNull(): Int?mapIndexedTo
Applies the given transform function to each element and its index in the original array and appends the results to the given destination.
fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(
destination: C,
transform: (index: Int, Int) -> R
): CmapTo
Applies the given transform function to each element of the original array and appends the results to the given destination.
fun <R, C : MutableCollection<in R>> IntArray.mapTo(
destination: C,
transform: (Int) -> R
): CmaxByOrNull
Returns the first element yielding the largest value of the given function or null if there are no elements.
fun <R : Comparable<R>> IntArray.maxByOrNull(
selector: (Int) -> R
): Int?maxOf
Returns the largest value among all values produced by selector function applied to each element in the array.
fun <R : Comparable<R>> any_array<R>.maxOf(
selector: (Int) -> R
): RmaxOfOrNull
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.
fun <R : Comparable<R>> any_array<R>.maxOfOrNull(
selector: (Int) -> R
): R?maxOfWith
Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the array.
fun <R> IntArray.maxOfWith(
comparator: Comparator<in R>,
selector: (Int) -> R
): RmaxOfWithOrNull
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.
fun <R> IntArray.maxOfWithOrNull(
comparator: Comparator<in R>,
selector: (Int) -> R
): R?maxOrNull
Returns the largest element or null if there are no elements.
fun IntArray.maxOrNull(): Int?maxWith
Returns the first element having the largest value according to the provided comparator.
fun IntArray.maxWith(comparator: Comparator<in Int>): Intfun IntArray.maxWith(comparator: Comparator<in Int>): Int?maxWithOrNull
Returns the first element having the largest value according to the provided comparator or null if there are no elements.
fun IntArray.maxWithOrNull(
comparator: Comparator<in Int>
): Int?minByOrNull
Returns the first element yielding the smallest value of the given function or null if there are no elements.
fun <R : Comparable<R>> IntArray.minByOrNull(
selector: (Int) -> R
): Int?minOf
Returns the smallest value among all values produced by selector function applied to each element in the array.
fun <R : Comparable<R>> any_array<R>.minOf(
selector: (Int) -> R
): RminOfOrNull
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.
fun <R : Comparable<R>> any_array<R>.minOfOrNull(
selector: (Int) -> R
): R?minOfWith
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the array.
fun <R> IntArray.minOfWith(
comparator: Comparator<in R>,
selector: (Int) -> R
): RminOfWithOrNull
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.
fun <R> IntArray.minOfWithOrNull(
comparator: Comparator<in R>,
selector: (Int) -> R
): R?minOrNull
Returns the smallest element or null if there are no elements.
fun IntArray.minOrNull(): Int?minWith
Returns the first element having the smallest value according to the provided comparator.
fun IntArray.minWith(comparator: Comparator<in Int>): Intfun IntArray.minWith(comparator: Comparator<in Int>): Int?minWithOrNull
Returns the first element having the smallest value according to the provided comparator or null if there are no elements.
fun IntArray.minWithOrNull(
comparator: Comparator<in Int>
): Int?randomOrNull
Returns a random element from this array, or null if this array is empty.
fun IntArray.randomOrNull(): Int?refTo
fun IntArray.refTo(index: Int): CValuesRef<IntVar>reverse
Reverses elements in the array in-place.
fun IntArray.reverse()Reverses elements of the array in the specified range in-place.
fun IntArray.reverse(fromIndex: Int, toIndex: Int)runningFoldIndexed
runningReduceIndexed
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.
scanIndexed
single
Returns the single element, or throws an exception if the array is empty or has more than one element.
fun IntArray.single(): IntsingleOrNull
Returns single element, or null if the array is empty or has more than one element.
fun IntArray.singleOrNull(): Int?sliceArray
Returns an array containing elements of this array at specified indices.
fun IntArray.sliceArray(indices: Collection<Int>): IntArraysort
Sorts the array in-place according to the order specified by the given comparison function.
fun IntArray.sort(comparison: (a: Int, b: Int) -> Int)sortDescending
Sorts elements in the array in-place descending according to their natural sort order.
fun IntArray.sortDescending()Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order.
fun IntArray.sortDescending(fromIndex: Int, toIndex: Int)sortedBy
Returns a list of all elements sorted according to natural sort order of the value returned by specified selector function.
fun <R : Comparable<R>> IntArray.sortedBy(
selector: (Int) -> R?
): List<Int>sortedByDescending
Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.
fun <R : Comparable<R>> IntArray.sortedByDescending(
selector: (Int) -> R?
): List<Int>sortedWith
Returns a list of all elements sorted according to the specified comparator.
fun IntArray.sortedWith(
comparator: Comparator<in Int>
): List<Int>sumOf
Returns the sum of all values produced by selector function applied to each element in the array.
fun IntArray.sumOf(selector: (Int) -> Double): Doublefun IntArray.sumOf(selector: (Int) -> Int): Intfun IntArray.sumOf(selector: (Int) -> Long): Longfun IntArray.sumOf(selector: (Int) -> BigDecimal): BigDecimalfun IntArray.sumOf(selector: (Int) -> BigInteger): BigIntegertoCollection
Appends all elements to the given destination collection.
fun <C : MutableCollection<in Int>> IntArray.toCollection(
destination: C
): CtoMutableList
Returns a new MutableList filled with all elements of this array.
fun IntArray.toMutableList(): MutableList<Int>toMutableSet
Returns a new MutableSet containing all distinct elements from the given array.
fun IntArray.toMutableSet(): MutableSet<Int>withIndex
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.
fun IntArray.withIndex(): Iterable<IndexedValue<Int>>zip
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.
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.
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.
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.