CharArray

class CharArray(size: Int)(source)

An array of chars. When targeting the JVM, instances of this class are represented as char[].

Since Kotlin

1.0
class CharArray(size: Int)(source)

An array of chars. When targeting the JVM, instances of this class are represented as char[].

Since Kotlin

1.1

Constructors

Link copied to clipboard
fun CharArray(size: Int, init: (Int) -> Char)

Creates a new array of the specified size, where each element is calculated by calling the specified init function.

fun CharArray(size: Int, init: (Int) -> Char)

Creates a new array of the specified size, where each element is calculated by calling the specified init function.

Link copied to clipboard
fun CharArray(size: Int)

Creates a new array of the specified size, with all elements initialized to null char (`\u0000').

fun CharArray(size: Int)

Creates a new array of the specified size, with all elements initialized to null char (`\u0000').

Functions

Link copied to clipboard
operator fun get(index: Int): Char

Returns the array element at the given index. This method can be called using the index operator.

Since Kotlin 1.0
operator fun get(index: Int): Char

Returns the array element at the given index. This method can be called using the index operator.

Since Kotlin 1.1
Link copied to clipboard
operator fun iterator(): CharIterator

Creates an iterator over the elements of the array.

Since Kotlin 1.0
operator fun iterator(): CharIterator

Creates an iterator over the elements of the array.

Since Kotlin 1.1
Link copied to clipboard
operator fun set(index: Int, value: Char)

Sets the element at the given index to the given value. This method can be called using the index operator.

Since Kotlin 1.0
operator fun set(index: Int, value: Char)

Sets the element at the given index to the given value. This method can be called using the index operator.

Since Kotlin 1.1

Properties

Link copied to clipboard
val size: Int

Returns the number of elements in the array.

Since Kotlin 1.0
val size: Int

Returns the number of elements in the array.

Since Kotlin 1.1

Extensions

Link copied to clipboard
fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int
fun CharArray.binarySearch(element: Char, 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.0
Link copied to clipboard
Since Kotlin 1.0
Link copied to clipboard
inline fun <R : Comparable<R>> CharArray.maxBy(selector: (Char) -> R): Char?
inline fun <R : Comparable<R>> CharArray.maxBy(selector: (Char) -> R): Char?
Since Kotlin 1.0
Link copied to clipboard
fun CharArray.maxWith(comparator: Comparator<in Char>): Char?
fun CharArray.maxWith(comparator: Comparator<in Char>): Char?
Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.0
Link copied to clipboard
inline fun <R : Comparable<R>> CharArray.minBy(selector: (Char) -> R): Char?
inline fun <R : Comparable<R>> CharArray.minBy(selector: (Char) -> R): Char?
Since Kotlin 1.0
Link copied to clipboard
fun CharArray.minWith(comparator: Comparator<in Char>): Char?
fun CharArray.minWith(comparator: Comparator<in Char>): Char?
Since Kotlin 1.0
Link copied to clipboard
inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int)
inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int)

Sorts the array in-place according to the order specified by the given comparison function.

Since Kotlin 1.1
Link copied to clipboard

Returns a new SortedSet of all elements.

Since Kotlin 1.0