equal_range.qbk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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:equal_range equal_range]
  7. [heading Prototype]
  8. ``
  9. template<
  10. class ForwardRange,
  11. class Value
  12. >
  13. std::pair<typename range_iterator<ForwardRange>::type,
  14. typename range_iterator<ForwardRange>::type>
  15. equal_range(ForwardRange& rng, const Value& val);
  16. template<
  17. class ForwardRange,
  18. class Value
  19. >
  20. std::pair<typename range_iterator<const ForwardRange>::type,
  21. typename range_iterator<const ForwardRange>::type>
  22. equal_range(const ForwardRange& rng, const Value& val);
  23. template<
  24. class ForwardRange,
  25. class Value,
  26. class SortPredicate
  27. >
  28. std::pair<typename range_iterator<ForwardRange>::type,
  29. typename range_iterator<ForwardRange>::type>
  30. equal_range(ForwardRange& rng, const Value& val, SortPredicate pred);
  31. template<
  32. class ForwardRange,
  33. class Value,
  34. class SortPredicate
  35. >
  36. std::pair<typename range_iterator<const ForwardRange>::type,
  37. typename range_iterator<const ForwardRange>::type>
  38. equal_range(const ForwardRange& rng, const Value& val, SortPredicate pred);
  39. ``
  40. [heading Description]
  41. `equal_range` returns a range in the form of a pair of iterators where all of the elements are equal to `val`. If no values are found that are equal to `val`, then an empty range is returned, hence `result.first == result.second`. For the non-predicate versions of `equal_range` the equality of elements is determined by `operator<`.
  42. For the predicate versions of `equal_range` the equality of elements is determined by `pred`.
  43. [heading Definition]
  44. Defined in the header file `boost/range/algorithm/equal_range.hpp`
  45. [heading Requirements]
  46. [*For the non-predicate versions:]
  47. * `ForwardRange` is a model of the __forward_range__ Concept.
  48. * `Value` is a model of the `LessThanComparableConcept`.
  49. * The ordering of objects of type `Value` is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
  50. * `ForwardRange`'s value type is the same type as `Value`.
  51. [*For the predicate versions:]
  52. * `ForwardRange` is a model of the __forward_range__ Concept.
  53. * `SortPredicate` is a model of the `StrictWeakOrderingConcept`.
  54. * `ForwardRange`'s value type is the same as `Value`.
  55. * `ForwardRange`'s value type is convertible to both of `SortPredicate`'s argument types.
  56. [heading Precondition:]
  57. For the non-predicate versions: `rng` is ordered in ascending order according to `operator<`.
  58. For the predicate versions: `rng` is ordered in ascending order according to `pred`.
  59. [heading Complexity]
  60. For random-access ranges, the complexity is `O(log N)`, otherwise the complexity is `O(N)`.
  61. [endsect]