Блог пользователя noobied

Автор noobied, история, 6 лет назад, По-английски

How can i implement a Multiset in java which has all functions of treeset such as higher(),lower(),ceiling(),floor() etc. Is there is any way?

  • Проголосовать: нравится
  • -2
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится
  1. TreeMap<Key, Count>
  2. TreeSet<Pair<Key, Index>>
  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Can we get min and max keys from TreeMap in better than O(n) time? If yes, how?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Yes of course, take a look at the jdk manual of the TreeMap class, if I remember correctly it's firstKey() and lastKey() (not to sure, check it out).

»
6 лет назад, # |
  Проголосовать: нравится +17 Проголосовать: не нравится

multitreeset class i wrote a long time ago https://ideone.com/IxJk23

»
3 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In case it helps anyone, I implemented MultiSet here and Ordered MultiSet here in Java.

Let me know if you find any mistakes. Suggestions are always welcomed.