stlab.adobe.com Adobe Systems Incorporated
transform.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /*************************************************************************************************/
8 
9 #ifndef ADOBE_ALGORITHM_TRANSFORM_HPP
10 #define ADOBE_ALGORITHM_TRANSFORM_HPP
11 
12 #include <adobe/config.hpp>
13 
14 #include <boost/range/begin.hpp>
15 #include <boost/range/end.hpp>
16 #include <boost/bind.hpp>
17 
18 #include <algorithm>
19 
20 /*************************************************************************************************/
21 
22 namespace adobe {
23 
24 /*************************************************************************************************/
32 /*************************************************************************************************/
38 template <class InputIterator, class OutputIterator, class UnaryOperation>
39 inline OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result,
40  UnaryOperation op)
41 {
42  return std::transform(first, last, result, boost::bind(op, _1));
43 }
44 
50 template <class InputRange, class OutputIterator, class UnaryOperation>
51 inline OutputIterator transform(InputRange& range, OutputIterator result, UnaryOperation op)
52 {
53  return adobe::transform(boost::begin(range), boost::end(range), result, op);
54 }
55 
56 
62 template <class InputRange, class OutputIterator, class UnaryOperation>
63 inline OutputIterator transform(const InputRange& range, OutputIterator result, UnaryOperation op)
64 {
65  return adobe::transform(boost::begin(range), boost::end(range), result, op);
66 }
67 
68 
74 template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
75 inline OutputIterator transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
76  OutputIterator result, BinaryOperation binary_op)
77 {
78  return std::transform( first1, last1, first2, result,
79  boost::bind(binary_op, _1, _2));
80 }
81 
87 template <class InputRange1, class InputIterator2, class OutputIterator, class BinaryOperation>
88 inline OutputIterator transform(InputRange1& range1, InputIterator2 first2, OutputIterator result,
89  BinaryOperation binary_op)
90 {
91  return adobe::transform(boost::begin(range1), boost::end(range1), first2, result, binary_op);
92 }
93 
99 template <class InputRange1, class InputIterator2, class OutputIterator, class BinaryOperation>
100 inline OutputIterator transform(const InputRange1& range1, InputIterator2 first2,
101  OutputIterator result, BinaryOperation binary_op)
102 {
103  return adobe::transform(boost::begin(range1), boost::end(range1), first2, result, binary_op);
104 }
105 
106 /*************************************************************************************************/
107 
108 } // namespace adobe
109 
110 /*************************************************************************************************/
111 
112 #endif
113 
114 /*************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google