W3cubDocs

/Kotlin

ArrayList

typealias ArrayList<E> = ArrayList<E>

Platform and version requirements: Kotlin 1.1, JVM

open class ArrayList<E> : 
    AbstractMutableList<E>, 
    RandomAccess

Platform and version requirements: JS

Provides a MutableList implementation, which uses a resizable array as its backing storage.

This implementation doesn't provide a way to manage capacity, as backing JS array is resizeable itself. There is no speed advantage to pre-allocating array sizes in JavaScript, so this implementation does not include any of the capacity and "growth increment" concepts.

Constructors

<init>

ArrayList(capacity: Int = 0)

Creates an empty ArrayList.

ArrayList(elements: Collection<E>)

Creates an ArrayList filled from the elements collection.

Properties

size

open val size: Int

Returns the size of the collection.

Inherited Properties

modCount

var modCount: Int

Functions

add

open fun add(element: E): Boolean

Adds the specified element to the collection.

open fun add(index: Int, element: E)

Inserts an element into the list at the specified index.

addAll

open fun addAll(elements: Collection<E>): Boolean

Adds all of the elements in the specified collection to this collection.

open fun addAll(index: Int, elements: Collection<E>): Boolean

Inserts all of the elements in the specified collection elements into this list at the specified index.

clear

open fun clear()

Removes all elements from this collection.

ensureCapacity

fun ensureCapacity(minCapacity: Int)

Does nothing in this ArrayList implementation.

get

open fun get(index: Int): E

Returns the element at the specified index in the list.

indexOf

open fun indexOf(element: E): Int

Returns the index of the first occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

lastIndexOf

open fun lastIndexOf(element: E): Int

Returns the index of the last occurrence of the specified element in the list, or -1 if the specified element is not contained in the list.

remove

open fun remove(element: E): Boolean

Removes a single instance of the specified element from this collection, if it is present.

removeAt

open fun removeAt(index: Int): E

Removes an element at the specified index from the list.

removeRange

open fun removeRange(fromIndex: Int, toIndex: Int)

Removes the range of elements from this list starting from fromIndex and ending with but not including toIndex.

set

open fun set(index: Int, element: E): E

Replaces the element at the specified position in this list with the specified element.

toArray

open fun toArray(): Array<Any?>

Returns new array of type Array<Any?> with the elements of this collection.

toString

open fun toString(): String

Returns a string representation of the object.

trimToSize

fun trimToSize()

Does nothing in this ArrayList implementation.

Inherited Functions

equals

open fun equals(other: Any?): Boolean

Compares this list with another list instance with the ordered structural equality.

hashCode

open fun hashCode(): Int

Returns the hash code value for this list.

iterator

open fun iterator(): MutableIterator<E>

Returns an iterator over the elements of this object.

listIterator

open fun listIterator(index: Int): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified index.

open fun listIterator(): MutableListIterator<E>

Returns a list iterator over the elements in this list (in proper sequence).

subList

open fun subList(
    fromIndex: Int, 
    toIndex: Int
): MutableList<E>

Returns a view of the portion of this list between the specified fromIndex (inclusive) and toIndex (exclusive). The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-array-list/