|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.pattis.ics22.SimplePriorityQueue
public class SimplePriorityQueue
Objects constructed from the SimplePriorityQueue class act as collections of any references to objects. We can enqueue reference to objects into this collection and dequeue references to objects from the collection (according to the highest-priority-out ordering). Note that NO METHODS are called on these objects inside this class: we just move references around.
Constructor Summary | |
---|---|
SimplePriorityQueue(java.util.Comparator prioritizer)
Constructs a SimplePriorityQueue object, specifying the
initial size for it as 1. |
|
SimplePriorityQueue(java.util.Comparator prioritizer,
int initialSize)
Constructs a SimplePriorityQueue object, specifying the
initial size for it (number of references it can store). |
Method Summary | |
---|---|
java.lang.Object |
dequeue()
Returns the highest priority reference in this SimplePriorityQueue , removing it in the process. |
void |
enqueue(java.lang.Object o)
Enqueue a reference into this SimplePriorityQueue . |
int |
getSize()
Returns the number of reference this SimplePriorityQueue
stores (0 if empty). |
boolean |
isEmpty()
Returns whether or not this SimplePriorityQueue is empty
(stores no references). |
void |
makeEmpty()
Make this SimplePriorityQueue empty. |
java.lang.Object |
peek()
Returns the highest priority reference in this SimplePriorityQueue , without removing it in the
process. |
java.lang.String |
toString()
Returns a String |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SimplePriorityQueue(java.util.Comparator prioritizer, int initialSize) throws java.lang.IllegalArgumentException
SimplePriorityQueue
object, specifying the
initial size for it (number of references it can store).
Initially, the SimplePriorityQueue
is empty.
prioritizer
- specifies a Comparator
to use
when establishing the relative priorities of the valuesinitialSize
- specifies the number of references that the
SimplePriorityQueue
can initially store
"
java.lang.IllegalArgumentException
- if initialSize is < 1
public SimplePriorityQueue(java.util.Comparator prioritizer)
SimplePriorityQueue
object, specifying the
initial size for it as 1.
prioritizer
- specifies a Comparator
to use
when establishing the relative priorities of the valuesMethod Detail |
---|
public void makeEmpty()
SimplePriorityQueue
empty.
public void enqueue(java.lang.Object o)
SimplePriorityQueue
.
o
- specifies the reference to enqueuepublic java.lang.Object dequeue() throws java.lang.IllegalStateException
SimplePriorityQueue
, removing it in the process.
SimplePriorityQueue
, removing it in the process
java.lang.IllegalStateException
- if this SimplePriorityQueue
is
emptypublic java.lang.Object peek() throws java.lang.IllegalStateException
SimplePriorityQueue
, without removing it in the
process.
SimplePriorityQueue
, without removing it in the
process
java.lang.IllegalStateException
- if this SimplePriorityQueue
is
emptypublic boolean isEmpty()
SimplePriorityQueue
is empty
(stores no references).
SimplePriorityQueue
is empty
(stores no references)public int getSize()
SimplePriorityQueue
stores (0 if empty).
SimplePriorityQueue
stores (0 if empty)public java.lang.String toString()
String representation of the state of this
SimplePriorityQueue
.
The String
contains the value of rear
,
the length of the SimplePriorityQueue
array, and all the references
stored in the pq
array.
- Overrides:
toString
in class java.lang.Object
- Returns:
- a
String representation of the state of this
SimplePriorityQueue
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |