E - element typepublic class StrictPriorityQueue<E> extends AbstractQueue<E>
Comparator.compare(Object, Object) does not return 0 for two distinct elements).
If an element is inserted which, according to the Comparator, is already present, the specified StrictPriorityQueue.MergeOperation's StrictPriorityQueue.MergeOperation.merge(Object, Object) method is invoked to determine the replacement
element.
The name derives from the fact that subsequent calls to extractMin() will yield a strictly growing
sequence of elements.
This class does not disallow null values, but the supplied Comparator has to support them.
| Modifier and Type | Class and Description |
|---|---|
static interface |
StrictPriorityQueue.MergeOperation<E>
The merge operation two perform on two equally-ranked elements.
|
| Constructor and Description |
|---|
StrictPriorityQueue(Comparator<? super E> comparator,
StrictPriorityQueue.MergeOperation<E> mergeOp)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
E |
extractMin()
Retrieves and removes the element at the head of the queue (i.e., the minimum element in the queue).
|
boolean |
insert(E object)
Inserts an element into the queue.
|
boolean |
isEmpty() |
Iterator<E> |
iterator() |
boolean |
offer(E e) |
E |
peek() |
E |
peekMin()
Retrieves, but does not remove the element at the head of the queue (i.e., the minimum element in the queue).
|
E |
poll() |
int |
size() |
String |
toString() |
contains, containsAll, remove, removeAll, retainAll, toArray, toArrayclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontains, containsAll, equals, hashCode, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArraypublic StrictPriorityQueue(Comparator<? super E> comparator, StrictPriorityQueue.MergeOperation<E> mergeOp)
comparator - the comparator used to compare elementsmergeOp - the merge operation to perform for equally-ranked elementspublic E peekMin()
Note: Unlike peek(), this method throws a NoSuchElementException in case of an empty priority
queue.
public boolean offer(E e)
public boolean insert(E object)
object - the element to inserttrue if a new element has been inserted (i.e., the size has grown), false otherwise
(i.e., an existing element has been replaced)public E poll()
public E extractMin()
Note: Unlike poll(), this method throws a NoSuchElementException in case of an empty priority
queue.
public E peek()
public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in class AbstractCollection<E>public int size()
size in interface Collection<E>size in class AbstractCollection<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in class AbstractCollection<E>public String toString()
toString in class AbstractCollection<E>Copyright © 2019. All rights reserved.