|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchoco.cp.solver.constraints.global.geost.dataStructures.Heap
public final class Heap
A priority queue according to Cormen, Leiserson and Rivest.
The heap can be constructed in O(N) time by copying an array, or O(N log N) time by staring with an empty heap and performing N insertions.
Constructor Summary | |
---|---|
Heap()
Constructs a heap with keys sorted in descending order. |
|
Heap(boolean descending)
Constructs a heap with the given sorting order. |
|
Heap(Heapable[] anArray)
Constructs the heap by copying an unordered array. |
|
Heap(Heapable[] anArray,
boolean descending)
Constructs the heap by copying an unordered array. |
Method Summary | |
---|---|
void |
clear()
Removes all keys from the heap. |
void |
insert(Heapable key)
Inserts a key into the heap. |
boolean |
isEmpty()
Returns true if there are no keys in the heap, false otherwise. |
Heapable |
remove()
Removes the top key from the heap. |
int |
size()
Returns the number of keys in the heap. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Heap(Heapable[] anArray, boolean descending)
public Heap(Heapable[] anArray)
public Heap(boolean descending)
descending
- true if keys should be sorted in descending order.public Heap()
Method Detail |
---|
public boolean isEmpty()
public int size()
public void clear()
public Heapable remove() throws NoSuchElementException
NoSuchElementException
public void insert(Heapable key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |