br.usp.ime.klava.segmentit.structures
Class Queue<T>

java.lang.Object
  extended by br.usp.ime.klava.segmentit.structures.Queue<T>
Type Parameters:
T - the type of elements held in this queue

public class Queue<T>
extends java.lang.Object

Implements a queue, using a First In, First Out policy.

It uses a LinkedHashSet internally, so:

Author:
Bruno Klava

Constructor Summary
Queue()
          Creates an empty queue.
 
Method Summary
 void add(T element)
          Appends the specified element to the end of this queue if it is not already present.
 void clear()
          Removes all of the elements from this queue.
 boolean isEmpty()
          Returns true if this queue contains no elements.
 T peek()
          Returns the first element of the queue, without removing it.
 T remove()
          Returns the first element of the queue, removing it.
 boolean removeElement(T element)
          Removes the first occurrence of the specified element from this queue, if it is present.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Creates an empty queue.

Method Detail

add

public void add(T element)
Appends the specified element to the end of this queue if it is not already present.

Parameters:
element - element to be appended to this queue

remove

public T remove()
Returns the first element of the queue, removing it.

Returns:
the first element of the queue

peek

public T peek()
Returns the first element of the queue, without removing it.

Returns:
the first element of the queue

removeElement

public boolean removeElement(T element)
Removes the first occurrence of the specified element from this queue, if it is present.

Parameters:
element - element to be removed from this list, if present
Returns:
true if this queue contained the specified element

isEmpty

public boolean isEmpty()
Returns true if this queue contains no elements.

Returns:
true if this queue contains no elements

clear

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


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object