java.util.PriorityQueue
An unbounded priority queue based on a priority heap. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used. A priority queue does not permit null elements.
Some methods of PriorityQueue class.
add(K): This method inserts the specified element into this priority queue.
addAll(Collection): This method adds all of the elements in the specified collection to this queue.
clear(): This method removes all of the elements from this priority queue.
comparator(): This method 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.
contains(Object): This method returns true if this queue contains the specified element.
containsAll(Collection): This method returns true if this collection contains all of the elements in the specified collection.
element(): This method retrieves but does not remove, the head of this queue.
equals(Object): This method indicates whether some other object is "equal to" this one.
forEach(Consumer): This method performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
hashCode(): This method returns a hash code value for the object.
isEmpty(): This method returns true if this collection contains no elements.
iterator(): This method returns an iterator over the elements in this queue.
offer(K): This method inserts the specified element into this priority queue.
parallelStream(): This method returns a possibly parallel Stream with this collection as its source.
Some more Methods of PriorityQueue class Methods
No comments:
Post a Comment