Class ArrayQueue<E>

java.lang.Object
  extended by AbstractQueue<E>
      extended by ArrayQueue<E>
All Implemented Interfaces:
Queue<E>

public class ArrayQueue<E>
extends AbstractQueue<E>

Implements a simple queue using an array

Author:
Mark Guzdial, Barb Ericson

Constructor Summary
ArrayQueue()
          No argument constructor
 
Method Summary
static void main(String[] args)
          Main method for testing
 E peek()
          Peek at, but don't remove, the head of the queue
 E pop()
          Pop an object from the Queue
 void push(E element)
          Push an element onto the tail of the Queue
 int size()
          Return the size of a queue
 
Methods inherited from class AbstractQueue
isEmpty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayQueue

public ArrayQueue()
No argument constructor

Method Detail

push

public void push(E element)
Push an element onto the tail of the Queue

Specified by:
push in interface Queue<E>
Specified by:
push in class AbstractQueue<E>
Parameters:
element - the element to add to the queue

peek

public E peek()
Peek at, but don't remove, the head of the queue

Specified by:
peek in interface Queue<E>
Specified by:
peek in class AbstractQueue<E>
Returns:
the head of the queue (top)

pop

public E pop()
Pop an object from the Queue

Specified by:
pop in interface Queue<E>
Specified by:
pop in class AbstractQueue<E>
Returns:
the head (top) of the queue and remove it from the queue

size

public int size()
Return the size of a queue

Specified by:
size in interface Queue<E>
Specified by:
size in class AbstractQueue<E>
Returns:
the number of elements in the queue

main

public static void main(String[] args)
Main method for testing