Sequence optimized for add/removing items at the beginning or end.

The underlying implementation dynamically resizes.

OperationComputational complexity
lengthO(1)
get/setO(1)
push/pop, unshift/shiftO(1) (amortized, due to dynamic sizing)
insert/removeO(n)

Constructor

new (?maxSize:Int)

Returns a new empty Deque.

Parameters:

maxSize

Optional maximum size of the collection. By default, the sequence is unbounded. If maxSize is given, any attempt to add more items will cause the method to throw FullException.

Static methods

staticfromCollection<T> (other:Collection<T>):Deque<T>

Returns a new Deque from the given collection.

Inherited Variables

Defined by VariableSequenceUpgrade

read onlylength:Int

Inherited Methods

Defined by VariableSequenceUpgrade

clear ():Void

contains (item:T):Bool

contentEquals (other:ImmutableBaseSequence<T>):Bool

extend (other:Collection<T>):Void

first ():T

firstOption ():Option<T>

get (index:Int):T

indexOf (item:T, ?fromIndex:Int):Option<Int>

insert (index:Int, item:T):Void

isEmpty ():Bool

last ():T

lastIndexOf (item:T, ?fromIndex:Int):Option<Int>

lastOption ():Option<T>

pop ():Option<T>

push (item:T):Void

remove (item:T):Bool

removeAt (index:Int):Void

reverse ():Void

set (index:Int, item:T):Void

shift ():Option<T>

slice (index:Int, ?endIndex:Int):VariableSequence<T>

sort (?comparer:T ‑> T ‑> Int):Void

splice (index:Int, count:Int):VariableSequence<T>

toString ():String

unshift (item:T):Void

unsplice (index:Int, other:Collection<T>):Void