stlab.adobe.com Adobe Systems Incorporated

find_match.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_FIND_MATCH_HPP
00010 #define ADOBE_ALGORITHM_FIND_MATCH_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 /*************************************************************************************************/
00035 /*************************************************************************************************/
00041 template <class InputIterator, class T, class Compare>
00042 inline InputIterator
00043 find_match(InputIterator first, InputIterator last, const T& value, Compare comp)
00044 {
00045     return std::find_if(first, last, boost::bind(comp, value, _1));
00046 }
00047 
00053 template <class InputRange, class T, class Compare>
00054 inline typename boost::range_iterator<InputRange>::type
00055 find_match(InputRange& range, const T& value, Compare comp)
00056 {
00057     return adobe::find_match(boost::begin(range), boost::end(range), value, comp);
00058 }
00059 
00065 template <class InputRange, class T, class Compare>
00066 inline typename boost::range_const_iterator<InputRange>::type
00067 find_match(const InputRange& range, const T& value, Compare comp)
00068 {
00069     return adobe::find_match(boost::begin(range), boost::end(range), value, comp);
00070 }
00071 
00077 template <class InputIterator, class T, class Compare>
00078 inline InputIterator find_match(InputIterator first, InputIterator last, const T& value)
00079 {
00080     return std::find_if(first, last, boost::bind(std::equal_to<T>(), value, _1));
00081 }
00082 
00088 template <class InputRange, class T, class Compare>
00089 inline typename boost::range_iterator<InputRange>::type
00090 find_match(InputRange& range, const T& value)
00091 {
00092     return adobe::find_match(boost::begin(range), boost::end(range), value);
00093 }
00094 
00100 template <class InputRange, class T, class Compare>
00101 inline typename boost::range_const_iterator<InputRange>::type
00102 find_match(const InputRange& range, const T& value)
00103 {
00104     return adobe::find_match(boost::begin(range), boost::end(range), value);
00105 }
00106 
00107 
00108 /*************************************************************************************************/
00109 
00110 } // namespace adobe
00111 
00112 /*************************************************************************************************/
00113 
00114 #endif
00115 
00116 /*************************************************************************************************/

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