lexicographical_compare.qbk 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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:lexicographical_compare lexicographical_compare]
  7. [heading Prototype]
  8. ``
  9. template<
  10. class SinglePassRange1,
  11. class SinglePassRange2
  12. >
  13. bool lexicographical_compare(const SinglePassRange1& rng1,
  14. const SinglePassRange2& rng2);
  15. template<
  16. class SinglePassRange1,
  17. class SinglePassRange2,
  18. class BinaryPredicate
  19. >
  20. bool lexicographical_compare(const SinglePassRange1& rng1,
  21. const SinglePassRange2& rng2,
  22. BinaryPredicate pred);
  23. ``
  24. [heading Description]
  25. `lexicographical_compare` compares element by element `rng1` against `rng2`. If the element from `rng1` is less than the element from `rng2` then `true` is returned. If the end of `rng1` without reaching the end of `rng2` this also causes the return value to be `true`. The return value is `false` in all other circumstances. The elements are compared using `operator<` in the non-predicate versions of `lexicographical_compare` and using `pred` in the predicate versions.
  26. [heading Definition]
  27. Defined in the header file `boost/range/algorithm/lexicographical_compare.hpp`
  28. [heading Requirements]
  29. [*For the non-predicate versions of lexicographical_compare:]
  30. * `SinglePassRange1` is a model of the __single_pass_range__ Concept.
  31. * `SinglePassRange2` is a model of the __single_pass_range__ Concept.
  32. * `SinglePassRange1`'s value type is a model of the `LessThanComparableConcept`.
  33. * `SinglePassRange2`'s value type is a model of the `LessThanComparableConcept`.
  34. * Let `x` be an object of `SinglePassRange1`'s value type. Let `y` be an object of `SinglePassRange2`'s value type. `x < y` must be valid. `y < x` must be valid.
  35. [*For the predicate versions of lexicographical_compare:]
  36. * `SinglePassRange1` is a model of the __single_pass_range__ Concept.
  37. * `SinglePassRange2` is a model of the __single_pass_range__ Concept.
  38. * `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
  39. * `SinglePassRange1`'s value type is convertible to `BinaryPredicate`'s first argument type.
  40. * `SinglePassRange2`'s value type is convertible to `BinaryPredicate`'s second argument type.
  41. [heading Complexity]
  42. Linear. At most `2 * min(distance(rng1), distance(rng2))` comparisons.
  43. [endsect]