aspose file tools*
The moose likes Java in General and the fly likes Data Structures in Java Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Data Structures in Java Collections" Watch "Data Structures in Java Collections" New topic
Author

Data Structures in Java Collections

Vaibhav G Garg
Ranch Hand

Joined: Sep 23, 2011
Posts: 140
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

Joined: Oct 13, 2005
Posts: 39869
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data Structures in Java Collections