All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jdsl.simple.ref.MyDeque

java.lang.Object
   |
   +----jdsl.simple.ref.MyDeque

public class MyDeque
extends Object
implements Deque
This is the implementation of the Deque interface Dbmy means of a doubly- linked list. Note that this class uses class DLNode, which is the node that stores the previos and next nodes in the list, and a reference to its element.


Constructor Index

 o MyDeque()

Method Index

 o first()
Inspect the first element without modifying the deque.
 o insertFirst(Object)
Add an element at the front of the sequence.
 o insertLast(Object)
Add an element at the back of the sequence.
 o isEmpty()
This function returns true if and only if the deque is empty
 o last()
Inspect the last element without modifying the deque.
 o removeFirst()
Delete the element at the front of the sequence.
 o removeLast()
Delete the element at the back of the sequence.
 o size()
Return the size of the deque, that is the number of elements it has.

Constructors

 o MyDeque
 public MyDeque()

Methods

 o size
 public int size()
Return the size of the deque, that is the number of elements it has.

Returns:
Number of elements in the deque
 o isEmpty
 public boolean isEmpty()
This function returns true if and only if the deque is empty

Returns:
true if the deque is empty, false otherwise
 o first
 public Object first() throws DequeEmptyException
Inspect the first element without modifying the deque.

Returns:
The first element in the sequence
 o last
 public Object last() throws DequeEmptyException
Inspect the last element without modifying the deque.

Returns:
The last element in the sequence
 o insertFirst
 public void insertFirst(Object o)
Add an element at the front of the sequence.

Parameters:
element - New element for the front of the deque
 o insertLast
 public void insertLast(Object o)
Add an element at the back of the sequence.

Parameters:
element - New element for the back of the deque
 o removeFirst
 public Object removeFirst() throws DequeEmptyException
Delete the element at the front of the sequence.

Returns:
The element formerly known as "first()"
 o removeLast
 public Object removeLast() throws DequeEmptyException
Delete the element at the back of the sequence.

Returns:
The element formerly known as "last()"

All Packages  Class Hierarchy  This Package  Previous  Next  Index