Class DLDeque

java.lang.Object
  |
  +--DLDeque
All Implemented Interfaces:
Deque

class DLDeque
extends java.lang.Object
implements Deque

DLDeque is an implementation of Deque, a repository for Objects. that maintains insertion order. Objects can be inserted and removed from either in. Objects are inserted using enqueue and removed using dequeue. A doubly-linked list is used to maintain the Deque.


Nested Class Summary
(package private)  class DLDeque.Dcell
          A Dcell stores one Object in the Queue and points to the immediately following and preceding Dcells, if any.
 
Field Summary
(package private)  DLDeque.Dcell back
          the Dcell at the back
(package private)  DLDeque.Dcell front
          the Dcell at the front
 
Constructor Summary
DLDeque()
          Construct an empty DLDeque.
 
Method Summary
 java.lang.Object dequeueBack()
          Remove an Object from the back of the Deque.
 java.lang.Object dequeueFront()
          Remove an Object from the front of the Deque.
 void enqueueBack(java.lang.Object item)
          Insert an Object at the back of the Deque.
 void enqueueFront(java.lang.Object item)
          Insert an Object at the front of the Deque.
 boolean isEmpty()
          Indicate whether or not the Deque is empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

front

DLDeque.Dcell front
the Dcell at the front


back

DLDeque.Dcell back
the Dcell at the back

Constructor Detail

DLDeque

public DLDeque()
Construct an empty DLDeque.

Method Detail

enqueueBack

public void enqueueBack(java.lang.Object item)
Insert an Object at the back of the Deque.

Specified by:
enqueueBack in interface Deque
Parameters:
item - the Object to be inserted

dequeueFront

public java.lang.Object dequeueFront()
                              throws EmptyQueueException
Remove an Object from the front of the Deque.

Specified by:
dequeueFront in interface Deque
Returns:
the Object removed
Throws:
EmptyQueueException - if the Queue is empty

enqueueFront

public void enqueueFront(java.lang.Object item)
Insert an Object at the front of the Deque.

Specified by:
enqueueFront in interface Deque
Parameters:
item - the Object to be inserted

dequeueBack

public java.lang.Object dequeueBack()
                             throws EmptyQueueException
Remove an Object from the back of the Deque.

Specified by:
dequeueBack in interface Deque
Returns:
the Object removed
Throws:
EmptyQueueException - if the Queue is empty

isEmpty

public boolean isEmpty()
Indicate whether or not the Deque is empty

Specified by:
isEmpty in interface Deque
Returns:
boolean indicating whether or not the Deque is empty