1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/detail/overlap_count_2.hpp

55 lines
1.7 KiB
C++
Raw Normal View History

2011-09-01 02:48:32 +00:00
#ifndef SPROUT_DETAIL_OVERLAP_COUNT_2_HPP
#define SPROUT_DETAIL_OVERLAP_COUNT_2_HPP
#include <iterator>
#include <sprout/config.hpp>
2011-10-01 15:19:13 +00:00
#include <sprout/iterator/operation.hpp>
2011-09-01 02:48:32 +00:00
namespace sprout {
namespace detail {
//
// overlap_count_2
//
template<typename Iterator1, typename Iterator2, typename Compare>
inline SPROUT_CONSTEXPR typename std::iterator_traits<Iterator1>::difference_type overlap_count_2(
2011-09-01 02:48:32 +00:00
Iterator1 first1,
Iterator1 last1,
Iterator2 first2,
Iterator2 last2,
Compare comp
)
{
return first1 != last1 && first2 != last2
? comp(*first1, *first2)
2011-10-01 15:19:13 +00:00
? sprout::detail::overlap_count_2(sprout::next(first1), last1, first2, last2, comp)
2011-09-01 02:48:32 +00:00
: comp(*first2, *first1)
2011-10-01 15:19:13 +00:00
? sprout::detail::overlap_count_2(first1, last1, sprout::next(first2), last2, comp)
: 1 + sprout::detail::overlap_count_2(sprout::next(first1), last1, sprout::next(first2), last2, comp)
2011-09-01 02:48:32 +00:00
: 0
;
}
//
// overlap_count_2
//
template<typename Iterator1, typename Iterator2>
inline SPROUT_CONSTEXPR typename std::iterator_traits<Iterator1>::difference_type overlap_count_2(
2011-09-01 02:48:32 +00:00
Iterator1 first1,
Iterator1 last1,
Iterator2 first2,
Iterator2 last2
)
{
return first1 != last1 && first2 != last2
? *first1 < *first2
2011-10-01 15:19:13 +00:00
? sprout::detail::overlap_count_2(sprout::next(first1), last1, first2, last2)
2011-09-01 02:48:32 +00:00
: *first2 < *first1
2011-10-01 15:19:13 +00:00
? sprout::detail::overlap_count_2(first1, last1, sprout::next(first2), last2)
: 1 + sprout::detail::overlap_count_2(sprout::next(first1), last1, sprout::next(first2), last2)
2011-09-01 02:48:32 +00:00
: 0
;
}
} // namespace detail
} // namespace sprout
#endif // #ifndef SPROUT_DETAIL_OVERLAP_COUNT_2_HPP