Brian Silverman | 598d029 | 2018-08-04 23:56:47 -0700 | [diff] [blame^] | 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:adjacent_difference adjacent_difference] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template< |
| 12 | class SinglePassRange, |
| 13 | class OutputIterator |
| 14 | > |
| 15 | OutputIterator adjacent_difference( |
| 16 | const SinglePassRange& source_rng, |
| 17 | OutputIterator out_it); |
| 18 | |
| 19 | template< |
| 20 | class SinglePassRange, |
| 21 | class OutputIterator, |
| 22 | class BinaryOperation |
| 23 | > |
| 24 | OutputIterator adjacent_difference( |
| 25 | const SinglePassRange& source_rng, |
| 26 | OutputIterator out_it, |
| 27 | BinaryOperation op); |
| 28 | `` |
| 29 | |
| 30 | [heading Description] |
| 31 | |
| 32 | `adjacent_difference` calculates the differences of adjacent_elements in `rng`. |
| 33 | |
| 34 | The first version of `adjacent_difference` uses `operator-()` to calculate the differences. |
| 35 | The second version uses `BinaryOperation` instead of `operator-()`. |
| 36 | |
| 37 | [heading Definition] |
| 38 | |
| 39 | Defined in the header file `boost/range/numeric.hpp` |
| 40 | |
| 41 | [heading Requirements] |
| 42 | |
| 43 | [heading For the first version] |
| 44 | |
| 45 | # `SinglePassRange` is a model of the __single_pass_range__ Concept. |
| 46 | # `OutputIterator` is a model of the `OutputIteratorConcept`. |
| 47 | # If `x` and `y` are objects of `SinglePassRange`'s value type, then `x - y` is defined. |
| 48 | # The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. |
| 49 | # The return type of `x - y` is convertible to a type in `OutputIterator`'s set of value types. |
| 50 | |
| 51 | [heading For the second version] |
| 52 | |
| 53 | # `SinglePassRange` is a model of the __single_pass_range__ Concept. |
| 54 | # `OutputIterator` is a model of the `OutputIteratorConcept`. |
| 55 | # `BinaryOperation` is a model of the `BinaryFunctionConcept`. |
| 56 | # The value type of `SinglePassRange` is convertible to `BinaryOperation`'s first and second argument types. |
| 57 | # The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types. |
| 58 | # The result type of `BinaryOperation` is convertible to a type in `OutputIterator`'s set of value types. |
| 59 | |
| 60 | [heading Precondition:] |
| 61 | |
| 62 | `[result, result + distance(rng))` is a valid range. |
| 63 | |
| 64 | [heading Complexity] |
| 65 | |
| 66 | Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed. |
| 67 | |
| 68 | [endsect] |