|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Heapable>
choco.cp.solver.constraints.global.geost.dataStructures.HeapAscending
public final class HeapAscending
An implementation of a priority queue according to Cormen, Leiserson and Rivest. Sorts in ascending order.
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
HeapAscending()
Constructs a heap with no elements. |
|
HeapAscending(Heapable[] anArray)
Constructs the heap in O(N) time, using a technique similar to bottom-up construction. |
Method Summary | |
---|---|
protected void |
exchange(int i,
int j)
Exchanges the elements stored at the two locations |
Heapable |
extractMin()
Removes the minimum (top) element from the Heap, decreases the size of the heap by one, and returns the minimum element. |
Heapable |
getMin()
Returns the minimum (top) element from the Heap. |
protected void |
heapify(int i)
Also known as downheap, restores the heap condition starting at node i and working its way down. |
void |
insert(Heapable key)
Inserts key into the heap, and then upheaps that key to a position where the heap property is satisfied. |
protected int |
left(int i)
Returns the Vector index of the left child |
protected int |
parent(int i)
Returns the Vector index of the parent |
Heapable |
remove()
Removes an element from the heap. |
void |
removeAllElements()
|
protected int |
right(int i)
Returns the Vector index of the right child |
Methods inherited from class java.util.ArrayList |
---|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface choco.cp.solver.constraints.global.geost.dataStructures.HeapImpl |
---|
isEmpty, size |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList |
Constructor Detail |
---|
public HeapAscending(Heapable[] anArray)
public HeapAscending()
Method Detail |
---|
protected int left(int i)
protected int right(int i)
protected int parent(int i)
protected void exchange(int i, int j)
protected void heapify(int i)
public Heapable extractMin() throws NoSuchElementException
NoSuchElementException
public Heapable getMin() throws NoSuchElementException
NoSuchElementException
public Heapable remove() throws NoSuchElementException
remove
in interface HeapImpl
NoSuchElementException
public void insert(Heapable key)
insert
in interface HeapImpl
public void removeAllElements()
removeAllElements
in interface HeapImpl
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |