arbcrt040's blog

By arbcrt040, history, 9 years ago, In English

Hello guys :)

I've read this blog by adamant. So my question is: Is there a way to get kth number in a multiset. Thanks in advance.

(Sorry for bad English)

  • Vote: I like it
  • +6
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +8 Vote: I do not like it

you can transform any set into multiset. Just like in adamant's example:

typedef tree<pair<int, int>, ...> ordered_set;

ordered_set X;
int cnt = 0;

X.insert({1, cnt}); cnt += 1;
X.insert({1, cnt}); cnt += 1;
X.insert({2, cnt}); cnt += 1;

cout << X.find_by_order(1)->first << endl; // 1
cout << X.order_of_key({2, 0}) << endl; // 2
  • »
    »
    9 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Ohhh thanks, you're right. I feel so dumb now :d