ArrayDeque

class ArrayDeque<E> : AbstractMutableList<E>

Resizable-array implementation of the deque data structure.

The name deque is short for "double ended queue" and is usually pronounced "deck".

The collection provide methods for convenient access to the both ends. It also implements MutableList interface and supports efficient get/set operations by index.

Since Kotlin

1.4

Constructors

ArrayDeque
Link copied to clipboard
Common
fun ArrayDeque(initialCapacity: Int)

Constructs an empty deque with specified initialCapacity, or throws IllegalArgumentException if initialCapacity is negative.

ArrayDeque
Link copied to clipboard
Common
fun ArrayDeque()

Constructs an empty deque.

ArrayDeque
Link copied to clipboard
Common
fun <E> ArrayDeque(elements: Collection<E>)

Constructs a deque that contains the same elements as the specified elements collection in the same order.

Functions

add
Link copied to clipboard
Common
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)
addAll
Link copied to clipboard
Common
open override fun addAll(elements: Collection<E>): Boolean
open override fun addAll(index: Int, elements: Collection<E>): Boolean
addFirst
Link copied to clipboard
Common
fun addFirst(element: E)

Prepends the specified element to this deque.

addLast
Link copied to clipboard
Common
fun addLast(element: E)

Appends the specified element to this deque.

clear
Link copied to clipboard
Common
open override fun clear()
contains
Link copied to clipboard
Common
open operator override fun contains(element: E): Boolean
containsAll
Link copied to clipboard
Common
open override fun containsAll(elements: Collection<E>): Boolean
first
Link copied to clipboard
Common
fun first(): E

Returns the first element, or throws NoSuchElementException if this deque is empty.

firstOrNull
Link copied to clipboard
Common
fun firstOrNull(): E?

Returns the first element, or null if this deque is empty.

get
Link copied to clipboard
Common
open operator override fun get(index: Int): E
indexOf
Link copied to clipboard
Common
open override fun indexOf(element: E): Int
isEmpty
Link copied to clipboard
Common
open override fun isEmpty(): Boolean
iterator
Link copied to clipboard
Common
open operator override fun iterator(): MutableIterator<E>
last
Link copied to clipboard
Common
fun last(): E

Returns the last element, or throws NoSuchElementException if this deque is empty.

lastIndexOf
Link copied to clipboard
Common
open override fun lastIndexOf(element: E): Int
lastOrNull
Link copied to clipboard
Common
fun lastOrNull(): E?

Returns the last element, or null if this deque is empty.

listIterator
Link copied to clipboard
Common
open override fun listIterator(): MutableListIterator<E>
open override fun listIterator(index: Int): MutableListIterator<E>
remove
Link copied to clipboard
Common
open override fun remove(element: E): Boolean
removeAll
Link copied to clipboard
Common
open override fun removeAll(elements: Collection<E>): Boolean
removeAt
Link copied to clipboard
Common
open override fun removeAt(index: Int): E
removeFirst
Link copied to clipboard
Common
fun removeFirst(): E

Removes the first element from this deque and returns that removed element, or throws NoSuchElementException if this deque is empty.

removeFirstOrNull
Link copied to clipboard
Common
fun removeFirstOrNull(): E?

Removes the first element from this deque and returns that removed element, or returns null if this deque is empty.

removeLast
Link copied to clipboard
Common
fun removeLast(): E

Removes the last element from this deque and returns that removed element, or throws NoSuchElementException if this deque is empty.

removeLastOrNull
Link copied to clipboard
Common
fun removeLastOrNull(): E?

Removes the last element from this deque and returns that removed element, or returns null if this deque is empty.

retainAll
Link copied to clipboard
Common
open override fun retainAll(elements: Collection<E>): Boolean
set
Link copied to clipboard
Common
open operator override fun set(index: Int, element: E): E
subList
Link copied to clipboard
Common
open override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
toArray
Link copied to clipboard
Common
open fun toArray(): Array<Any?>
open fun <T> toArray(array: Array<T>): Array<T>

Properties

size
Link copied to clipboard
Common
open override var size: Int = 0