Java PriorityQueue tutorial with example program
By candid | Posted :
Dec 17, 2015
| Updated :
Dec 17, 2015
Class PriorityQueue
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Queue<E>
public class PriorityQueue<E>
extends AbstractQueue<E>
implements Serializable
{
//
}
Since:
1.5
See Also:
Serialized Form
Constructor Summary
Creates a PriorityQueue with the default initial capacity (11) that orders its elements according to their natural ordering.
Creates a PriorityQueue containing the elements in the specified collection.
Creates a PriorityQueue with the specified initial capacity that orders its elements according to their natural ordering.
Creates a PriorityQueue with the specified initial capacity that orders its elements according to the specified comparator.
Creates a PriorityQueue containing the elements in the specified priority queue.
Creates a PriorityQueue containing the elements in the specified sorted set.
Method Summary
Inserts the specified element into this priority queue.
Removes all of the elements from this priority queue.
Returns the comparator used to order the elements in this queue, or null if this queue is sorted according to the natural ordering of its elements.
Returns true if this queue contains the specified element.
Returns an iterator over the elements in this queue.\
Inserts the specified element into this priority queue.
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
Retrieves and removes the head of this queue, or returns null if this queue is empty.
Removes a single instance of the specified element from this queue, if it is present.
Returns the number of elements in this collection.
Returns an array containing all of the elements in this queue.
Returns an array containing all of the elements in this queue; the runtime type of the returned array is that of the specified array.
Methods inherited from class java.util.AbstractQueue
Adds all of the elements in the specified collection to this queue. Attempts to addAll of a queue to itself result in IllegalArgumentException. Further, the behavior of this operation is undefined if the specified collection is modified while the operation is in progress.
Retrieves, but does not remove, the head of this queue. This method differs from peek only in that it throws an exception if this queue is empty.
Retrieves and removes the head of this queue. This method differs from poll only in that it throws an exception if this queue is empty.
Methods inherited from class java.util.AbstractCollection
Returns true if this collection contains all of the elements in the specified collection.
Returns true if this collection contains no elements.
This implementation returns size() == 0.
Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
Methods inherited from interface java.util.Collection
Returns true if this collection contains all of the elements in the specified collection.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Related Post
Facebook
twitter
google+
pinterest
Comments