• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
     
    I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic