prev_permutation.qbk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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:prev_permutation prev_permutation]
  7. [heading Prototype]
  8. ``
  9. template<class BidirectionalRange>
  10. bool prev_permutation(BidirectionalRange& rng);
  11. template<class BidirectionalRange>
  12. bool prev_permutation(const BidirectionalRange& rng);
  13. template<class BidirectionalRange, class Compare>
  14. bool prev_permutation(BidirectionalRange& rng, Compare pred);
  15. template<class BidirectionalRange, class Compare>
  16. bool prev_permutation(const BidirectionalRange& rng, Compare pred);
  17. ``
  18. [heading Description]
  19. `prev_permutation` transforms the range of elements `rng` into the lexicographically next smaller permutation of the elements if such a permutation exists. If one does not exist then the range is transformed into the lexicographically largest permutation and `false` is returned. `true` is returned when the next smaller permutation is successfully generated.
  20. The ordering relationship is determined by using `operator<` in the non-predicate versions, and by evaluating `pred` in the predicate versions.
  21. [heading Definition]
  22. Defined in the header file `boost/range/algorithm/permutation.hpp`
  23. [heading Requirements]
  24. [*For the non-predicate versions:]
  25. * `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
  26. * `BidirectionalRange` is mutable.
  27. * `BidirectionalRange`'s value type is a model of the `LessThanComparableConcept`.
  28. * The ordering of objects of type `BidirectionalRange`'s value type is a [*/strict weak ordering/], as defined in the `LessThanComparableConcept` requirements.
  29. [*For the predicate versions:]
  30. * `BidirectionalRange` is a model of the __bidirectional_range__ Concept.
  31. * `BidirectionalRange` is mutable.
  32. * `Compare` is a model of the `StrictWeakOrderingConcept`.
  33. * `BidirectionalRange`'s value type is convertible to both of `Compare`'s argument types.
  34. [heading Complexity]
  35. Linear. At most `distance(rng) / 2` swaps.
  36. [endsect]