E
- element class.K
- key class.public interface SmartGeneralPriorityQueue<E,K extends Comparable<K>> extends SmartPriorityQueue<E>
Comparator
. Instead, keys can be assigned to the elements
explicitly.
Since this interface extends the SmartCollection
(and thus also
the Collection
) interface, it has to provide the
SmartCollection.referencedAdd(Object)
and
Collection.add(Object)
methods with no additional key parameters.
This is handled by using a default key, which is implicitly used
for all elements inserted using the above methods. Initially, the default
key is null
, whereas the null
key is by convention
larger than any non-null
key. The default key for consequent
insertions can be changed by calling setDefaultKey(Comparable)
.Modifier and Type | Method and Description |
---|---|
ElementReference |
add(E elem,
K key)
Inserts an element with the specified key.
|
void |
changeKey(ElementReference ref,
K newKey)
Changes the key of an element in the priority key.
|
void |
setDefaultKey(K defaultKey)
Sets the default key, which is used for elements that are inserted
with no explicit key specified.
|
extractMin, peekMin
addAll, addAll, choose, chooseRef, deepClear, find, get, quickClear, referencedAdd, referenceIterator, references, remove, remove, replace
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
ElementReference add(E elem, K key)
elem
- the element to insert.key
- the key for this element.void setDefaultKey(K defaultKey)
defaultKey
- the new defualt key.void changeKey(ElementReference ref, K newKey)
ref
- reference to the element whose key is to be changed.newKey
- the new key of this element.Copyright © 2015. All rights reserved.