All Packages Class Hierarchy This Package Previous Next Index
Interface jdsl.simple.api.Deque
- public interface Deque
Interface for a deque, or double-ended queue. A deque is a
collection of linearly arranged elements that are accessed,
inserted, and removed at the beginning or at the end.
- Version:
- $Revision: 1.2 $, $Date: 1998/07/02 21:24:38 $
- Author:
- Michael T. Goodrich, Mark Handy, Roberto Tamassia
- See Also:
- DequeEmptyException, Queue, Stack
-
first()
-
Gets the first element (without modifying the deque).
-
insertFirst(Object)
-
Insert an element at the beginning.
-
insertLast(Object)
-
Insert an element at the end.
-
isEmpty()
-
Tests if this deque is empty
-
last()
-
Gets the last element (without modifying the deque).
-
removeFirst()
-
Remove the element at the beginning.
-
removeLast()
-
Remove the element at the end.
-
size()
-
Gets the number of elements.
first
public abstract Object first() throws DequeEmptyException
- Gets the first element (without modifying the deque).
- Returns:
- first element in the deque.
- Throws: DequeEmptyException
- if the deque is empty
last
public abstract Object last() throws DequeEmptyException
- Gets the last element (without modifying the deque).
- Returns:
- last element in the deque.
- Throws: DequeEmptyException
- if the deque is empty
isEmpty
public abstract boolean isEmpty()
- Tests if this deque is empty
- Returns:
-
true
if the deque is empty, false
otherwise.
size
public abstract int size()
- Gets the number of elements.
- Returns:
- number of elements in the deque.
insertFirst
public abstract void insertFirst(Object element)
- Insert an element at the beginning.
- Parameters:
- element - new element to be inserted.
insertLast
public abstract void insertLast(Object element)
- Insert an element at the end.
- Parameters:
- element - new element to be inserted.
removeFirst
public abstract Object removeFirst() throws DequeEmptyException
- Remove the element at the beginning.
- Returns:
- element removed.
- Throws: DequeEmptyException
- if the deque is empty
removeLast
public abstract Object removeLast() throws DequeEmptyException
- Remove the element at the end.
- Returns:
- element removed.
- Throws: DequeEmptyException
- if the deque is empty
All Packages Class Hierarchy This Package Previous Next Index