I need a data structure which works like the STL multiset but the TreeSet in Java doesn\'t allow duplicate elements. Is there any built-in data structure in Java which is eq
Since 1.8, Map allows you to do this:
map.computeIfAbsent(key, k -> new HashSet()).add(v);
Each value is added into a Set, which is created on demand.
You may need to change remove() too.