std::vector<int> v = {1,1,1,1,2,2};
auto cmp = [&v](size_t a, size_t b){return v[a] < v[b];};
std::multiset<int, decltype(cmp)> s(cmp);
Vector v's contents is just an example. It could be any array of ints, but can have repeating values.
I'm using a multiset because I want to be able to traverse over all the values by-order, and because values in v are not unique.
Also, I'd like to be able to know if a certain value is in it or not. For example after inserting:
s.insert(1);
s.insert(1);
s.insert(2);
s.insert(2);
I'd expect for the value of present in this test to be false:
auto iter = s.find(3);
bool present = iter != s.end();
However, it is true, I guess it's due to the internal implementation of set (AVL/RB-tree?) and how it searches for values inside using the comparator. Although, I'd think it should compare the last value to make sure it is what it thinks it is.
Is there an elegant way (without additional helper data structures) to make it "understand" it doesn't hold the value?