File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compare method arguments ?

 
aslika bahini
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




PQsort pqs = new PQsort();
Priorityqueue<Ingeger> pq2 = new priorityqueue<Integers>(10,pqs);

Creates a PriorityQueue with the specified initial capacity that
orders its elements according to the specified comparator.

initialCapacity - the initial capacity for this priority queue.
comparator - the comparator used to order this priority queue. If
null then the order depends on the elements'
natural ordering.

the 2nd parameter in the priorityqueue constructor invokes the
compare of method. (which happens behind the scene)
what arguments are passed inside compare of method?
say here public int compare(Integer one, Integer two)
what one and two holds?
can anyone explain

Thanks
samura



 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This might not completely answer your question, but it should suggest an approach to investigating questions like this.
[ July 02, 2007: Message edited by: marc weber ]
 
aslika bahini
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ObjectArrayPriorityQueue(int capacity, Comparator c)
Creates a new empty queue with a given capacity and comparator.

Is the above one is same as this
priorityqueue(int capacity, Comparator c)?

Thanks
samura
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are entirely different classes:
  • PriorityQueue is part of Sun's standard Java API.
  • ObjectArrayPriorityQueue is a third-party class from fastutil. (See the fastutil site for details.)
  • No third-party classes are covered in the SCJP exam.
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic