public class PriorityQueueRVM extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
PriorityQueueRVM.PriorityQueueNode
A local class that holds the nodes of the priority tree
|
Modifier and Type | Field and Description |
---|---|
private int |
numElements
the number of elements actually in the queue
|
private PriorityQueueRVM.PriorityQueueNode[] |
queue
the queue, we use elements 1..queue.length
|
Modifier | Constructor and Description |
---|---|
protected |
PriorityQueueRVM() |
Modifier and Type | Method and Description |
---|---|
Object |
deleteMin()
Remove and return the front (minimum) object
|
void |
insert(double _priority,
Object _data)
Insert the object passed with the priority value passed
|
protected boolean |
isEmpty()
Checks if the queue is empty
|
int |
numElements()
Determines number of elements in the queue
|
private void |
reheapify(int startingElement)
Starting at the position passed, swap with parent until heap condition
is satisfied, i.e., bubble up
|
double |
rootValue()
Return the priority of front object without removing it
|
String |
toString()
Prints the contents of the queue
|
private PriorityQueueRVM.PriorityQueueNode[] queue
private int numElements
protected PriorityQueueRVM()
public final int numElements()
protected final boolean isEmpty()
private void reheapify(int startingElement)
startingElement
- the position to start atpublic void insert(double _priority, Object _data)
_priority
- the priority of the inserted object_data
- the object to insertpublic Object deleteMin()
public final double rootValue()