Polymorphic HashTable like datastructure
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?开发者_开发知识库
Instead of using a HashTable, it'd be easier to use a tree, since a tree would easily represent the type heirarchy.
If you key you HashMap by Class objects it will behave exactly as you expect it to. There will be no lookup on "subtype".
精彩评论