### hwangganzi's blog

By hwangganzi, history, 4 weeks ago, ,

I want to find a pair that both first and the second value are bigger than s.lower_bound({a,b})

for example ~~~~ set<pair<int,int>> s; s.insert({50, 40}); s.insert({100, 20}); s.insert({120, 80}); auto it = s.lower_bound({80 , 60 }); ~~~~ if I do like this, iterator will find pair({100,20}). But What I want is pair ({120, 80}) because both first and the second value are bigger than ({80, 60}). for ({100, 20}) the first value is bigger than 80 but the second value is smaller than 60. This is not what I want. Sorry for my bad english, Thank you in advance.

• +6

 » 4 weeks ago, # |   +13 a set can't do that because the order you describe is not a total order.
•  » » 4 weeks ago, # ^ |   0 I think using lower_bound at max 2 times will work .You can see my comment below and tell me if I am wrong .
 » 4 weeks ago, # | ← Rev. 4 →   +15 Edit : I was wrong .
•  » » 4 weeks ago, # ^ |   +12 add the entries {100, 21}, {100, 22}, ... , {100, 1000000000}...
•  » » » 4 weeks ago, # ^ |   0 Thanks I got the mistake .
•  » » » » 4 weeks ago, # ^ |   +1 Thank you nice try though
•  » » » 4 weeks ago, # ^ |   0 Thanks i got it