• 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

how comparator works

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my question is based on following program



when i use ts.add("G") how compare method in MyComp is called?

thanks
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To find out, I would go through the source of the method and trace the execution. TreeSet#add(...) calls TreeMap#put(...) on a TreeMap constructed with the supplied comparator, and that comparator is used in put(...)
 
shriram iyer
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darryl Burke wrote:To find out, I would go through the source of the method and trace the execution. TreeSet#add(...) calls TreeMap#put(...) on a TreeMap constructed with the supplied comparator, and that comparator is used in put(...)



do you mean following method



i have doubt in above method.what t.left ,t.right means

thanks
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shriram iyer wrote:i have doubt in above method.what t.left ,t.right means


They are the next node downward to the "left" or "right", but for a full explanation you should probably Google something like "B-tree algorithm".

Winston
reply
    Bookmark Topic Watch Topic
  • New Topic