stable_sort.qbk 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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:stable_sort stable_sort]
  7. [heading Prototype]
  8. ``
  9. template<class RandomAccessRange>
  10. RandomAccessRange& stable_sort(RandomAccessRange& rng);
  11. template<class RandomAccessRange>
  12. const RandomAccessRange& stable_sort(const RandomAccessRange& rng);
  13. template<class RandomAccessRange, class BinaryPredicate>
  14. RandomAccessRange& stable_sort(RandomAccessRange& rng, BinaryPredicate pred);
  15. template<class RandomAccessRange, class BinaryPredicate>
  16. const RandomAccessRange& stable_sort(const RandomAccessRange& rng, BinaryPredicate pred);
  17. ``
  18. [heading Description]
  19. `stable_sort` sorts the elements in `rng` into ascending order. `stable_sort` is guaranteed to be stable. The order is preserved for equivalent elements.
  20. For versions of the `stable_sort` function without a predicate ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`.
  21. For versions of the `stable_sort` function with a predicate, ascending order is designed by `pred` such that for all adjacent elements `[x,y]`, `pred(y,x) == false`.
  22. [heading Definition]
  23. Defined in the header file `boost/range/algorithm/stable_sort.hpp`
  24. [heading Requirements]
  25. [*For versions of stable_sort without a predicate]
  26. * `RandomAccessRange` is a model of the __random_access_range__ Concept.
  27. * `RandomAccessRange` is mutable.
  28. * `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`.
  29. * The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements.
  30. [*For versions of stable_sort with a predicate:]
  31. * `RandomAccessRange` is a model of the __random_access_range__ Concept.
  32. * `RandomAccessRange` is mutable.
  33. * `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`.
  34. * `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types.
  35. [heading Complexity]
  36. Best case: `O(N)` where `N` is `distance(rng)`.
  37. Worst case: `O(N log(N)^2)` comparisons, where `N` is `distance(rng)`.
  38. [endsect]