File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Data Structures in Java Collections

Vaibhav G Garg
Ranch Hand

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

Vaibhav Garg
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46348
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:
subject: Data Structures in Java Collections
It's not a secret anymore!