Boost.RangeEx merged into Boost.Range

[SVN r60897]
This commit is contained in:
Neil Groves
2010-03-28 16:08:35 +00:00
parent 1461479a17
commit b0d1db7c2e
471 changed files with 48610 additions and 2065 deletions

View File

@ -0,0 +1,56 @@
[section:accumulate accumulate]
[heading Prototype]
``
template<
class SinglePassRange,
class Value
>
Value accumulate(const SinglePassRange& source_rng,
Value init);
template<
class SinglePassRange,
class Value,
class BinaryOperation
>
Value accumulate(const SinglePassRange& source_rng,
Value init,
BinaryOperation op);
``
[heading Description]
`accumulate` is a generalisation of summation. It computes a binary operation (`operator+`
in the non-predicate version) of `init` and all of the elements in `rng`.
The return value is the resultant value of the above algorithm.
[heading Definition]
Defined in the header file `boost/range/numeric.hpp`
[heading Requirements]
[heading For the first version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `Value` is a model of the `AssignableConcept`.
# An `operator+` is defined for a left-hand operand of type `Value` and a right-hand operance of the `SinglePassRange` value type.
# The return type of the above operator is convertible to `Value`.
[heading For the second version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `Value` is a model of the `AssignableConcept`.
# `BinaryOperation` is a model of the `BinaryFunctionConcept`.
# `Value` is convertible to `BinaryOperation`'s first argument type.
# `SinglePassRange`'s value type is convertible to `BinaryOperation`'s second argument type.
# The return type of `BinaryOperation` is convertible to `Value`.
[heading Complexity]
Linear. Exactly `distance(source_rng)`.
[endsect]

View File

@ -0,0 +1,63 @@
[section:adjacent_difference adjacent_difference]
[heading Prototype]
``
template<
class SinglePassRange,
class OutputIterator
>
OutputIterator adjacent_difference(
const SinglePassRange& source_rng,
OutputIterator out_it);
template<
class SinglePassRange,
class OutputIterator,
class BinaryOperation
>
OutputIterator adjacent_difference(
const SinglePassRange& source_rng,
OutputIterator out_it,
BinaryOperation op);
``
[heading Description]
`adjacent_difference` calculates the differences of adjacent_elements in `rng`.
The first version of `adjacent_difference` uses `operator-()` to calculate the differences.
The second version uses `BinaryOperation` instead of `operator-()`.
[heading Definition]
Defined in the header file `boost/range/numeric.hpp`
[heading Requirements]
[heading For the first version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `OutputIterator` is a model of the `OutputIteratorConcept`.
# If `x` and `y` are objects of `SinglePassRange`'s value type, then `x - y` is defined.
# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
# The return type of `x - y` is convertible to a type in `OutputIterator`'s set of value types.
[heading For the second version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `OutputIterator` is a model of the `OutputIteratorConcept`.
# `BinaryOperation` is a model of the `BinaryFunctionConcept`.
# The value type of `SinglePassRange` is convertible to `BinaryOperation`'s first and second argument types.
# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
# The result type of `BinaryOperation` is convertible to a type in `OutputIterator`'s set of value types.
[heading Precondition:]
`[result, result + distance(rng))` is a valid range.
[heading Complexity]
Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed.
[endsect]

View File

@ -0,0 +1,67 @@
[section:inner_product inner_product]
[heading Prototype]
``
template<class SinglePassRange1,
class SinglePassRange2,
class Value>
Value inner_product( const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
Value init);
template<class SinglePassRange1,
class SinglePassRange2,
class Value,
class BinaryOperation1,
class BinaryOperation2>
Value inner_product( const SinglePassRange1& rng1,
const SinglePassRange2& rng2,
Value init,
BinaryOperation1 op1,
``
[heading Description]
`inner_product` calculates a generalised inner product of the range `rng1` and `rng2`.
For further information on the `inner_product` algorithm please see __sgi_inner_product__.
[heading Definition]
Defined in the header file `boost/range/numeric.hpp`
[heading Requirements]
[heading For the first version]
# `SinglePassRange1` is a model of the __single_pass_range__ Concept.
# `SinglePassRange2` is a model of the __single_pass_range__ Concept.
# `Value` is a model of the `AssignableConcept`.
# If `x` is an object of type `Value`, `y` is an object of `SinglePassRange1`'s value
type, and `z` is an object of `SinglePassRange2`'s value type, then `x + y * z`
is defined.
# The result type of the expression `x + y * z` is convertible to `Value`.
[heading For the second version]
# `SinglePassRange1` is a model of the __single_pass_range__ Concept.
# `SinglePassRange2` is a model of the __single_pass_range__ Concept.
# `Value` is a model of the `AssignableConcept`.
# `BinaryOperation1` is a model of the `BinaryFunctionConcept`.
# `BinaryOperation2` is a model of the `BinaryFunctionConcept`.
# The value type of `SinglePassRange1` is convertible to the first argument type of `BinaryOperation2`.
# The value type of `SinglePassRange2` is convertible to the second argument type of `BinaryOperation2`.
# `Value` is convertible to the value type of `BinaryOperation1`.
# The return type of `BinaryOperation2` is convertible to the second argument type of `BinaryOperation1`.
# The return type of `BinaryOperation1` is convertible to `Value`.
[heading Precondition:]
`distance(rng2) >= distance(rng1)` is a valid range.
[heading Complexity]
Linear. Exactly `distance(rng)`.
[endsect]

View File

@ -0,0 +1,55 @@
[section:partial_sum partial_sum]
[heading Prototype]
``
template<class SinglePassRange,
class OutputIterator>
OutputIterator partial_sum(const SinglePassRange& rng,
OutputIterator out_it);
template<class SinglePassRange,
class OutputIterator,
class BinaryOperation>
OutputIterator partial_sum(const SinglePassRange& rng,
OutputIterator out_it,
BinaryOperation op);
``
[heading Description]
`partial_sum` calculates a generalised partial sum of `rng` in the same manner as
`std::partial_sum(boost::begin(rng), boost::end(rng), out_it)`. See __sgi_partial_sum__.
[heading Definition]
Defined in the header file `boost/range/numeric.hpp`
[heading Requirements]
[heading For the first version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `OutputIterator` is a model of the `OutputIteratorConcept`.
# If `x` and `y` are objects of `SinglePassRange`'s value type, then `x + y` is defined.
# The return type of `x + y` is convertible to the value type of `SinglePassRange`.
# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
[heading For the second version]
# `SinglePassRange` is a model of the __single_pass_range__ Concept.
# `OutputIterator` is a model of the `OutputIteratorConcept`.
# `BinaryOperation` is a model of the `BinaryFunctionConcept`.
# The result type of `BinaryOperation` is convertible to the value type of `SinglePassRange`.
# The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.
[heading Precondition:]
`[result, result + distance(rng))` is a valid range.
[heading Complexity]
Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed.
[endsect]