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