ArrayList

expect class ArrayList<E> : MutableList<E> , RandomAccess
actual typealias ArrayList = ArrayList<E>
actual 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.

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

Constructors

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

Creates an empty ArrayList.

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

Creates an empty ArrayList.

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

Creates an ArrayList filled from the elements collection.

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

Functions

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

Adds the specified element to the end of this list.

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

Inserts an element into the list at the specified index.

actual open override fun add(element: E): Boolean

Adds the specified element to the end of this list.

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

Inserts an element into the list at the specified index.

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

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

actual 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.

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

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

actual 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
expect open override fun clear()
actual open override fun clear()

Removes all elements from this collection.

actual open override fun clear()

Removes all elements from this collection.

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

Checks if the specified element is contained in this collection.

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

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

abstract override fun containsAll(elements: Collection<E>): Boolean

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

ensureCapacity
Link copied to clipboard
expect fun ensureCapacity(minCapacity: Int)
actual fun ensureCapacity(minCapacity: Int)

Does nothing in this ArrayList implementation.

actual fun ensureCapacity(minCapacity: Int)
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

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

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

Returns the element at the specified index in the list.

actual open operator override fun get(index: Int): E

Returns the element at the specified index in the list.

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

Returns the hash code value for this list.

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

actual 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
expect open override fun isEmpty(): Boolean
open override fun isEmpty(): Boolean

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

actual open override fun isEmpty(): Boolean

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

iterator
Link copied to clipboard
expect open operator override fun iterator(): MutableIterator<E>
actual open operator override fun iterator(): MutableIterator<E>

Returns an iterator over the elements of this object.

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

actual 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
expect open override fun listIterator(): MutableListIterator<E>
expect open override fun listIterator(index: Int): MutableListIterator<E>
actual open override fun listIterator(): MutableListIterator<E>

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

actual 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
expect open override fun remove(element: E): Boolean
actual open override fun remove(element: E): Boolean

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

actual 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
expect open override fun removeAll(elements: Collection<E>): Boolean
actual 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
expect open override fun removeAt(index: Int): E
actual open override fun removeAt(index: Int): E

Removes an element at the specified index from the list.

actual open override fun removeAt(index: Int): E

Removes an element at the specified index from the list.

retainAll
Link copied to clipboard
expect open override fun retainAll(elements: Collection<E>): Boolean
actual 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
expect open operator override fun set(index: Int, element: E): E
actual open operator override fun set(index: Int, element: E): E

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

actual 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
expect open override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
actual 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
open fun toJSON(): Any
toString
Link copied to clipboard
open override fun toString(): String
open override fun toString(): String
trimToSize
Link copied to clipboard
expect fun trimToSize()
actual fun trimToSize()

Does nothing in this ArrayList implementation.

actual fun trimToSize()

Properties

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