Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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
Marshal
Posts: 53134
124
  • 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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!