asd_library.queue
Class Queue

java.lang.Object
  |
  +--asd_library.queue.Queue
All Implemented Interfaces:
java.lang.Cloneable, Queue_adt

public class Queue
extends java.lang.Object
implements Queue_adt, java.lang.Cloneable

Implementation of the abstract data type Queue


Constructor Summary
Queue()
           
 
Method Summary
 java.lang.Object clone()
          Returns a shallow copy of this Queue.
 java.lang.Object dequeue()
          Retrieves the item from the queue head and removes it.
 void enqueue(java.lang.Object el)
          Stores an item at the queue end.
 boolean equals(java.lang.Object q)
          Compares the specified object with this queue for equality.
 java.lang.Object firstEl()
          Retrieves the item from the queue head but doesn't remove it.
 boolean isEmpty()
          Verifies if the queue is empty.
 java.util.ListIterator listIterator()
          Returns a list-iterator of the elements in this queue (in proper sequence)
 java.lang.String toString()
          Returns a string representation of the queue.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Method Detail

enqueue

public void enqueue(java.lang.Object el)
Stores an item at the queue end.

Specified by:
enqueue in interface Queue_adt
Parameters:
el - object to store.

dequeue

public java.lang.Object dequeue()
Retrieves the item from the queue head and removes it.

Specified by:
dequeue in interface Queue_adt
Returns:
the object deleted from the queue.

firstEl

public java.lang.Object firstEl()
Retrieves the item from the queue head but doesn't remove it.

Specified by:
firstEl in interface Queue_adt
Returns:
the object at the head of the queue.

isEmpty

public boolean isEmpty()
Verifies if the queue is empty.

Specified by:
isEmpty in interface Queue_adt
Returns:
true if the queue is empty, false otherwise.

toString

public java.lang.String toString()
Returns a string representation of the queue. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String.valueOf(Object).

Overrides:
toString in class java.lang.Object
Returns:
a String that represents the queue.

clone

public java.lang.Object clone()
Returns a shallow copy of this Queue. (The elements themselves are not cloned.)

Overrides:
clone in class java.lang.Object
Returns:
a shallow copy of this Queue instance.

equals

public boolean equals(java.lang.Object q)
Compares the specified object with this queue for equality. Returns true if and only if the specified object is also a queue, both queues have the same size, and all corresponding pairs of elements in the two queues are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two queues are defined to be equal if they contain the same elements in the same order.

Overrides:
equals in class java.lang.Object
Parameters:
q - the object to be compared for equality with this queue
Returns:
true if the specified object is equal to this queue.

listIterator

public java.util.ListIterator listIterator()
Returns a list-iterator of the elements in this queue (in proper sequence)

Returns:
a ListIterator of the elements in this queue.