Interface QueueInterface<E>

Type Parameters:
E - The type of Object that the queue will accept.
All Superinterfaces:
java.lang.Iterable<E>

public interface QueueInterface<E>
extends java.lang.Iterable<E>

Generic interface for a FIFO queue.

Author:
Sameh Fakhouri

Method Summary
 boolean add(E e)
          Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
 E element()
          Retrieves, but does not remove, the head of this queue.
 boolean isEmpty()
          This method is called to determine if the queue is empty.
 E remove()
          Retrieves and removes the element at the head of this queue.
 E remove(int index)
          Retrieves and removes the element at the specified index.
 void removeAll()
          Removes all elements from the queue.
 int size()
          This method is called to obtain the count of elements in the list.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

isEmpty

boolean isEmpty()
This method is called to determine if the queue is empty.

Returns:
Returns true if the list is empty, otherwise it returns false.

size

int size()
This method is called to obtain the count of elements in the list.

Returns:
Returns the numbers of Objects that are currently in the list.

add

boolean add(E e)
            throws java.lang.IllegalStateException,
                   java.lang.NullPointerException
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.

Parameters:
e - The element to add.
Returns:
true if the element was successfully added.
Throws:
java.lang.IllegalStateException - If the element cannot be added at this time due to capacity restrictions.
java.lang.NullPointerException - If the specified element is null and this queue does not permit null elements.

element

E element()
          throws java.util.NoSuchElementException
Retrieves, but does not remove, the head of this queue.

Returns:
The head of the queue.
Throws:
java.util.NoSuchElementException - If the queue is empty.

remove

E remove()
         throws java.util.NoSuchElementException
Retrieves and removes the element at the head of this queue.

Returns:
The elememt in the head of the queue.
Throws:
java.util.NoSuchElementException - If the queue is empty.

remove

E remove(int index)
         throws java.util.NoSuchElementException
Retrieves and removes the element at the specified index.

Parameters:
index - The index of the element to be removed.
Returns:
The element at the specified index.
Throws:
java.util.NoSuchElementException - If the queue is empty.

removeAll

void removeAll()
Removes all elements from the queue.