• 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

compare method arguments ?

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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



 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
    reply
      Bookmark Topic Watch Topic
    • New Topic