stlab.adobe.com Adobe Systems Incorporated
search.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_SEARCH_HPP
10 #define ADOBE_ALGORITHM_SEARCH_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 ForwardRange1, class ForwardRange2>
40 inline typename boost::range_const_iterator<ForwardRange1>::type
41 search(const ForwardRange1& range1, const ForwardRange2& range2)
42 {
43  return std::search(boost::begin(range1), boost::end(range1),
44  boost::begin(range2), boost::end(range2));
45 }
46 
52 template <class ForwardRange1, class ForwardRange2>
53 inline typename boost::range_iterator<ForwardRange1>::type
54 search(ForwardRange1& range1, const ForwardRange2& range2)
55 {
56  return std::search(boost::begin(range1), boost::end(range1),
57  boost::begin(range2), boost::end(range2));
58 }
59 
65 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
66 inline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1,
67  ForwardIterator2 first2, ForwardIterator2 last2,
68  BinaryPredicate pred)
69 {
70  return std::search(first1, last1, first2, last2, boost::bind(pred, _1, _2));
71 }
72 
78 template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
79 inline typename boost::range_iterator<ForwardRange1>::type search(ForwardRange1& range1,
80  const ForwardRange2& range2,
81  BinaryPredicate pred)
82 {
83  return adobe::search(boost::begin(range1), boost::end(range1),
84  boost::begin(range2), boost::end(range2),
85  pred);
86 }
87 
93 template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
94 inline typename boost::range_const_iterator<ForwardRange1>::type search(const ForwardRange1& range1,
95  const ForwardRange2& range2,
96  BinaryPredicate pred)
97 {
98  return adobe::search(boost::begin(range1), boost::end(range1),
99  boost::begin(range2), boost::end(range2),
100  pred);
101 }
102 
108 template <class ForwardRange, class Size, class T>
109 inline typename boost::range_iterator<ForwardRange>::type
110 search_n(ForwardRange& range, Size count, const T& value)
111 {
112  return std::search_n(boost::begin(range), boost::end(range), count, value);
113 }
114 
120 template <class ForwardRange, class Size, class T>
121 inline typename boost::range_const_iterator<ForwardRange>::type
122 search_n(const ForwardRange& range, Size count, const T& value)
123 {
124  return std::search_n(boost::begin(range), boost::end(range), count, value);
125 }
126 
132 template <class ForwardIterator, class Size, class T, class BinaryPredicate>
133 inline ForwardIterator
134 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred)
135 {
136  return std::search_n(first, last, count, value, boost::bind(pred, _1, _2));
137 }
138 
144 template <class ForwardRange, class Size, class T, class BinaryPredicate>
145 inline typename boost::range_iterator<ForwardRange>::type
146 search_n(ForwardRange& range, Size count, const T& value, BinaryPredicate pred)
147 {
148  return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
149 }
150 
156 template <class ForwardRange, class Size, class T, class BinaryPredicate>
157 inline typename boost::range_const_iterator<ForwardRange>::type
158 search_n(const ForwardRange& range, Size count, const T& value, BinaryPredicate pred)
159 {
160  return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
161 }
162 
163 /*************************************************************************************************/
164 
165 } // namespace adobe
166 
167 /*************************************************************************************************/
168 
169 #endif
170 
171 /*************************************************************************************************/
boost::range_difference< InputRange >::type count(InputRange &range, T &value)
count implementation
Definition: count.hpp:41
boost::range_const_iterator< ForwardRange1 >::type search(const ForwardRange1 &range1, const ForwardRange2 &range2, BinaryPredicate pred)
search implementation
Definition: search.hpp:94
boost::range_const_iterator< ForwardRange1 >::type search(const ForwardRange1 &range1, const ForwardRange2 &range2)
search implementation
Definition: search.hpp:41
boost::range_const_iterator< ForwardRange >::type search_n(const ForwardRange &range, Size count, const T &value, BinaryPredicate pred)
search implementation
Definition: search.hpp:158
boost::range_iterator< ForwardRange >::type search_n(ForwardRange &range, Size count, const T &value)
search implementation
Definition: search.hpp:110

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