• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on PriorityQueue

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My code below



The output(sorry, after copy-paste it becomes unformated on the post in contrast to the code supposed):

natural order: [1, 2, 3]
insertion order: [3, 1, 2]
iteration order: [1, 3, 2]
poll order: [1, 2, 3]



Why didn't "iteration order" follow either "natural order" or "insertion order" but did poll?

[ December 19, 2006: Message edited by: Bob CHOI ]
[ December 19, 2006: Message edited by: Bob CHOI ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the API the Iterator returned by PriorityQueue.iterator() does not return the elements of the PriorityQueue in any particular order.
 
Bob CHOI
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry, thanks!

i've thought the poll order depends on the iteration order, now it turns out false, thus means polling uses either other existing or customized order.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic