Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doubtt in priority queue  RSS feed

 
rajeev jayappa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between poll and peek method
i read the api but could not get the concept
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They both returns the head of the queue, but poll() also removes the retrieved element.

Queue : 1,2,3,4
peek : 1 (queue:1,2,3,4)
peek : 1 (queue:1,2,3,4)
poll : 1 (queue:2,3,4)
peek : 2 (queue:2,3,4)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!