partition.qbk 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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:partition partition]
  7. [heading Prototype]
  8. ``
  9. template<
  10. class ForwardRange,
  11. class UnaryPredicate
  12. >
  13. typename range_iterator<ForwardRange>::type
  14. partition(ForwardRange& rng, UnaryPredicate pred);
  15. template<
  16. class ForwardRange,
  17. class UnaryPredicate
  18. >
  19. typename range_iterator<const ForwardRange>::type
  20. partition(const ForwardRange& rng, UnaryPredicate pred);
  21. template<
  22. range_return_value re,
  23. class ForwardRange,
  24. class UnaryPredicate
  25. >
  26. typename range_return<ForwardRange, re>::type
  27. partition(ForwardRange& rng, UnaryPredicate pred);
  28. template<
  29. range_return_value re,
  30. class ForwardRange,
  31. class UnaryPredicate
  32. >
  33. typename range_return<const ForwardRange, re>::type
  34. partition(const ForwardRange& rng, UnaryPredicate pred);
  35. ``
  36. [heading Description]
  37. `partition` orders the elements in `rng` based on `pred`, such that the elements that satisfy `pred` precede the elements that do not. In the versions that return a single iterator, the return value is the middle iterator. In the versions that have a configurable range_return, `found` corresponds to the middle iterator.
  38. [heading Definition]
  39. Defined in the header file `boost/range/algorithm/partition.hpp`
  40. [heading Requirements]
  41. * `ForwardRange` is a model of the __forward_range__ Concept. For C++ versions prior to C++11 the underlying std::partition requires Bidirectional Iterators, hence the requirement for older library versions is for a __bidirectional_range__.
  42. * `UnaryPredicate` is a model of the `PredicateConcept`.
  43. * `ForwardRange`'s value type is convertible to `UnaryPredicate`'s argument type.
  44. [heading Complexity]
  45. Linear. Exactly `distance(rng)` applications of `pred`, and at most `distance(rng) / 2` swaps.
  46. [endsect]