Does any one know why they where given these names? Comming from a maths backgound they always left my mind in tangles since they are both mathematical lower bounds i.e. minimums in the finite world. Also the natural language definition given in the stl is a bad mental model imo.
Does anyone use mental synonyms to be able to work with them, or do they just remember the naïve implementations?
lower_bound(rng, x) = get_iter_to(mathematical_lower_bound(rng | filter([](auto y)
                                  {return x<=y;}))
upper_bound(rng, x) = get_iter_to(mathematical_lower_bound(rng | filter([](auto y)
                                  {return x<y;})))

Igor Tandetnik answered this in the comments.
The set in question is the the elements which the given value can be inserted before while preserving the order.
For example if we want to insert 2 in to the range [0,1,2,2,3,4] then we could insert it at index 2, 3 or 4. lower_bound gives the iterator to the start of the range. upper_bound gives the last element in this range.
I suppose this is a name for library implementers writing pivots, rather than me trying to look up keys/indices of a vector of numerics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With