ArrayList

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

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.

class ArrayList<E> : AbstractMutableList<E> , MutableList<E> , RandomAccess
typealias ArrayList = ArrayList<E>

Constructors

ArrayList
Link copied to clipboard
fun ArrayList()
fun ArrayList()

Creates an empty ArrayList.

ArrayList
Link copied to clipboard
fun ArrayList(initialCapacity: Int = 0)
fun ArrayList(initialCapacity: Int = 0)

Creates an empty ArrayList.

fun ArrayList(initialCapacity: Int = 0)
ArrayList
Link copied to clipboard
fun <E> ArrayList(elements: Collection<E>)
fun <E> ArrayList(elements: Collection<E>)

Creates an ArrayList filled from the elements collection.

fun <E> ArrayList(elements: Collection<E>)

Functions

add
Link copied to clipboard
Common
open override fun add(element: E): Boolean
open override fun add(index: Int, element: E)
open override fun add(element: E): Boolean
open override fun add(element: E): Boolean

Adds the specified element to the end of this list.

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

Inserts an element into the list at the specified index.

addAll
Link copied to clipboard
Common
open override fun addAll(elements: Collection<E>): Boolean
open override fun addAll(index: Int, elements: Collection<E>): Boolean
open override fun addAll(elements: Collection<E>): Boolean
open override fun addAll(elements: Collection<E>): Boolean

Adds all of the elements of the specified collection to the end of this list.

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

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

clear
Link copied to clipboard
Common
open override fun clear()
open override fun clear()
open override fun clear()

Removes all elements from this collection.

contains
Link copied to clipboard
Common
open operator override fun contains(element: @UnsafeVariance E): Boolean
Native
abstract operator override fun contains(element: E): Boolean

Checks if the specified element is contained in this collection.

containsAll
Link copied to clipboard
open override fun containsAll(elements: Collection<E>): Boolean
abstract override fun containsAll(elements: Collection<E>): Boolean

Checks if all elements in the specified collection are contained in this collection.

Common
open override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
ensureCapacity
Link copied to clipboard
fun ensureCapacity(minCapacity: Int)
fun ensureCapacity(minCapacity: Int)
JS
fun ensureCapacity(minCapacity: Int)

Does nothing in this ArrayList implementation.

equals
Link copied to clipboard
JS
open operator override fun equals(other: Any?): Boolean

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

Native
open operator override fun equals(other: Any?): Boolean
get
Link copied to clipboard
Common
open operator override fun get(index: Int): E
open operator override fun get(index: Int): E
open operator override fun get(index: Int): E

Returns the element at the specified index in the list.

hashCode
Link copied to clipboard
JS
open override fun hashCode(): Int

Returns the hash code value for this list.

Native
open override fun hashCode(): Int
indexOf
Link copied to clipboard
Common
open override fun indexOf(element: @UnsafeVariance E): Int
open override fun indexOf(element: E): Int
open override 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.

isEmpty
Link copied to clipboard
open override fun isEmpty(): Boolean
open override fun isEmpty(): Boolean

Returns true if the collection is empty (contains no elements), false otherwise.

Common
open override fun isEmpty(): Boolean
iterator
Link copied to clipboard
Common
open operator override fun iterator(): MutableIterator<E>
Native
open operator override fun iterator(): MutableIterator<E>

Returns an iterator over the elements of this object.

lastIndexOf
Link copied to clipboard
Common
open override fun lastIndexOf(element: @UnsafeVariance E): Int
open override fun lastIndexOf(element: E): Int
open override 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.

listIterator
Link copied to clipboard
Common
open override fun listIterator(): MutableListIterator<E>
open override fun listIterator(index: Int): MutableListIterator<E>
Native
open override fun listIterator(): MutableListIterator<E>

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

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

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

remove
Link copied to clipboard
Common
open override fun remove(element: E): Boolean
open override fun remove(element: E): Boolean
open override fun remove(element: E): Boolean

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

removeAll
Link copied to clipboard
Common
open override fun removeAll(elements: Collection<E>): Boolean
Native
open override fun removeAll(elements: Collection<E>): Boolean

Removes all of this collection's elements that are also contained in the specified collection.

removeAt
Link copied to clipboard
Common
open override fun removeAt(index: Int): E
open override fun removeAt(index: Int): E
open override fun removeAt(index: Int): E

Removes an element at the specified index from the list.

retainAll
Link copied to clipboard
Common
open override fun retainAll(elements: Collection<E>): Boolean
Native
open override fun retainAll(elements: Collection<E>): Boolean

Retains only the elements in this collection that are contained in the specified collection.

set
Link copied to clipboard
Common
open operator override fun set(index: Int, element: E): E
open operator override fun set(index: Int, element: E): E
open operator override fun set(index: Int, element: E): E

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

subList
Link copied to clipboard
Common
open override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
Native
open override 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.

toJSON
Link copied to clipboard
JS
open fun toJSON(): Any
toString
Link copied to clipboard
open override fun toString(): String
open override fun toString(): String
trimToSize
Link copied to clipboard
Common
fun trimToSize()
JS
fun trimToSize()

Does nothing in this ArrayList implementation.

Properties

size
Link copied to clipboard
open override val size: Int
open override val size: Int
open override val size: Int