How can I use a map if I want to have multiple sets of keys for each object? I want to have a map of nodes which I can access by ID, Name, and maybe something else. Is the only soln to have 3 maps, 1 for each kind of key?
Maps may be a bad choice if any index key can get multiple items. Can you have Name=Dave with ID=1 and another Name=Dave with ID=2? Map will only store one object with key Dave. If you have a db background, all keys must be primary key candidates. A solution might be to store a collection at each non-unique key. When you get Dave from the map, you get an ArrayList full of Daves.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
did you try the hashmap? i think you can use the key to get the elements in your map
Joined: Apr 01, 2003
Each key brings a unique item But different objects who may access the collection may have different information and thus I want to be able to use different/multiple keys to find objects in my collection For ex Object A may only know of my node IDs, but object B may only know about node Name. Bot will uniquely map to a particular node. I would like to be able to have one central collection if possible, but allow both objects A and B to be able to find nodes in this collection using the key they know. Essentially I'd like this fcn collection.put(key1,key2,key3, object); Can this be done with a single collection, or do I need to find another method?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com