2012-04-01 13:15:09 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_SEARCH_N_HPP
|
|
|
|
#define SPROUT_ALGORITHM_SEARCH_N_HPP
|
|
|
|
|
2013-01-10 17:55:19 +00:00
|
|
|
#include <iterator>
|
2012-04-01 13:15:09 +00:00
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/operation.hpp>
|
2012-12-13 09:08:59 +00:00
|
|
|
#include <sprout/iterator/value_iterator.hpp>
|
|
|
|
#include <sprout/functional/equal_to.hpp>
|
|
|
|
#include <sprout/algorithm/search.hpp>
|
2012-04-01 13:15:09 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
// 25.2.13 Search
|
2012-12-13 09:08:59 +00:00
|
|
|
//
|
|
|
|
// recursion depth:
|
2013-01-10 17:55:19 +00:00
|
|
|
// O(log(N1+N2))
|
2012-12-13 09:08:59 +00:00
|
|
|
//
|
|
|
|
template<typename ForwardIterator, typename Size, typename T, typename BinaryPredicate>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR ForwardIterator
|
2012-12-13 09:08:59 +00:00
|
|
|
search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value, BinaryPredicate pred) {
|
|
|
|
typedef sprout::value_iterator<T const&> iterator;
|
|
|
|
return sprout::search(
|
|
|
|
first, last,
|
2013-01-10 17:55:19 +00:00
|
|
|
iterator(value, static_cast<typename std::iterator_traits<iterator>::difference_type>(count)), iterator(value, 0),
|
2012-12-13 09:08:59 +00:00
|
|
|
pred
|
|
|
|
);
|
2012-04-01 13:15:09 +00:00
|
|
|
}
|
|
|
|
|
2012-12-13 09:08:59 +00:00
|
|
|
template<typename ForwardIterator, typename Size, typename T>
|
2012-10-06 04:53:07 +00:00
|
|
|
inline SPROUT_CONSTEXPR ForwardIterator
|
2012-12-13 09:08:59 +00:00
|
|
|
search_n(ForwardIterator first, ForwardIterator last, Size count, T const& value) {
|
|
|
|
return sprout::search_n(first, last, count, value, sprout::equal_to<>());
|
2012-04-01 13:15:09 +00:00
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_SEARCH_N_HPP
|