Class Queue2

java.lang.Object
  extended by Queue2

public class Queue2
extends java.lang.Object

Implements a simple queue using an array

Author:
Mark Guzdial, Barb Ericson

Constructor Summary
Queue2()
          No argument constructor
 
Method Summary
 java.lang.Object peek()
          Peek at, but don't remove, the head of the queue
 java.lang.Object pop()
          Pop an object from the Queue
 void push(java.lang.Object element)
          Push an object onto the Queue
 int size()
          Return the size of a queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue2

public Queue2()
No argument constructor

Method Detail

push

public void push(java.lang.Object element)
Push an object onto the Queue

Parameters:
element - the element to add to the queue

peek

public java.lang.Object peek()
Peek at, but don't remove, the head of the queue

Returns:
the head of the queue (top)

pop

public java.lang.Object pop()
Pop an object from the Queue

Returns:
the head (top) of the queue and remove it from the queue

size

public int size()
Return the size of a queue

Returns:
the number of elements in the queue