Class ArrayPriorityQueue<Element extends java.lang.Comparable<Element>>

java.lang.Object
  extended by ArrayPriorityQueue<Element>
All Implemented Interfaces:
java.lang.Iterable<Element>, PriorityQueue<Element>

public class ArrayPriorityQueue<Element extends java.lang.Comparable<Element>>
extends java.lang.Object
implements PriorityQueue<Element>

ArrayPriorityQueue is an array implementation of Priority Queue.


Constructor Summary
ArrayPriorityQueue()
           
 
Method Summary
 void clear()
          Removes all elements from the priority queue.
 Element dequeue()
          Retrieves and removes the head of this queue.
 void enqueue(Element element)
          Adds the specified element to this priority queue.
 boolean isEmpty()
          Indicates whether or not the queue is empty.
 java.util.Iterator<Element> iterator()
          Return an iterator over the items in this queue.
 Element peek()
          Retrieves, but does not remove, the head of this queue.
 int size()
          Returns the number of elements currently in this queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayPriorityQueue

public ArrayPriorityQueue()
Method Detail

isEmpty

public boolean isEmpty()
Description copied from interface: PriorityQueue
Indicates whether or not the queue is empty.

Specified by:
isEmpty in interface PriorityQueue<Element extends java.lang.Comparable<Element>>
Returns:
true if the queue size is zero, false otherwise.

size

public int size()
Description copied from interface: PriorityQueue
Returns the number of elements currently in this queue.

Specified by:
size in interface PriorityQueue<Element extends java.lang.Comparable<Element>>
Returns:
int the size of the queue

clear

public void clear()
Description copied from interface: PriorityQueue
Removes all elements from the priority queue.

Specified by:
clear in interface PriorityQueue<Element extends java.lang.Comparable<Element>>

enqueue

public void enqueue(Element element)
Description copied from interface: PriorityQueue
Adds the specified element to this priority queue.

Specified by:
enqueue in interface PriorityQueue<Element extends java.lang.Comparable<Element>>
Parameters:
element - is an item to be enqueued

peek

public Element peek()
Description copied from interface: PriorityQueue
Retrieves, but does not remove, the head of this queue.

Specified by:
peek in interface PriorityQueue<Element extends java.lang.Comparable<Element>>
Returns:
the head item in the queue, or null if this queue is empty.

dequeue

public Element dequeue()
Description copied from interface: PriorityQueue
Retrieves and removes the head of this queue.

Specified by:
dequeue in interface PriorityQueue<Element extends java.lang.Comparable<Element>>
Returns:
the head item in the queue, or null if this queue is empty.

iterator

public java.util.Iterator<Element> iterator()
Return an iterator over the items in this queue. The items are iterated in priority order.

Specified by:
iterator in interface java.lang.Iterable<Element extends java.lang.Comparable<Element>>
Returns:
Iterator an iterator for the queue.