Class jgl.PriorityQueue
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jgl.PriorityQueue

java.lang.Object
   |
   +----jgl.PriorityQueue

public class PriorityQueue
extends Object
implements Container
A PriorityQueue is an adapter that allows you to access items in a sorted order. It allows you to specify a comparator that is used to sort the items.

A PriorityQueue uses the generic heap algorithms to access its underlying Array as a heap. This means that although objects will always pop in the order determined by the comparator, the objects are not necessarily stored in that order within the heap structure.

See Also:
Array, Heap, PriorityQueueExamples

Constructor Index

 o PriorityQueue()
Construct myself to be an empty PriorityQueue.
 o PriorityQueue(BinaryPredicate)
Construct myself to be an empty PriorityQueue.
 o PriorityQueue(PriorityQueue)
Construct myself to be a shallow copy of a specified PriorityQueue.

Method Index

 o add(Object)
Push an object.
 o clear()
Remove all of my objects.
 o clone()
Return a shallow copy of myself.
 o copy(PriorityQueue)
Become a shallow copy of a specified PriorityQueue.
 o elements()
Return an Enumeration of my elements.
 o equals(Object)
Return true if object is a PriorityQueue whose underlying sequence is equal to mine.
 o equals(PriorityQueue)
Return true if a specified PriorityQueue's sequence is equal to mine.
 o finish()
Return an iterator positioned immediately afer my last item.
 o hashCode()
Return my hash code for support of hashing containers
 o isEmpty()
Return true if I contain no objects.
 o maxSize()
Return the maximum number of objects that I can contain.
 o pop()
Pop the last object that was pushed onto me.
 o push(Object)
Push an object.
 o size()
Return the number of objects that I contain.
 o start()
Return an iterator positioned at my first item.
 o swap(PriorityQueue)
Swap my contents with another PriorityQueue.
 o top()
Return my top object.
 o toString()
Return a string that describes me.

Constructors

 o PriorityQueue
  public PriorityQueue()
Construct myself to be an empty PriorityQueue. Order elements based on their hash code.
 o PriorityQueue
  public PriorityQueue(BinaryPredicate comparator)
Construct myself to be an empty PriorityQueue. Order elements using the specified comparator.
Parameters:
comparator - The comparator to be used for comparing elements.
 o PriorityQueue
  public PriorityQueue(PriorityQueue queue)
Construct myself to be a shallow copy of a specified PriorityQueue. A shallow copy is made of its underlying sequence.
Parameters:
queue - The instance of PriorityQueue to be copied.

Methods

 o toString
  public synchronized String toString()
Return a string that describes me.
Overrides:
toString in class Object
 o clone
  public synchronized Object clone()
Return a shallow copy of myself.
Overrides:
clone in class Object
 o copy
  public synchronized void copy(PriorityQueue queue)
Become a shallow copy of a specified PriorityQueue. By underlying data structure becomes a shallow copy of the specified PriorityQueue's data structure.
Parameters:
queue - The PriorityQueue to be copied.
 o equals
  public boolean equals(Object object)
Return true if object is a PriorityQueue whose underlying sequence is equal to mine.
Parameters:
object - Any object.
Overrides:
equals in class Object
 o equals
  public synchronized boolean equals(PriorityQueue queue)
Return true if a specified PriorityQueue's sequence is equal to mine.
Parameters:
queue - The PriorityQueue to compare myself against.
 o hashCode
  public int hashCode()
Return my hash code for support of hashing containers
Overrides:
hashCode in class Object
 o isEmpty
  public boolean isEmpty()
Return true if I contain no objects.
 o size
  public int size()
Return the number of objects that I contain.
 o maxSize
  public int maxSize()
Return the maximum number of objects that I can contain.
 o clear
  public synchronized void clear()
Remove all of my objects.
 o elements
  public synchronized Enumeration elements()
Return an Enumeration of my elements.
 o start
  public synchronized ForwardIterator start()
Return an iterator positioned at my first item.
 o finish
  public synchronized ForwardIterator finish()
Return an iterator positioned immediately afer my last item.
 o top
  public synchronized Object top()
Return my top object.
Throws: InvalidOperationException
If the PriorityQueue is empty.
 o add
  public Object add(Object object)
Push an object. Add always works so return null.
Parameters:
object - The object to push.
 o push
  public synchronized void push(Object object)
Push an object.
Parameters:
object - The object to push.
 o pop
  public synchronized Object pop()
Pop the last object that was pushed onto me.
Throws: InvalidOperationException
If the PriorityQueue is empty.
 o swap
  public synchronized void swap(PriorityQueue queue)
Swap my contents with another PriorityQueue.
Parameters:
queue - The PriorityQueue that I will swap my contents with.

All Packages  Class Hierarchy  This Package  Previous  Next  Index