stlab.adobe.com Adobe Systems Incorporated

unique.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_UNIQUE_HPP
00010 #define ADOBE_ALGORITHM_UNIQUE_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 /*************************************************************************************************/
00033 /*************************************************************************************************/
00039 template <class ForwardRange>
00040 inline typename boost::range_iterator<ForwardRange>::type unique(ForwardRange& range)
00041 {
00042     return std::unique(boost::begin(range), boost::end(range));
00043 }
00044 
00050 template <class ForwardIterator, class BinaryPredicate>
00051 inline ForwardIterator unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred)
00052 {
00053     return std::unique(first, last, boost::bind(pred, _1, _2));
00054 }
00055 
00061 template <class ForwardRange, class BinaryPredicate>
00062 inline typename boost::range_iterator<ForwardRange>::type unique(ForwardRange& range, BinaryPredicate pred)
00063 {
00064     return adobe::unique(boost::begin(range), boost::end(range), pred);
00065 }
00066 
00072 template <class InputRange, class OutputIterator>
00073 inline OutputIterator unique_copy(InputRange& range, OutputIterator result)
00074 {
00075     return std::unique_copy(boost::begin(range), boost::end(range), result);
00076 }
00077 
00083 template <class InputRange, class OutputIterator>
00084 inline OutputIterator unique_copy(const InputRange& range, OutputIterator result)
00085 {
00086     return std::unique_copy(boost::begin(range), boost::end(range), result);
00087 }
00088 
00094 template <class InputIterator, class OutputIterator, class BinaryPredicate>
00095 inline OutputIterator unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred)
00096 {
00097     return std::unique_copy(first, last, result, boost::bind(pred, _1, _2));
00098 }
00099 
00105 template <class InputRange, class OutputIterator, class BinaryPredicate>
00106 inline OutputIterator unique_copy(InputRange& range, OutputIterator result, BinaryPredicate pred)
00107 {
00108     return adobe::unique_copy(boost::begin(range), boost::end(range), result, pred);
00109 }
00110 
00116 template <class InputRange, class OutputIterator, class BinaryPredicate>
00117 inline OutputIterator unique_copy(const InputRange& range, OutputIterator result, BinaryPredicate pred)
00118 {
00119     return adobe::unique_copy(boost::begin(range), boost::end(range), result, pred);
00120 }
00121 
00122 /*************************************************************************************************/
00123 
00124 } // namespace adobe
00125 
00126 /*************************************************************************************************/
00127 
00128 #endif
00129 
00130 /*************************************************************************************************/

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