Package org.openjdk.jmh.util
Class BoundedPriorityQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractQueue<E>
-
- org.openjdk.jmh.util.BoundedPriorityQueue<E>
-
- Type Parameters:
E- type of the element
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Queue<E>
public class BoundedPriorityQueue<E> extends AbstractQueue<E> implements Serializable
Bounded variant ofPriorityQueue. Note: elements are returned in reverse order. For instance, if "top N smallest elements" are required, usenew BoundedPriorityQueue(N), and the elements would be returned in largest to smallest order.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BoundedPriorityQueue(int maxSize)Creates a bounded priority queue with the specified maximum size and default ordering.BoundedPriorityQueue(int maxSize, Comparator<? super E> comparator)Creates a bounded priority queue with the specified maximum size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)Iterator<E>iterator()booleanoffer(E e)Epeek()Epoll()intsize()-
Methods inherited from class java.util.AbstractQueue
addAll, clear, element, remove
-
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
contains, containsAll, equals, hashCode, isEmpty, parallelStream, remove, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Constructor Detail
-
BoundedPriorityQueue
public BoundedPriorityQueue(int maxSize)
Creates a bounded priority queue with the specified maximum size and default ordering. At mostmaxSizesmallest elements would be kept in the queue.- Parameters:
maxSize- maximum size of the queue
-
BoundedPriorityQueue
public BoundedPriorityQueue(int maxSize, Comparator<? super E> comparator)Creates a bounded priority queue with the specified maximum size. At mostmaxSizesmallest elements would be kept in the queue.- Parameters:
maxSize- maximum size of the queuecomparator- comparator that orders the elements
-
-
Method Detail
-
add
public boolean add(E e)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceQueue<E>- Overrides:
addin classAbstractQueue<E>
-
iterator
public Iterator<E> iterator()
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin classAbstractCollection<E>
-
size
public int size()
- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>
-
-