Sprout/sprout/detail/algorithm/set_overlap_count.hpp

53 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>
2012-10-05 15:58:56 +00:00
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator1>::difference_type
set_overlap_count(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
2012-06-23 04:22:50 +00:00
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>
2012-10-05 15:58:56 +00:00
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator1>::difference_type
set_overlap_count(
InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2
2012-06-23 04:22:50 +00:00
)
{
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