• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

poll() and peek()

 
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having a hard time understanding the concept of poll() and peek() in priority queue. And also what is the natural order of sorting.
 
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Poll removes the object from the Queue ,where as peek() simple retrives the object and does not remove it.
Natural ordering is ordering in a natural way.
For eg in String it would be Alphabetical order
In Numbers it would be Increasing order ...

Check out the api for further details.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chander,

May be this link makes some (if not much) sense for you:
https://coderanch.com/t/262787/java-programmer-SCJP/certification/PriorityQueue
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chander,

Natural order of sorting:


1- Sorting numbers 323, 645, 43, 5, 53,2,654
Natural sorting (ascending order): 2,5,43,53,323,645,654
Natural sorting (descending order): 654, 645, 323, 53,43,5,2

2- Sorting characters: C, G, A, F, B, Z, X, T
A,B,C,F,G,X,T,Z

3- Sorting of String:
madan, chander, chandra, madam, carlos
carlos, chander, chandra, madam, madan


I think, if not going so verbose, the given examples make sense to understand the natural sorting order.
[ September 03, 2008: Message edited by: Chandra Bhatt ]
 
chander shivdasani
Ranch Hand
Posts: 206
Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot everyone.
 
Trust God, but always tether your camel... to this tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic