I have set<int>, and I want to see how many elements there are less than x in it. (x also int)
set<int>
What should I do?
Use lower_boundto calculate std::distance(s.begin(), s.lower_bound(x)). (If xis the key, this counts the number of elements strictly up to x.)
lower_bound
std::distance(s.begin(), s.lower_bound(x))
x