Hash provides O (1), which is fast and does nothing with the size of the elements.
As for Multimap, you can put values in a dependent collection (List, Set). Various collection implementations provide excellent performance.
EDIT: As I commented on Sebastian's answer. You can use Guava, which provides various options for collecting values: HashMultiMap (HashMap<KEY, HashSet<VALUE>>) , ArrayListMultiMap (HashMap<KEY, ArrayList<VALUE>>) ...
卢 声 远 Shengyuan Lu
source share