• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how comparator works

 
shriram iyer
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Darryl Burke
Bartender
Posts: 5116
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Winston Gutkowski
Bartender
Pie
Posts: 9498
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic