public final class PuPriorityQueue extends PsObject
double
keys (resp. weights) based on following special
property: The ints given to the heap must be the numbers
from 0 to capacity-1 and each int can be in the heap
just once. As a result methods like isElement() run in O(1) time.
We call the integers in the heap elements.
Heap is used i.e. to compute a minimum spanning tree on
the vertices resp. faces of a geometry with weight assigned to each edge
(cp. Prim's algorithm for minimal spanning trees).HAS_BOUNDARY_PANEL, HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_LABEL_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, HAS_VECTOR_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_FOCUSSED, IS_PICKED, IS_SELECTED, IS_USED, NUM_TAGS
Constructor and Description |
---|
PuPriorityQueue(double[] key)
Create a priority queue that has the elements 0...key.length
and the given keys.
|
PuPriorityQueue(int capacity)
Create an empty priority queue with a given capacity.
|
PuPriorityQueue(int capacity,
double key)
Create a priority queue containing the elements 0,1,2,...capacity-1.
|
Modifier and Type | Method and Description |
---|---|
boolean |
changeKey(int element,
double key)
Changes the key assigned to an element and reorder the heap.
|
java.lang.Object |
clone()
Create a copy of the heap.
|
boolean |
decreaseKey(int element,
double key)
Decrease the key assigned to an element and reorder the heap.
|
void |
emptyHeap()
Remove all elements from heap.
|
boolean |
enqueue(int element,
double key)
Add element to heap.
|
boolean |
enqueueOrDecrease(int element,
double key)
Add element to heap.
|
double |
extractElement(int element)
Remove a specific element from the heap and return its key.
|
int |
extractMin()
Extract the element with the smallest key of the heap.
|
int |
getCapacity()
Maximal heap size for this heap.
|
int |
getElement(int position)
Method returns the index of the element at the specified position.
|
int[] |
getElements()
Get the array, where the heap stores the elements.
|
int |
getHeapSize()
Get the number of Elements in the heap.
|
double |
getKey(int element)
Method returns the key of the specified element.
|
double |
getKeyOfMin()
Get key of minimal element.
|
double[] |
getKeys()
Get the array containing the key of each element.
|
int |
getPosition(int element)
Method returns the position of the specified element in the heap.
|
int[] |
getPositions()
Get the array, where the heap stores the positions of the elements.
|
boolean |
increaseKey(int element,
double key)
Increases the key assigned to an element and reorder the heap.
|
boolean |
isElement(int element)
Check if element i is in the heap.
|
boolean |
isEmpty()
Returns true, if there is no element in the heap.
|
java.lang.String |
toString()
Create a multi-line string representation
with detailed information about instance variables.
|
addInspector, addUpdateListener, assureInspector, clearTag, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, getSymbol, hasInspector, hasTag, hasUpdateListener, init, instanceOf, instanceOf, newInspector, newInspector, removeInspector, removeInspector, removeUpdateListener, setName, setParent, setSymbol, setTag, update, updatePanels
public PuPriorityQueue(int capacity)
public PuPriorityQueue(double[] key)
public PuPriorityQueue(int capacity, double key)
public int getCapacity()
public int[] getElements()
public int getElement(int position)
public int[] getPositions()
public int getPosition(int element)
public double[] getKeys()
public double getKey(int element)
public boolean decreaseKey(int element, double key)
key
public boolean increaseKey(int element, double key)
key
public boolean changeKey(int element, double key)
public double getKeyOfMin()
public int extractMin()
getKey(int)
.public double extractElement(int element)
element
- index of the element to extract.public int getHeapSize()
public boolean isEmpty()
public java.lang.Object clone()
clone
in class PsObject
PsObject.copy(PsObject)
public boolean isElement(int element)
public boolean enqueue(int element, double key)
public boolean enqueueOrDecrease(int element, double key)
public void emptyHeap()
"