MultiMap vs MultiValue Map

后端 未结 4 1554
悲哀的现实
悲哀的现实 2021-01-17 21:40

At one place i have to use a map with many values mapped to a single key, so i was wondering whether there is any significant performance distinction between using H

4条回答
  •  庸人自扰
    2021-01-17 22:29

    Hash provides O(1) which is fast and does nothing with the size of elements.

    Regarding to Multimap, you could put values in dependent collection (List, Set). Different collection implementations provides different performance.

    EDIT: As I commented on Sebastian's answer. You could use Guava which provides different value collection implemantions: HashMultiMap (HashMap>), ArrayListMultiMap (HashMap>)...

提交回复
热议问题