fi.joensuu.cs.tra
Class LinkedQueue<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<E>
                  extended by fi.joensuu.cs.tra.LinkedQueue<E>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, Queue<E>

public class LinkedQueue<E>
extends LinkedList<E>

LinkedQueue extends java.util.LinkedList to highlight java.util.Queue-defined behaviour.

See Also:
LinkedList, Queue, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedQueue()
          Creates an empty queue.
LinkedQueue(Collection<? extends E> c)
          Constructs a queue containing the elements of the specified collection, in the order they are returned by the collection's iterator.
 
Method Summary
 void clear()
          Removes all of the elements from this queue
 E element()
          Retrieves, but does not remove, the head of this queue.
 boolean offer(E o)
          Inserts the specified element into the rear of this queue.
 E peek()
          Retrieves, but does not remove, the head of this queue, returning null if this queue is empty.
 E poll()
          Retrieves and removes the head of this queue, or null if this queue is empty.
 E remove()
          Retrieves and removes the head of this queue.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clone, contains, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, remove, remove, removeFirst, removeLast, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

LinkedQueue

public LinkedQueue()
Creates an empty queue.


LinkedQueue

public LinkedQueue(Collection<? extends E> c)
Constructs a queue containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
c - the collection whose elements are to be placed into this queue.
Throws:
NullPointerException - if the specified collection was null.
Method Detail

offer

public boolean offer(E o)
Inserts the specified element into the rear of this queue.

Specified by:
offer in interface Queue<E>
Overrides:
offer in class LinkedList<E>
Parameters:
o - the element to insert.
Returns:
true (as per the general contract of Queue.offer).

poll

public E poll()
Retrieves and removes the head of this queue, or null if this queue is empty.

Specified by:
poll in interface Queue<E>
Overrides:
poll in class LinkedList<E>
Returns:
the head of the queue or null if this queue is empty.

remove

public E remove()
Retrieves and removes the head of this queue. This method differs from the poll method in that it throws an exception if this queue is empty.

Specified by:
remove in interface Queue<E>
Overrides:
remove in class LinkedList<E>
Returns:
the head of this queue.
Throws:
NoSuchElementException - if this queue is empty.

peek

public E peek()
Retrieves, but does not remove, the head of this queue, returning null if this queue is empty.

Specified by:
peek in interface Queue<E>
Overrides:
peek in class LinkedList<E>
Returns:
the head of this queue, or null if this queue is empty.

element

public E element()
Retrieves, but does not remove, the head of this queue. This method differs from the peek method only in that it throws an exception if this queue is empty.

Specified by:
element in interface Queue<E>
Overrides:
element in class LinkedList<E>
Returns:
the head of this queue.
Throws:
NoSuchElementException - if this queue is empty.

clear

public void clear()
Removes all of the elements from this queue

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class LinkedList<E>