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

Data Structures in Java Collections

 
Vaibhav G Garg
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am just curious to know that the Java has provided a COLLECTIONS framework which has some data structures such as LinkedList, ArrayList, Sets, HashMaps but there is no provision for Graphs and Trees. Can you please suggest why these have not been provided since if we have to solve some problem using Breadth First Search or some tree algorithm, then these data structures would have been really helpful.

Thanks,
Vaibhav Garg
 
Campbell Ritchie
Sheriff
Posts: 48642
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are trees, but only as TreeSet, etc.
I think the idea of the collections framework was to provide a wide range of collections, rather than particular data structures. You can use a Set implementation without knowing whether it is based on an array or a tree.
On the other hand, what you want is a particular data structure. Maybe the designers thought that everybody would need different structures or functionality, so thought it better to let them create their own. Of course, you might find a tree to suit your needs in Apache Commons or similar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic