|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An interface that defines the basic methods for priority queues.
The elements of the priority queue are KeyValueHolders
.
The key defines the priority and can be any object (e.g. a Number
),
which will be compared to the keys of the other KeyValueHolders by a Comparitor
selected by setComparitor(gishur.core.Comparitor)
.
The elements are queued in increasing order, thus a lower key indicates a
higher priority.
The value contains the actual object, inserted into the priority queue.
Method Summary | |
Comparitor |
comparitor()
Returns the Comparitor used to compare the elements of this PriorityQueue |
void |
decreaseKey(java.lang.Object k,
KeyValueHolder p)
Decreases the key of p to k, if k is Comparitor.SMALLER than the current key of p.
|
void |
delete(KeyValueHolder p)
Deletes the element p from the PriorityQueue |
boolean |
empty()
Tests, if the PriorityQueue is empty. |
KeyValueHolder |
extractMin()
Deletes the the entry with the minimum key and returns it |
KeyValueHolder |
insert(KeyValueHolder p)
Inserts an element with a priority equal to p.{ |
void |
meld(PriorityQueue Q)
Melds this PriorityQueue with the PriorityQueue Q |
KeyValueHolder |
min()
Returns the entry with the minimum key |
void |
setComparitor(Comparitor c)
Sets the Comparitor , used to compare the priorities of the queue elements |
Method Detail |
public void setComparitor(Comparitor c)
Comparitor
, used to compare the priorities of the queue elementsComparitor
- for comparing the priorities of the queue elementspublic Comparitor comparitor()
Comparitor
used to compare the elements of this PriorityQueueComparitor
used to compare the elements of this PriorityQueuepublic boolean empty()
true
, if the PriorityQueue is empty, false
otherwise.public KeyValueHolder insert(KeyValueHolder p)
key()
and an object
equal to p.value()
into the PriorityQueuep
- object to be insertedKeyValueHolder
public void meld(PriorityQueue Q)
this
PriorityQueue with the PriorityQueue QQ
- PriorityQueue, which should be melded with this
public KeyValueHolder extractMin()
public void decreaseKey(java.lang.Object k, KeyValueHolder p)
Comparitor.SMALLER
than the current key of p.
This operation increases the priority of p.k
- new key of pp
- element the key of which will be decreasedpublic KeyValueHolder min()
public void delete(KeyValueHolder p)
p
- element to be deleted
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |