1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-12-03 21:15:42 +00:00
Sprout/sprout/detail/algorithm/set_overlap_count.hpp

55 lines
1.8 KiB
C++
Raw Normal View History

2012-06-23 23:22:12 +00:00
#ifndef SPROUT_DETAIL_ALGORITHM_SET_OVERLAP_COUNT_HPP
#define SPROUT_DETAIL_ALGORITHM_SET_OVERLAP_COUNT_HPP
2012-06-23 04:22:50 +00:00
#include <iterator>
#include <sprout/config.hpp>
#include <sprout/iterator/operation.hpp>
namespace sprout {
namespace detail {
//
// set_overlap_count
//
template<typename InputIterator1, typename InputIterator2, typename Compare>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator1>::difference_type set_overlap_count(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
InputIterator2 last2,
Compare comp
)
{
return first1 != last1 && first2 != last2
? comp(*first1, *first2)
? sprout::detail::set_overlap_count(sprout::next(first1), last1, first2, last2, comp)
: comp(*first2, *first1)
? sprout::detail::set_overlap_count(first1, last1, sprout::next(first2), last2, comp)
: 1 + sprout::detail::set_overlap_count(sprout::next(first1), last1, sprout::next(first2), last2, comp)
: 0
;
}
//
// set_overlap_count
//
template<typename InputIterator1, typename InputIterator2>
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator1>::difference_type set_overlap_count(
InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
InputIterator2 last2
)
{
return first1 != last1 && first2 != last2
? *first1 < *first2
? sprout::detail::set_overlap_count(sprout::next(first1), last1, first2, last2)
: *first2 < *first1
? sprout::detail::set_overlap_count(first1, last1, sprout::next(first2), last2)
: 1 + sprout::detail::set_overlap_count(sprout::next(first1), last1, sprout::next(first2), last2)
: 0
;
}
} // namespace detail
} // namespace sprout
2012-06-23 23:22:12 +00:00
#endif // #ifndef SPROUT_DETAIL_ALGORITHM_SET_OVERLAP_COUNT_HPP