BiggestQuitter's blog

By BiggestQuitter, history, 8 years ago, In English

Hello everybody, I was solving a problem and for that, I needed a sorted map in java which stores an integer at the place of the key and a "Sorted Set" in place of value. Also, is the procedure same when we replace this sorted set with some user made class?

Can anyone tell me how to implement one such Sorted Map?

Also, what to do we have to do when we are implementing one such map where key is a sorted set? Is it really possible to implement one such thing in either C++ or Java?

Any tutorial/guidance/links will suffice.

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

| Write comment?
»
8 years ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

C++: map<int, set<int>>

Java: TreeMap<Integer, TreeSet<Integer>>

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

    Hello and thanks for reply.

    But my question was not this. :(

    Let me explain it a bit more clearly.

    In C++, we can do something like this

    map < int , set < int > > a;

    and it goes like this

    a[key].insert(value);

    But how to implement the same in Java because there we do like this — a.push(key , value);

    But how we will do this thing?

    and other questions are like suppose I declare something like map < set < int > , int > a. ow to go on with this then in both the languages?