stlab.adobe.com Adobe Systems Incorporated
unique.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_UNIQUE_HPP
10 #define ADOBE_ALGORITHM_UNIQUE_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 /*************************************************************************************************/
33 /*************************************************************************************************/
39 template <class ForwardRange>
40 inline typename boost::range_iterator<ForwardRange>::type unique(ForwardRange& range)
41 {
42  return std::unique(boost::begin(range), boost::end(range));
43 }
44 
50 template <class ForwardIterator, class BinaryPredicate>
51 inline ForwardIterator unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred)
52 {
53  return std::unique(first, last, boost::bind(pred, _1, _2));
54 }
55 
61 template <class ForwardRange, class BinaryPredicate>
62 inline typename boost::range_iterator<ForwardRange>::type unique(ForwardRange& range, BinaryPredicate pred)
63 {
64  return adobe::unique(boost::begin(range), boost::end(range), pred);
65 }
66 
72 template <class InputRange, class OutputIterator>
73 inline OutputIterator unique_copy(InputRange& range, OutputIterator result)
74 {
75  return std::unique_copy(boost::begin(range), boost::end(range), result);
76 }
77 
83 template <class InputRange, class OutputIterator>
84 inline OutputIterator unique_copy(const InputRange& range, OutputIterator result)
85 {
86  return std::unique_copy(boost::begin(range), boost::end(range), result);
87 }
88 
94 template <class InputIterator, class OutputIterator, class BinaryPredicate>
95 inline OutputIterator unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred)
96 {
97  return std::unique_copy(first, last, result, boost::bind(pred, _1, _2));
98 }
99 
105 template <class InputRange, class OutputIterator, class BinaryPredicate>
106 inline OutputIterator unique_copy(InputRange& range, OutputIterator result, BinaryPredicate pred)
107 {
108  return adobe::unique_copy(boost::begin(range), boost::end(range), result, pred);
109 }
110 
116 template <class InputRange, class OutputIterator, class BinaryPredicate>
117 inline OutputIterator unique_copy(const InputRange& range, OutputIterator result, BinaryPredicate pred)
118 {
119  return adobe::unique_copy(boost::begin(range), boost::end(range), result, pred);
120 }
121 
122 /*************************************************************************************************/
123 
124 } // namespace adobe
125 
126 /*************************************************************************************************/
127 
128 #endif
129 
130 /*************************************************************************************************/

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