stlab.adobe.com Adobe Systems Incorporated

transform.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 
00009 #ifndef ADOBE_ALGORITHM_TRANSFORM_HPP
00010 #define ADOBE_ALGORITHM_TRANSFORM_HPP
00011 
00012 #include <adobe/config.hpp>
00013 
00014 #include <boost/range/begin.hpp>
00015 #include <boost/range/end.hpp>
00016 #include <boost/bind.hpp>
00017 
00018 #include <algorithm>
00019 
00020 /*************************************************************************************************/
00021 
00022 namespace adobe {
00023 
00024 /*************************************************************************************************/
00032 /*************************************************************************************************/
00038 template <class InputIterator, class OutputIterator, class UnaryOperation>
00039 inline OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result,
00040     UnaryOperation op)
00041 {
00042     return std::transform(first, last, result, boost::bind(op, _1));
00043 }
00044 
00050 template <class InputRange, class OutputIterator, class UnaryOperation>
00051 inline OutputIterator transform(InputRange& range, OutputIterator result, UnaryOperation op)
00052 {
00053     return adobe::transform(boost::begin(range), boost::end(range), result, op);
00054 }
00055     
00056 
00062 template <class InputRange, class OutputIterator, class UnaryOperation>
00063 inline OutputIterator transform(const InputRange& range, OutputIterator result, UnaryOperation op)
00064 {
00065     return adobe::transform(boost::begin(range), boost::end(range), result, op);
00066 }
00067     
00068 
00074 template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
00075 inline OutputIterator transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
00076                                 OutputIterator result, BinaryOperation binary_op)
00077 {
00078     return std::transform(  first1, last1, first2, result,
00079                             boost::bind(binary_op, _1, _2));
00080 }
00081 
00087 template <class InputRange1, class InputIterator2, class OutputIterator, class BinaryOperation>
00088 inline OutputIterator transform(InputRange1& range1, InputIterator2 first2, OutputIterator result,
00089                                 BinaryOperation binary_op)
00090 {
00091     return adobe::transform(boost::begin(range1), boost::end(range1), first2, result, binary_op);
00092 }
00093     
00099 template <class InputRange1, class InputIterator2, class OutputIterator, class BinaryOperation>
00100 inline OutputIterator transform(const InputRange1& range1, InputIterator2 first2,
00101                                 OutputIterator result, BinaryOperation binary_op)
00102 {
00103     return adobe::transform(boost::begin(range1), boost::end(range1), first2, result, binary_op);
00104 }
00105 
00106 /*************************************************************************************************/
00107 
00108 } // namespace adobe
00109 
00110 /*************************************************************************************************/
00111 
00112 #endif
00113 
00114 /*************************************************************************************************/

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