8#ifndef ADOBE_ALGORITHM_FIND_HPP
9#define ADOBE_ALGORITHM_FIND_HPP
17#include <boost/next_prior.hpp>
18#include <boost/range/begin.hpp>
19#include <boost/range/end.hpp>
78template <
class InputIterator,
class Predicate>
79inline InputIterator
find_if_not(InputIterator first, InputIterator last, Predicate pred) {
80 return std::find_if_not(first, last, std::bind(pred, std::placeholders::_1));
88template <
class InputRange,
class Predicate>
89inline typename boost::range_iterator<InputRange>::type
find_if_not(InputRange& range,
99template <
class InputRange,
class Predicate>
100inline typename boost::range_const_iterator<InputRange>::type
find_if_not(
const InputRange& range,
110template <
class InputIterator,
class T>
111inline InputIterator
find_not(InputIterator first, InputIterator last,
const T& value) {
112 return std::find_if_not(first, last,
113 std::bind(std::equal_to<T>(), value, std::placeholders::_1));
121template <
class InputRange,
class T>
122inline typename boost::range_iterator<InputRange>::type
find_not(InputRange& range,
132template <
class InputRange,
class T>
133inline typename boost::range_const_iterator<InputRange>::type
find_not(
const InputRange& range,
143template <
class InputRange,
class T>
144inline typename boost::range_iterator<InputRange>::type
find(InputRange& range,
const T& value) {
145 return std::find(boost::begin(range), boost::end(range), value);
153template <
class InputRange,
class T>
154inline typename boost::range_const_iterator<InputRange>::type
find(
const InputRange& range,
156 return std::find(boost::begin(range), boost::end(range), value);
164template <
class InputIterator,
class Predicate>
165inline InputIterator
find_if(InputIterator first, InputIterator last, Predicate pred) {
166 return std::find_if(first, last, std::bind(pred, std::placeholders::_1));
174template <
class InputRange,
class Predicate>
175inline typename boost::range_iterator<InputRange>::type
find_if(InputRange& range, Predicate pred) {
176 return adobe::find_if(boost::begin(range), boost::end(range), pred);
184template <
class InputRange,
class Predicate>
185inline typename boost::range_const_iterator<InputRange>::type
find_if(
const InputRange& range,
187 return adobe::find_if(boost::begin(range), boost::end(range), pred);
198 f = std::find(f, l, x);
201 return std::make_pair(f, l);
215 return std::make_pair(f, l);
223template <
class ForwardRange1,
class ForwardRange2>
224inline typename boost::range_iterator<ForwardRange1>::type
find_end(ForwardRange1& range1,
225 const ForwardRange2& range2) {
226 return std::find_end(boost::begin(range1), boost::end(range1), boost::begin(range2),
235template <
class ForwardRange1,
class ForwardRange2>
236inline typename boost::range_const_iterator<ForwardRange1>::type
237find_end(
const ForwardRange1& range1,
const ForwardRange2& range2) {
238 return std::find_end(boost::begin(range1), boost::end(range1), boost::begin(range2),
247template <
class ForwardIterator1,
class ForwardIterator2,
class BinaryPredicate>
248inline ForwardIterator1
find_end(ForwardIterator1 first1, ForwardIterator1 last1,
249 ForwardIterator2 first2, ForwardIterator2 last2,
250 BinaryPredicate comp) {
251 return std::find_end(first1, last1, first2, last2,
252 std::bind(comp, std::placeholders::_1, std::placeholders::_2));
260template <
class ForwardRange1,
class ForwardRange2,
class BinaryPredicate>
261inline typename boost::range_iterator<ForwardRange1>::type
262find_end(ForwardRange1& range1,
const ForwardRange2& range2, BinaryPredicate comp) {
263 return adobe::find_end(boost::begin(range1), boost::end(range1), boost::begin(range2),
264 boost::end(range2), comp);
272template <
class ForwardRange1,
class ForwardRange2,
class BinaryPredicate>
273inline typename boost::range_const_iterator<ForwardRange1>::type
274find_end(
const ForwardRange1& range1,
const ForwardRange2& range2, BinaryPredicate comp) {
275 return adobe::find_end(boost::begin(range1), boost::end(range1), boost::begin(range2),
276 boost::end(range2), comp);
288template <
class InputRange,
class ForwardRange>
289inline typename boost::range_iterator<InputRange>::type
290find_first_of(InputRange& range1,
const ForwardRange& range2)
292 return std::find_first_of(boost::begin(range1), boost::end(range1),
293 boost::begin(range2), boost::end(range2));
301template <
class InputRange,
class ForwardRange>
302inline typename boost::range_const_iterator<InputRange>::type
303find_first_of(
const InputRange& range1,
const ForwardRange& range2)
305 return std::find_first_of(boost::begin(range1), boost::end(range1),
306 boost::begin(range2), boost::end(range2));
314template <
class InputIterator,
class ForwardIterator,
class BinaryPredicate>
315inline InputIterator find_first_of(InputIterator first1, InputIterator last1,
316 ForwardIterator first2, ForwardIterator last2,
317 BinaryPredicate comp)
320 return std::find_first_of(first1, last1, first2, last2, std::bind(comp, std::placeholders::_1, std::placeholders::_2));
328template <
class InputRange,
class ForwardRange,
class BinaryPredicate>
329inline typename boost::range_iterator<InputRange>::type
330find_first_of(InputRange& range1,
const ForwardRange& range2, BinaryPredicate comp)
332 return adobe::find_first_of(boost::begin(range1), boost::end(range1),
333 boost::begin(range2), boost::end(range2),
342template <
class InputRange,
class ForwardRange,
class BinaryPredicate>
343inline typename boost::range_const_iterator<InputRange>::type
344find_first_of(
const InputRange& range1,
const ForwardRange& range2, BinaryPredicate comp)
346 return adobe::find_first_of(boost::begin(range1), boost::end(range1),
347 boost::begin(range2), boost::end(range2),
358template <
class ForwardRange>
359inline typename boost::range_iterator<ForwardRange>::type
adjacent_find(ForwardRange& range) {
360 return std::adjacent_find(boost::begin(range), boost::end(range));
368template <
class ForwardRange>
369inline typename boost::range_const_iterator<ForwardRange>::type
371 return std::adjacent_find(boost::begin(range), boost::end(range));
379template <
class ForwardIterator,
class BinaryPredicate>
380inline ForwardIterator
adjacent_find(ForwardIterator first, ForwardIterator last,
381 BinaryPredicate pred) {
382 return std::adjacent_find(first, last,
383 std::bind(pred, std::placeholders::_1, std::placeholders::_2));
391template <
class ForwardRange,
class BinaryPredicate>
392inline typename boost::range_iterator<ForwardRange>::type
adjacent_find(ForwardRange& range,
393 BinaryPredicate pred) {
402template <
class ForwardRange,
class BinaryPredicate>
403inline typename boost::range_const_iterator<ForwardRange>::type
InputIterator find_if_not(InputIterator first, InputIterator last, Predicate pred)
find_if_not implementation
InputIterator find_not(InputIterator first, InputIterator last, const T &value)
boost::range_iterator< ForwardRange >::type adjacent_find(ForwardRange &range)
find implementation
boost::range_iterator< ForwardRange1 >::type find_end(ForwardRange1 &range1, const ForwardRange2 &range2)
find implementation
std::pair< I, I > find_range(I f, I l, const T &x)
std::pair< I, I > find_range_if(I f, I l, P p)
InputIterator find_if(InputIterator first, InputIterator last, Predicate pred)
find implementation
boost::range_iterator< InputRange >::type find(InputRange &range, const T &value)
find implementation