Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TreeSet and it's interface

 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reviewing collections, and of all the books I've read and other web-sites I come across all seem to indicate that the TreeSet implements the SortSet interface.
While looking through JDK I came across this:
"This class (java.util.TreeSet) implements the Set interface, backed by a TreeMap instance. ... "
It this an error in the jdk doc? Can someone explain the anomalies here?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually it is backed by a SortedMap
From the source:
 
Rajinder Yadav
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great work Valetin, I guess the source code can't lie ... the ultimate reference
So if I come across a ture/false type exam question asking if a TreeSet implements the SortSet interface I should answer false!
[ February 28, 2002: Message edited by: Rajinder Yadav ]
 
swapna sivaraju
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Yeah i also came across this confusing statement..
can anyone elaborate on this.....
what does this mean--"-backed by TreeMap instance"..
Swapna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic