This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes poll() and peek() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "poll() and peek()" Watch "poll() and peek()" New topic
Author

poll() and peek()

chander shivdasani
Ranch Hand

Joined: Oct 09, 2007
Posts: 206

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.


Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
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.


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Chander,

May be this link makes some (if not much) sense for you:
http://www.coderanch.com/t/262787/java-programmer-SCJP/certification/PriorityQueue


cmbhatt
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Oct 09, 2007
Posts: 206

thanks a lot everyone.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: poll() and peek()
 
Similar Threads
Print contents of PriorityQueue not working
doubtt in priority queue
PriorityQueue
Scrabble... it only takes a minute...
Is PriorityQueue Sorted