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

Tree with duplicate keys

Vladimir Bezugliy
Ranch Hand

Joined: Sep 29, 2004
Posts: 33
Do you use any tree with duplicate keys?
What can I use from standard containers instead of it?

ps.
do not offer jgl.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
The Java Collections Framework does not offer a Tree class. However, there are tree implementations of some of the collections that ARE available. These include TreeSet and TreeMap.

However, to answer your question, one possible solution is to use a Map (either HashMap or TreeMap) where the value associated with each key is a List (or Map or Set or any other Collection). You can add the multiple values associated with the key to the List then add the List to the Map.

You may find it helpful to go through the Collections trail in Sun's Java Tutorial. Also, the Java API documentation is a great reference when looking for classes and methods to accomplish a specific task. You should familiarize yourself with the documentation. IMO, learning to navigate it is an essential skill when programming in Java.

I hope this helps get you headed in the right direction. Good luck!

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tree with duplicate keys
 
Similar Threads
Tree
HashMaps
Difference between HashMap and arraylist
List with a sublist of Integers
How to index java objects in memory