• Post Reply Bookmark Topic Watch Topic
  • New Topic

which Sorting algorithm follow's Tree Set?  RSS feed

 
sujitha reddy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which Sorting algorithm follow's Tree Set?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the API, TreeSet uses a TreeMap internally, which is based on a "Red-Black tree" algorithm.
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you really want to know what algorithm is used, then you need to look it up in the source code or google a little. if you just want to know what sorting criteria is applied then javadoc to the rescue:
This class implements the Set interface, backed by a TreeMap instance. This class guarantees that the sorted set will be in ascending element order, sorted according to the natural order of the elements (see Comparable), or by the comparator provided at set creation time, depending on which constructor is used.



pascal
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!