noobied's blog

By noobied, history, 6 years ago, In English

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?

  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it +14 Vote: I do not like it
  1. TreeMap<Key, Count>
  2. TreeSet<Pair<Key, Index>>
  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

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

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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 years ago, # |
  Vote: I like it +17 Vote: I do not like it

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

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.