Reputation: 4973
What would be the benefits of using MultiKeyMap vs. using Map with Map values in the matters of performance (any maybe readability, in your opinion)?
Upvotes: 0
Views: 706
Reputation: 70989
When you use a Multy key map, a single lookup will be done in the underlying HashMap
while if you go with using a Map with Map values you will have to perform at least two lookups to find the element you are looking for.
Also note that you may use generics with Map of Map-s and thus you may specify the key-s and values types, while with MultiKeyMap you can not do that. That is why I would say using a Map of Map-s is a bit "safer" in that aspect.
Upvotes: 1