Class PriorityQ<T>
java.lang.Object
com.googlecode.javaewah.datastructure.PriorityQ<T>
- Type Parameters:
T
- object type
Special-purpose priority queue. Does limited error checking and supports
toss, buildHeap, poll, peek, percolateDown. It is faster than the equivalent
class from java.util.
- Since:
- 0.8.0
- Author:
- Owen Kaser
-
Constructor Summary
ConstructorsConstructorDescriptionPriorityQ(int maxSize, Comparator<T> c)
Construct a priority queue with a given capacity -
Method Summary
Modifier and TypeMethodDescriptionvoid
build the heap...boolean
isEmpty()
Check whether the heap is empty.peek()
Look at the top of the heapvoid
Signals that the element on top of the heap has been updatedpoll()
Remove the element on top of the heapint
size()
void
Add an element at the end of the queue
-
Constructor Details
-
PriorityQ
Construct a priority queue with a given capacity- Parameters:
maxSize
- capacityc
- comparator
-
-
Method Details
-
size
public int size()- Returns:
- the size of the queue
-
toss
Add an element at the end of the queue- Parameters:
t
- element to be added
-
peek
Look at the top of the heap- Returns:
- the element on top
-
buildHeap
public void buildHeap()build the heap... -
percolateDown
public void percolateDown()Signals that the element on top of the heap has been updated -
poll
Remove the element on top of the heap- Returns:
- the element being removed
-
isEmpty
public boolean isEmpty()Check whether the heap is empty.- Returns:
- true if empty
-