hwangganzi's blog

By hwangganzi, history, 5 years ago, In English

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.

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

»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

a set can't do that because the order you describe is not a total order.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think using lower_bound at max 2 times will work .
    You can see my comment below and tell me if I am wrong .

»
5 years ago, # |
Rev. 4   Vote: I like it +15 Vote: I do not like it

Edit : I was wrong .