priority queue and peek, poll methods

Hi,


When we use priority queue and whar are the uses of peek, poll methods. How it is different from regular queue and dequeue. please advise
LVL 7
gudii9Asked:
Who is Participating?
 
ozoCommented:
For a java.util.PriorityQueue object, peek retrieves but does not remove the head of the queue, poll retrieves and removes the head of the queue.
http://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html
The elements of the priority queue are ordered according to their value, while the elements of a regular queue are ordered by which was inserted first.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.