shadow:utility

Interface Deque<E>

Interfaces

shadow:standard@CanIterate<E>

interface Deque<E>

Interface Deque<E> defines the operations that a container class must implement to be a double-ended queue (deque). A deque can be used in place of a stack or queue. A deque should be optimized for adding and removing from both the front and the back but does not necessarily provide arbitrary access to elements like classes that have the List<E> interface.

See Also

Method Summary

Modifiers Return Types Method and Description
public (Deque<E>) addFirst(E element)

Method should add an element to the beginning of the deque.

public (Deque<E>) addLast(E element)

Method should add an element to the end of the deque.

public (Deque<E>) clear()

Removes all elements from the deque.

public readonly (E) getFirst()

Method should retrieve the element at the beginning of the deque.

public readonly (E) getLast()

Method should retrieve the element at the end of the deque.

public readonly (boolean) isEmpty()

Method should check whether or not the deque is empty.

public (E) removeFirst()

Method should remove the element at the beginning of the deque.

public (E) removeLast()

Method should remove the element at the end of the deque.

Property Summary

Modifiers Return Types Method and Description
public readonly get (int) size()

Property should get the number of elements in the deque.

Method Detail

addFirst

public addFirst(E element) => (Deque<E>)

Method should add an element to the beginning of the deque. Ideally, this operation should run in constant or amortized constant time.

Parameters

element - element to add

Returns

deque after the add

addLast

public addLast(E element) => (Deque<E>)

Method should add an element to the end of the deque. Ideally, this operation should run in constant or amortized constant time.

Parameters

element - element to add

Returns

deque after the add

clear

public clear() => (Deque<E>)

Removes all elements from the deque. This operation should run in constant time.

Returns

deque after being cleared

getFirst

public readonly getFirst() => (E)

Method should retrieve the element at the beginning of the deque. This operation should run in constant time.

Returns

first element in the deque

getLast

public readonly getLast() => (E)

Method should retrieve the element at the end of the deque. This operation should run in constant time.

Returns

last element in the deque

isEmpty

public readonly isEmpty() => (boolean)

Method should check whether or not the deque is empty.

Returns

true if the deque is empty

removeFirst

public removeFirst() => (E)

Method should remove the element at the beginning of the deque. This operation should run in constant time.

Returns

element being removed

removeLast

public removeLast() => (E)

Method should remove the element at the end of the deque. This operation should run in constant time.

Returns

element being removed

Property Detail

size

public readonly get size() => (int)

Property should get the number of elements in the deque.

Returns

size of the deque