unique.qbk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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:unique unique]
  7. [heading Prototype]
  8. ``
  9. template<class ForwardRange>
  10. typename range_return<ForwardRange, return_begin_found>::type
  11. unique(ForwardRange& rng);
  12. template<class ForwardRange>
  13. typename range_return<const ForwardRange, return_begin_found>::type
  14. unique(const ForwardRange& rng);
  15. template<class ForwardRange, class BinaryPredicate>
  16. typename range_return<ForwardRange, return_begin_found>::type
  17. unique(ForwardRange& rng, BinaryPredicate pred);
  18. template<class ForwardRange, class BinaryPredicate>
  19. typename range_return<const ForwardRange, return_begin_found>::type
  20. unique(const ForwardRange& rng, BinaryPredicate pred);
  21. template<range_return_value re, class ForwardRange>
  22. typename range_return<ForwardRange, re>::type
  23. unique(ForwardRange& rng);
  24. template<range_return_value re, class ForwardRange>
  25. typename range_return<const ForwardRange, re>::type
  26. unique(const ForwardRange& rng);
  27. template<range_return_value re, class ForwardRange, class BinaryPredicate>
  28. typename range_return<ForwardRange, re>::type
  29. unique(ForwardRange& rng, BinaryPredicate pred);
  30. template<range_return_value re, class ForwardRange, class BinaryPredicate>
  31. typename range_return<const ForwardRange, re>::type
  32. unique(const ForwardRange& rng, BinaryPredicate pred);
  33. ``
  34. [heading Description]
  35. `unique` removes all but the first element of each sequence of duplicate encountered in `rng`.
  36. Elements in the range `[new_last, end(rng))` are dereferenceable but undefined.
  37. Equality is determined by the predicate if one is supplied, or by `operator==()` for `ForwardRange`'s value type.
  38. [heading Definition]
  39. Defined in the header file `boost/range/algorithm/unique.hpp`
  40. [heading Requirements]
  41. [*For the non-predicate versions of unique:]
  42. * `ForwardRange` is a model of the __forward_range__ Concept.
  43. * `ForwardRange` is mutable.
  44. * `ForwardRange`'s value type is a model of the `EqualityComparableConcept`.
  45. [*For the predicate versions of unique:]
  46. * `ForwardRange` is a model of the __forward_range__ Concept.
  47. * `ForwardRange` is mutable.
  48. * `BinaryPredicate` is a model of the `BinaryPredicateConcept`.
  49. * `ForwardRange`'s value type is convertible to `BinaryPredicate`'s first argument type and to `BinaryPredicate`'s second argument type.
  50. [heading Complexity]
  51. Linear. `O(N)` where `N` is `distance(rng)`. Exactly `distance(rng)` comparisons are performed.
  52. [endsect]