Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Natuaral ordering in PriorityQueues  RSS feed

 
vinay raghu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,



Output:
Priority Queue is [apple, ball, cat, dog, eagle, food, god, hen]
p.peek() is : apple
p.poll() is : apple
Priority Queue is [ball, dog, cat, hen, eagle, food, god]

I am not sure, how the order of the elements is happening.

Any help would be highly appreciated.

Thank you in advance
Vinay R
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your code. Always use them. Doesn't it look better
What does it say in the (link→) PriorityQueue documentation about the iterator method?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!