Adobe Source Libraries 2.0.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
search.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_SEARCH_HPP
9#define ADOBE_ALGORITHM_SEARCH_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15
16#include <algorithm>
17#include <functional>
18
19/**************************************************************************************************/
20
21namespace adobe {
22
23/**************************************************************************************************/
32/**************************************************************************************************/
38template <class ForwardRange1, class ForwardRange2>
39inline typename boost::range_const_iterator<ForwardRange1>::type
40search(const ForwardRange1& range1, const ForwardRange2& range2) {
41 return std::search(boost::begin(range1), boost::end(range1), boost::begin(range2),
42 boost::end(range2));
43}
44
50template <class ForwardRange1, class ForwardRange2>
51inline typename boost::range_iterator<ForwardRange1>::type search(ForwardRange1& range1,
52 const ForwardRange2& range2) {
53 return std::search(boost::begin(range1), boost::end(range1), boost::begin(range2),
54 boost::end(range2));
55}
56
62template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
63inline ForwardIterator1 search(ForwardIterator1 first1, ForwardIterator1 last1,
64 ForwardIterator2 first2, ForwardIterator2 last2,
65 BinaryPredicate pred) {
66 return std::search(first1, last1, first2, last2,
67 std::bind(pred, std::placeholders::_1, std::placeholders::_2));
68}
69
75template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
76inline typename boost::range_iterator<ForwardRange1>::type
77search(ForwardRange1& range1, const ForwardRange2& range2, BinaryPredicate pred) {
78 return adobe::search(boost::begin(range1), boost::end(range1), boost::begin(range2),
79 boost::end(range2), pred);
80}
81
87template <class ForwardRange1, class ForwardRange2, class BinaryPredicate>
88inline typename boost::range_const_iterator<ForwardRange1>::type
89search(const ForwardRange1& range1, const ForwardRange2& range2, BinaryPredicate pred) {
90 return adobe::search(boost::begin(range1), boost::end(range1), boost::begin(range2),
91 boost::end(range2), pred);
92}
93
99template <class ForwardRange, class Size, class T>
100inline typename boost::range_iterator<ForwardRange>::type search_n(ForwardRange& range, Size count,
101 const T& value) {
102 return std::search_n(boost::begin(range), boost::end(range), count, value);
103}
104
110template <class ForwardRange, class Size, class T>
111inline typename boost::range_const_iterator<ForwardRange>::type
112search_n(const ForwardRange& range, Size count, const T& value) {
113 return std::search_n(boost::begin(range), boost::end(range), count, value);
114}
115
121template <class ForwardIterator, class Size, class T, class BinaryPredicate>
122inline ForwardIterator search_n(ForwardIterator first, ForwardIterator last, Size count,
123 const T& value, BinaryPredicate pred) {
124 return std::search_n(first, last, count, value,
125 std::bind(pred, std::placeholders::_1, std::placeholders::_2));
126}
127
133template <class ForwardRange, class Size, class T, class BinaryPredicate>
134inline typename boost::range_iterator<ForwardRange>::type
135search_n(ForwardRange& range, Size count, const T& value, BinaryPredicate pred) {
136 return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
137}
138
144template <class ForwardRange, class Size, class T, class BinaryPredicate>
145inline typename boost::range_const_iterator<ForwardRange>::type
146search_n(const ForwardRange& range, Size count, const T& value, BinaryPredicate pred) {
147 return adobe::search_n(boost::begin(range), boost::end(range), count, value, pred);
148}
149
150/**************************************************************************************************/
151
152} // namespace adobe
153
154/**************************************************************************************************/
155
156#endif
157
158/**************************************************************************************************/
boost::range_difference< InputRange >::type count(InputRange &range, T &value)
count implementation
Definition count.hpp:40
boost::range_iterator< ForwardRange >::type search_n(ForwardRange &range, Size count, const T &value)
search implementation
Definition search.hpp:100
boost::range_const_iterator< ForwardRange1 >::type search(const ForwardRange1 &range1, const ForwardRange2 &range2)
search implementation
Definition search.hpp:40