mercredi 22 août 2018

Creating ordered multiset with correctly working find()

I tried to create ordered multiset with such code:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

using ordered_multiset = tree <type1, null_type, less_equal <type1>, rb_tree_tag, tree_order_statistics_node_update>;

veni_multisetano <ll> kek;

int main()
{
    kek.insert(1); kek.insert(1);
    kek.insert(2); kek.insert(2); kek.insert(2);
    kek.insert(3);
    cout << (kek.find(2) == kek.end()) << endl;
}

But find() cant find any number because of using less_equal < ll > comparator instead of less < ll >. So, how to save dublicates in sorted set with working right find()?

Aucun commentaire:

Enregistrer un commentaire