net.datastructures
Interface Deque<E>

All Known Subinterfaces:
Sequence<E>
All Known Implementing Classes:
NodeDeque

public interface Deque<E>

Interface for a deque: a collection of objects that are inserted and removed at both ends; a subset of java.util.LinkedList methods.

Author:
Roberto Tamassia, Michael Goodrich

Method Summary
 void addFirst(E element)
          Inserts an element to be the first in the deque.
 void addLast(E element)
          Inserts an element to be the last in the deque.
 E getFirst()
          Returns the first element; an exception is thrown if deque is empty.
 E getLast()
          Returns the last element; an exception is thrown if deque is empty.
 boolean isEmpty()
          Returns whether the deque is empty.
 E removeFirst()
          Removes the first element; an exception is thrown if deque is empty.
 E removeLast()
          Removes the last element; an exception is thrown if deque is empty.
 int size()
          Returns the number of elements in the deque.
 

Method Detail

size

int size()
Returns the number of elements in the deque.


isEmpty

boolean isEmpty()
Returns whether the deque is empty.


getFirst

E getFirst()
           throws EmptyDequeException
Returns the first element; an exception is thrown if deque is empty.

Throws:
EmptyDequeException

getLast

E getLast()
          throws EmptyDequeException
Returns the last element; an exception is thrown if deque is empty.

Throws:
EmptyDequeException

addFirst

void addFirst(E element)
Inserts an element to be the first in the deque.


addLast

void addLast(E element)
Inserts an element to be the last in the deque.


removeFirst

E removeFirst()
              throws EmptyDequeException
Removes the first element; an exception is thrown if deque is empty.

Throws:
EmptyDequeException

removeLast

E removeLast()
             throws EmptyDequeException
Removes the last element; an exception is thrown if deque is empty.

Throws:
EmptyDequeException