Reputation: 504
I'm creating a client side cache object and one of the consumers of the cache needs a means of looking up data by type. Obviously I can't just have a map from class to data since that wouldn't retrieve subtypes of the class. Is there a 'standard' or well suited data structure for this kind of thing?
Upvotes: 1
Views: 175
Reputation: 9096
If you key you HashMap by Class objects it will behave exactly as you expect it to. There will be no lookup on "subtype".
Upvotes: 0
Reputation: 5205
Instead of using a HashTable, it'd be easier to use a tree, since a tree would easily represent the type heirarchy.
Upvotes: 2