Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Function transform

boost::range_run_storage::transform — Apply a unary transformation to a single InfiniteRangeRunStorage, or a binary transform to two InfiniteRangeRunStorage.

Synopsis

// In header: <boost/range_run_storage/algorithm/transform.hpp>


template<typename In, typename UnaryOp, typename Out> 
  Out & transform(In & in, UnaryOp const & unary_op, Out & out);
template<typename In, typename UnaryOp, typename Out> 
  Out & transform(In const & in, UnaryOp const & unary_op, Out & out);
template<typename Left, typename Right, typename BothOp, typename LeftOp, 
         typename RightOp, typename Out> 
  Out & transform(Left const & left, Right const & right, 
                  BothOp const & both_op, LeftOp const & left_op, 
                  RightOp const & right_op, Out & out);
template<typename Left, typename Right, typename BinOp, typename Out> 
  Out & transform(Left const & left, Right const & right, 
                  BinOp const & binary_op, Out & out);

Description

The three-parameter form of transform, transform(in, unary_op, out), effectively copies the runs from in to out after applying unary_op to each element value.

The four-parameter form of transform, transform(left, right, binary_op, out), steps through the series left and right in lock-step. Where two runs overlap, the result of binary_op(left_value, right_value) is written to out. Where part of a left run does not overlap with a right, the result of binary_op(left_value, rrs::zero(right)) is written to out. Where part of a right run does not overlap with a left, the result of binary_op(rrs::zero(left), right_value) is written to out.

The six-parameter form of transform, transform(left, right, both_op, left_op, right_op, out), steps through the series left and right in lock-step. Where two runs overlap, the result of both_op(left_value, right_value) is written to out. Where part of a left run does not overlap with a right, the result of left_op(left_value) is written to out. Where part of a right run does not overlap with a left, the result of right_op(right_value) is written to out.

Parameters:
in

The input sequence.

out

An OrderedInserter into which the resulting sequence is written.

unary_op

A UnaryFunction used to transform the elements of the input sequence.

Requires:

In is a model of InfiniteRangeRunStorage.

Left is a model of InfiniteRangeRunStorage.

Right is a model of InfiniteRangeRunStorage.

UnaryOp is a model of UnaryFunction.

LeftOp is a model of UnaryFunction.

RightOp is a model of UnaryFunction.

BothOp is a model of BinaryFunction.

BinaryOp is a model of BinaryFunction.

Out is a model of OrderedInserter.


PrevUpHomeNext