Does Java have a multiset data structure like the one in C++ STL?

后端 未结 7 559
灰色年华
灰色年华 2020-12-28 13:00

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

相关标签:
7条回答
  • 2020-12-28 14:00

    Using Map<E, Integer> where Integer is the count is a good replacement for Multiset, and it does not need any third party library as well.

    Update: If you really want to store the object twice, use a List with a Map like Map<E, List<E>>.

    0 讨论(0)
提交回复
热议问题