- ByteArray
- Constructors
- Properties
- Functions
- iterator
- Extension Properties
- indices
- lastIndex
- Extension Functions
- asIterable
- asSequence
- associate
- associateBy
- associateByTo
- associateTo
- associateWith
- associateWithTo
- asUByteArray
- average
- binarySearch
- component1
- component2
- component3
- component4
- component5
- contains
- count
- distinct
- distinctBy
- dropLast
- dropLastWhile
- dropWhile
- elementAtOrElse
- elementAtOrNull
- filter
- filterIndexed
- filterIndexedTo
- filterNot
- filterNotTo
- filterTo
- findLast
- first
- firstOrNull
- flatMap
- flatMapIndexed
- flatMapIndexedTo
- flatMapTo
- foldIndexed
- foldRight
- foldRightIndexed
- forEach
- forEachIndexed
- getCharAt
- getDoubleAt
- getFloatAt
- getIntAt
- getLongAt
- getOrElse
- getOrNull
- getShortAt
- getUByteAt
- getUIntAt
- getULongAt
- getUShortAt
- groupBy
- groupByTo
- indexOf
- indexOfFirst
- indexOfLast
- inputStream
- intersect
- isEmpty
- isNotEmpty
- joinTo
- joinToString
- lastIndexOf
- lastOrNull
- mapIndexed
- mapIndexedTo
- mapTo
- maxBy
- maxByOrNull
- maxOf
- maxOfOrNull
- maxOfWith
- maxOfWithOrNull
- maxOrNull
- maxWith
- maxWithOrNull
- minBy
- minByOrNull
- minOf
- minOfOrNull
- minOfWith
- minOfWithOrNull
- minOrNull
- minWith
- minWithOrNull
- onEach
- onEachIndexed
- partition
- random
- randomOrNull
- reduce
- reduceIndexed
- reduceIndexedOrNull
- reduceOrNull
- reduceRight
- reduceRightIndexed
- reduceRightIndexedOrNull
- reduceRightOrNull
- refTo
- reverse
- reversed
- reversedArray
- runningFold
- runningFoldIndexed
- runningReduce
- runningReduceIndexed
- scanIndexed
- setCharAt
- setDoubleAt
- setFloatAt
- setIntAt
- setLongAt
- setShortAt
- setUByteAt
- setUIntAt
- setULongAt
- setUShortAt
- shuffle
- single
- singleOrNull
- slice
- sliceArray
- sortDescending
- sorted
- sortedArray
- sortedArrayDescending
- sortedBy
- sortedByDescending
- sortedDescending
- sortedWith
- subtract
- sumBy
- sumByDouble
- sumOf
- takeLast
- takeLastWhile
- takeWhile
- toCollection
- toCValues
- toHashSet
- toKString
- toList
- toMutableList
- toMutableSet
- toSet
- toSortedSet
- toString
- toUByteArray
- union
- withIndex
ByteArray
For Common, JVM, JS
An array of bytes. When targeting the JVM, instances of this class are represented as byte[] .
For Native
An array of bytes.
Constructors
Creates a new array of the specified size, with all elements initialized to zero.
Properties
Returns the number of elements in the array.
Functions
Returns the array element at the given index. This method can be called using the index operator.
iterator
Creates an iterator over the elements of the array.
Sets the element at the given index to the given value. This method can be called using the index operator.
Extension Properties
indices
Returns the range of valid indices for the array.
lastIndex
Returns the last valid index for the array.
Extension Functions
Returns true if all elements match the given predicate.
Returns true if array has at least one element.
Returns true if at least one element matches the given predicate.
asIterable
Creates an Iterable instance that wraps the original array returning its elements when being iterated.
asSequence
Creates a Sequence instance that wraps the original array returning its elements when being iterated.
associate
Returns a Map containing key-value pairs provided by transform function applied to elements of the given array.
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.
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 array.
associateTo
Populates and returns the destination mutable map with key-value pairs provided by transform function applied to each element of the given array.
associateWith
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.
asUByteArray
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.
average
Returns an average value of elements in the array.
binarySearch
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.
component1
Returns 1st element from the array.
component2
Returns 2nd element from the array.
component3
Returns 3rd element from the array.
component4
Returns 4th element from the array.
component5
Returns 5th element from the array.
contains
Returns true if element is found in the array.
count
Returns the number of elements in this array.
Returns the number of elements matching the given predicate.
distinct
Returns a list containing only distinct elements from the given array.
distinctBy
Returns a list containing only elements from the given array having distinct keys returned by the given selector function.
Returns a list containing all elements except first n elements.
dropLast
Returns a list containing all elements except last n elements.
dropLastWhile
Returns a list containing all elements except last elements that satisfy the given predicate.
dropWhile
Returns a list containing all elements except first elements that satisfy the given predicate.
elementAtOrElse
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.
elementAtOrNull
Returns an element at the given index or null if the index is out of bounds of this array.
filter
Returns a list containing only elements matching the given predicate.
filterIndexed
Returns a list containing only elements matching the given predicate.
filterIndexedTo
Appends all elements matching the given predicate to the given destination.
filterNot
Returns a list containing all elements not matching the given predicate.
filterNotTo
Appends all elements not matching the given predicate to the given destination.
filterTo
Appends all elements matching the given predicate to the given destination.
Returns the first element matching the given predicate, or null if no such element was found.
findLast
Returns the last element matching the given predicate, or null if no such element was found.
first
Returns first element.
Returns the first element matching the given predicate.
firstOrNull
Returns the first element, or null if the array is empty.
Returns the first element matching the given predicate, or null if element was not found.
flatMap
Returns a single list of all elements yielded from results of transform function being invoked on each element of original array.
flatMapIndexed
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.
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.
flatMapTo
Appends all elements yielded from results of transform function being invoked on each element of original array, to the given destination.
Accumulates value starting with initial value and applying operation from left to right to current accumulator value and each element.
foldIndexed
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.
foldRight
Accumulates value starting with initial value and applying operation from right to left to each element and current accumulator value.
foldRightIndexed
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.
forEach
Performs the given action on each element.
forEachIndexed
Performs the given action on each element, providing sequential index with the element.
getCharAt
Gets Char out of the ByteArray byte buffer at specified index index
getDoubleAt
Gets Double out of the ByteArray byte buffer at specified index index
getFloatAt
Gets Float out of the ByteArray byte buffer at specified index index
getIntAt
Gets Int out of the ByteArray byte buffer at specified index index
getLongAt
Gets Long out of the ByteArray byte buffer at specified index index
getOrElse
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.
getOrNull
Returns an element at the given index or null if the index is out of bounds of this array.
getShortAt
Gets Short out of the ByteArray byte buffer at specified index index
getUByteAt
Gets UByte out of the ByteArray byte buffer at specified index index
getUIntAt
Gets UInt out of the ByteArray byte buffer at specified index index
getULongAt
Gets ULong out of the ByteArray byte buffer at specified index index
getUShortAt
Gets UShort out of the ByteArray byte buffer at specified index index
groupBy
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.
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.
indexOf
Returns first index of element, or -1 if the array does not contain element.
indexOfFirst
Returns index of the first element matching the given predicate, or -1 if the array does not contain such element.
indexOfLast
Returns index of the last element matching the given predicate, or -1 if the array does not contain such element.
inputStream
Creates an input stream for reading data from this byte array.
Creates an input stream for reading data from the specified portion of this byte array.
intersect
Returns a set containing all elements that are contained by both this array and the specified collection.
isEmpty
Returns true if the array is empty.
isNotEmpty
Returns true if the array is not empty.
joinTo
Appends the string from all the elements separated using separator and using the given prefix and postfix if supplied.
joinToString
Creates a string from all the elements separated using separator and using the given prefix and postfix if supplied.
Returns the last element.
Returns the last element matching the given predicate.
lastIndexOf
Returns last index of element, or -1 if the array does not contain element.
lastOrNull
Returns the last element, or null if the array is empty.
Returns the last element matching the given predicate, or null if no such element was found.
Returns a list containing the results of applying the given transform function to each element in the original array.
mapIndexed
Returns a list containing the results of applying the given transform function to each element and its index in the original array.
mapIndexedTo
Applies the given transform function to each element and its index in the original array and appends the results to the given destination.
mapTo
Applies the given transform function to each element of the original array and appends the results to the given destination.
maxBy
maxByOrNull
Returns the first element yielding the largest value of the given function or null if there are no elements.
maxOf
Returns the largest value among all values produced by selector function applied to each element in the array.
maxOfOrNull
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.
maxOfWith
Returns the largest value according to the provided comparator among all values produced by selector function applied to each element in the array.
maxOfWithOrNull
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.
maxOrNull
Returns the largest element or null if there are no elements.
maxWith
maxWithOrNull
Returns the first element having the largest value according to the provided comparator or null if there are no elements.
minBy
minByOrNull
Returns the first element yielding the smallest value of the given function or null if there are no elements.
minOf
Returns the smallest value among all values produced by selector function applied to each element in the array.
minOfOrNull
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.
minOfWith
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each element in the array.
minOfWithOrNull
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.
minOrNull
Returns the smallest element or null if there are no elements.
minWith
minWithOrNull
Returns the first element having the smallest value according to the provided comparator or null if there are no elements.
Returns true if the array has no elements.
Returns true if no elements match the given predicate.
onEach
Performs the given action on each element and returns the array itself afterwards.
onEachIndexed
Performs the given action on each element, providing sequential index with the element, and returns the array itself afterwards.
partition
Splits the original array into pair of lists, where first list contains elements for which predicate yielded true , while second list contains elements for which predicate yielded false .
random
Returns a random element from this array.
Returns a random element from this array using the specified source of randomness.
randomOrNull
Returns a random element from this array, or null if this array is empty.
Returns a random element from this array using the specified source of randomness, or null if this array is empty.
reduce
Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element.
reduceIndexed
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.
reduceIndexedOrNull
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.
reduceOrNull
Accumulates value starting with the first element and applying operation from left to right to current accumulator value and each element.
reduceRight
Accumulates value starting with the last element and applying operation from right to left to each element and current accumulator value.
reduceRightIndexed
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.
reduceRightIndexedOrNull
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.
reduceRightOrNull
Accumulates value starting with the last element and applying operation from right to left to each element and current accumulator value.
refTo
reverse
Reverses elements in the array in-place.
Reverses elements of the array in the specified range in-place.
reversed
Returns a list with elements in reversed order.
reversedArray
Returns an array with elements of this array in reversed order.
runningFold
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.
runningFoldIndexed
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.
runningReduce
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.
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.
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.
scanIndexed
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.
setCharAt
Sets Char out of the ByteArray byte buffer at specified index index
setDoubleAt
Sets Double out of the ByteArray byte buffer at specified index index
setFloatAt
Sets Float out of the ByteArray byte buffer at specified index index
setIntAt
Sets Int out of the ByteArray byte buffer at specified index index
setLongAt
Sets Long out of the ByteArray byte buffer at specified index index
setShortAt
Sets Short out of the ByteArray byte buffer at specified index index
setUByteAt
Sets UByte out of the ByteArray byte buffer at specified index index
setUIntAt
Sets UInt out of the ByteArray byte buffer at specified index index
setULongAt
Sets ULong out of the ByteArray byte buffer at specified index index
setUShortAt
Sets UShort out of the ByteArray byte buffer at specified index index
shuffle
Randomly shuffles elements in this array in-place.
Randomly shuffles elements in this array in-place using the specified random instance as the source of randomness.
single
Returns the single element, or throws an exception if the array is empty or has more than one element.
Returns the single element matching the given predicate, or throws exception if there is no or more than one matching element.
singleOrNull
Returns single element, or null if the array is empty or has more than one element.
Returns the single element matching the given predicate, or null if element was not found or more than one element was found.
slice
Returns a list containing elements at indices in the specified indices range.
Returns a list containing elements at specified indices.
sliceArray
Returns an array containing elements of this array at specified indices.
Returns an array containing elements at indices in the specified indices range.
Sorts the array in-place according to the order specified by the given comparison function.
sortDescending
Sorts elements in the array in-place descending according to their natural sort order.
Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order.
sorted
Returns a list of all elements sorted according to their natural sort order.
sortedArray
Returns an array with all elements of this array sorted according to their natural sort order.
sortedArrayDescending
Returns an array with all elements of this array sorted descending according to their natural sort order.
sortedBy
Returns a list of all elements sorted according to natural sort order of the value returned by specified selector function.
sortedByDescending
Returns a list of all elements sorted descending according to natural sort order of the value returned by specified selector function.
sortedDescending
Returns a list of all elements sorted descending according to their natural sort order.
sortedWith
Returns a list of all elements sorted according to the specified comparator.
subtract
Returns a set containing all elements that are contained by this array and not contained by the specified collection.
Returns the sum of all elements in the array.
sumBy
Returns the sum of all values produced by selector function applied to each element in the array.
sumByDouble
Returns the sum of all values produced by selector function applied to each element in the array.
sumOf
Returns the sum of all values produced by selector function applied to each element in the array.
Returns a list containing first n elements.
takeLast
Returns a list containing last n elements.
takeLastWhile
Returns a list containing last elements satisfying the given predicate.
takeWhile
Returns a list containing first elements satisfying the given predicate.
toCollection
Appends all elements to the given destination collection.
toCValues
toHashSet
Returns a new HashSet of all elements.
toKString
Decodes a string from the bytes in UTF-8 encoding in this array. Bytes following the first occurrence of 0 byte, if it occurs, are not decoded.
Decodes a string from the bytes in UTF-8 encoding in this array or its subrange. Bytes following the first occurrence of 0 byte, if it occurs, are not decoded.
toList
Returns a List containing all elements.
toMutableList
Returns a new MutableList filled with all elements of this array.
toMutableSet
Returns a new MutableSet containing all distinct elements from the given array.
toSet
Returns a Set of all elements.
toSortedSet
Returns a new SortedSet of all elements.
toString
Converts the contents of this byte array to a string using the specified charset.
toUByteArray
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.
union
Returns a set containing all distinct elements from both collections.
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.
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.
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.
Источник