stlab.adobe.com Adobe Systems Incorporated

search.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_SEARCH_HPP
00010 #define ADOBE_ALGORITHM_SEARCH_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 ForwardRange1, class ForwardRange2>
00040 inline typename boost::range_const_iterator<ForwardRange1>::type
00041 search(const ForwardRange1& range1, const ForwardRange2& range2)
00042 {
00043     return std::search(boost::begin(range1), boost::end(range1),
00044                        boost::begin(range2), boost::end(range2));
00045 }
00046 
00052 template <class ForwardRange1, class ForwardRange2>
00053 inline typename boost::range_iterator<ForwardRange1>::type
00054 search(ForwardRange1& range1, const ForwardRange2& range2)
00055 {
00056     return std::search(boost::begin(range1), boost::end(range1),
00057                        boost::begin(range2), boost::end(range2));
00058 }
00059 
00065 template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
00066 inline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1, 
00067                                ForwardIterator2 first2, ForwardIterator2 last2,
00068                                BinaryPredicate pred)
00069 {
00070     return std::search(first1, last1, first2, last2, boost::bind(pred, _1, _2));
00071 }
00072 
00078 template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
00079 inline typename boost::range_iterator<ForwardRange1>::type search(ForwardRange1& range1,
00080                                                                   const ForwardRange2& range2,
00081                                                                   BinaryPredicate pred)
00082 {
00083     return adobe::search(boost::begin(range1), boost::end(range1),
00084                          boost::begin(range2), boost::end(range2),
00085                          pred);
00086 }
00087 
00093 template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
00094 inline typename boost::range_const_iterator<ForwardRange1>::type search(const ForwardRange1& range1,
00095                                                                         const ForwardRange2& range2,
00096                                                                         BinaryPredicate      pred)
00097 {
00098     return adobe::search(boost::begin(range1), boost::end(range1),
00099                          boost::begin(range2), boost::end(range2),
00100                          pred);
00101 }
00102 
00108 template <class ForwardRange, class Size, class T>
00109 inline typename boost::range_iterator<ForwardRange>::type
00110 search_n(ForwardRange& range, Size count, const T& value)
00111 {
00112     return std::search_n(boost::begin(range), boost::end(range), count, value);
00113 }
00114 
00120 template <class ForwardRange, class Size, class T>
00121 inline typename boost::range_const_iterator<ForwardRange>::type
00122 search_n(const ForwardRange& range, Size count, const T& value)
00123 {
00124     return std::search_n(boost::begin(range), boost::end(range), count, value);
00125 }
00126 
00132 template <class ForwardIterator, class Size, class T, class BinaryPredicate>
00133 inline ForwardIterator
00134 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value, BinaryPredicate pred)
00135 {
00136     return std::search_n(first, last, count, value, boost::bind(pred, _1, _2));
00137 }
00138 
00144 template <class ForwardRange, class Size, class T, class BinaryPredicate>
00145 inline typename boost::range_iterator<ForwardRange>::type
00146 search_n(ForwardRange& range, Size count, const T& value, BinaryPredicate pred)
00147 {
00148     return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
00149 }
00150 
00156 template <class ForwardRange, class Size, class T, class BinaryPredicate>
00157 inline typename boost::range_const_iterator<ForwardRange>::type
00158 search_n(const ForwardRange& range, Size count, const T& value, BinaryPredicate pred)
00159 {
00160     return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
00161 }
00162 
00163 /*************************************************************************************************/
00164 
00165 } // namespace adobe
00166 
00167 /*************************************************************************************************/
00168 
00169 #endif
00170 
00171 /*************************************************************************************************/

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