lower_bound.qbk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. [/
  2. Copyright 2010 Neil Groves
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. /]
  6. [section:lower_bound lower_bound]
  7. [heading Prototype]
  8. ``
  9. template<
  10. class ForwardRange,
  11. class Value
  12. >
  13. typename range_iterator<ForwardRange>::type
  14. lower_bound(ForwardRange& rng, Value val);
  15. template<
  16. range_return_value re,
  17. class ForwardRange,
  18. class Value
  19. >
  20. typename range_return<ForwardRange, re>::type
  21. lower_bound(ForwardRange& rng, Value val);
  22. template<
  23. class ForwardRange,
  24. class Value,
  25. class SortPredicate
  26. >
  27. typename range_iterator<ForwardRange>::type
  28. lower_bound(ForwardRange& rng, Value val, SortPredicate pred);
  29. template<
  30. range_return_value re,
  31. class ForwardRange,
  32. class Value,
  33. class SortPredicate
  34. >
  35. typename range_return<ForwardRange,re>::type
  36. lower_bound(ForwardRange& rng, Value val, SortPredicate pred);
  37. ``
  38. [heading Description]
  39. The versions of `lower_bound` that return an iterator, returns the first iterator in the range `rng` such that:
  40. without predicate - `*i < value` is `false`,
  41. with predicate - `pred(*i, value)` is `false`.
  42. `end(rng)` is returned if no such iterator exists.
  43. The versions of `lower_bound` that return a `range_return`, defines `found` in the same manner as the returned iterator described above.
  44. [heading Definition]
  45. Defined in the header file `boost/range/algorithm/lower_bound.hpp`
  46. [heading Requirements]
  47. [*For the non-predicate versions:]
  48. * `ForwardRange` is a model of the __forward_range__ Concept.
  49. * `Value` is a model of the `LessThanComparableConcept`.
  50. * The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
  51. * `ForwardRange`'s value type is the same type as `Value`.
  52. [*For the predicate versions:]
  53. * `ForwardRange` is a model of the __forward_range__ Concept.
  54. * `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
  55. * `ForwardRange`'s value type is the same type as `Value`.
  56. * `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
  57. [heading Precondition:]
  58. [*For the non-predicate versions:]
  59. `rng` is sorted in ascending order according to `operator<`.
  60. [*For the predicate versions:]
  61. `rng` is sorted in ascending order according to `pred`.
  62. [heading Complexity]
  63. For ranges that model the __random_access_range__ concept the complexity is `O(log N)`, where `N` is `distance(rng)`.
  64. For all other range types the complexity is `O(N)`.
  65. [endsect]