stlab.adobe.com Adobe Systems Incorporated
sort.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_SORT_HPP
10 #define ADOBE_ALGORITHM_SORT_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 /*************************************************************************************************/
34 /*************************************************************************************************/
40 template <class RandomAccessRange>
41 inline void sort(RandomAccessRange& range)
42 {
43  return std::sort(boost::begin(range), boost::end(range));
44 }
45 
51 template <class RandomAccessIterator, class Compare>
52 inline void sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
53 {
54  return std::sort(first, last, boost::bind(comp, _1, _2));
55 }
56 
62 template <typename I, // I models RandomAccessIterator
63  typename C, // C models StrictWeakOrdering(T, T)
64  typename P> // P models UnaryFunction(value_type(I)) -> T
65 inline void sort(I f, I l, C c, P p)
66 {
67  return std::sort(f, l, boost::bind(c, boost::bind(p, _1), boost::bind(p, _2)));
68 }
69 
75 template <typename R, // I models RandomAccessRange
76  typename C, // C models StrictWeakOrdering(T, T)
77  typename P> // P models UnaryFunction(value_type(I)) -> T
78 inline void sort(R& r, C c, P p)
79 {
80  return adobe::sort(boost::begin(r), boost::end(r), boost::bind(c, boost::bind(p, _1),
81  boost::bind(p, _2)));
82 }
83 
89 template <class RandomAccessRange, class Compare>
90 inline void sort(RandomAccessRange& range, Compare comp)
91 {
92  return adobe::sort(boost::begin(range), boost::end(range), comp);
93 }
94 
100 template <class RandomAccessRange>
101 inline void stable_sort(RandomAccessRange& range)
102 {
103  return std::stable_sort(boost::begin(range), boost::end(range));
104 }
105 
111 template <class RandomAccessIterator, class Compare>
112 inline void stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp)
113 {
114  return std::stable_sort(first, last, boost::bind(comp, _1, _2));
115 }
116 
122 template <class RandomAccessRange, class Compare>
123 inline void stable_sort(RandomAccessRange& range, Compare comp)
124 {
125  return adobe::stable_sort(boost::begin(range), boost::end(range), comp);
126 }
127 
133 template <class InputRange, class RandomAccessRange>
134 inline void partial_sort_copy(InputRange& range, RandomAccessRange& result_range)
135 {
136  return std::partial_sort_copy( boost::begin(range), boost::end(range),
137  boost::begin(result_range), boost::end(result_range));
138 }
139 
145 template <class InputRange, class RandomAccessRange>
146 inline void partial_sort_copy(const InputRange& range, RandomAccessRange& result_range)
147 {
148  return std::partial_sort_copy( boost::begin(range), boost::end(range),
149  boost::begin(result_range), boost::end(result_range));
150 }
151 
157 template <class InputIterator, class RandomAccessIterator, class Compare>
158 inline void partial_sort_copy( InputIterator first, InputIterator last,
159  RandomAccessIterator result_first, RandomAccessIterator result_last,
160  Compare comp)
161 {
162  return std::partial_sort_copy(first, last, result_first, result_last, boost::bind(comp, _1, _2));
163 }
164 
170 template <class InputRange, class RandomAccessRange, class Compare>
171 inline void partial_sort_copy(InputRange& range, RandomAccessRange& result_range, Compare comp)
172 {
173  return adobe::partial_sort_copy(boost::begin(range), boost::end(range),
174  boost::begin(result_range), boost::end(result_range),
175  comp);
176 }
177 
183 template <class InputRange, class RandomAccessRange, class Compare>
184 inline void partial_sort_copy(const InputRange& range, RandomAccessRange& result_range, Compare comp)
185 {
186  return adobe::partial_sort_copy(boost::begin(range), boost::end(range),
187  boost::begin(result_range), boost::end(result_range),
188  comp);
189 }
190 
191 /*************************************************************************************************/
192 
193 } // namespace adobe
194 
195 /*************************************************************************************************/
196 
197 #endif
198 
199 /*************************************************************************************************/

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