2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2019-01-07 08:47:17 +00:00
|
|
|
Copyright (c) 2011-2019 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2013-01-26 12:30:29 +00:00
|
|
|
#ifndef SPROUT_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP
|
|
|
|
#define SPROUT_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/iterator/operation.hpp>
|
|
|
|
#include <sprout/functional/less.hpp>
|
2013-02-07 14:12:57 +00:00
|
|
|
#include <sprout/utility/pair/pair.hpp>
|
2013-01-26 12:30:29 +00:00
|
|
|
#include <sprout/algorithm/find_symmetric_difference.hpp>
|
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
//
|
|
|
|
// next_symmetric_difference
|
|
|
|
//
|
|
|
|
// recursion depth:
|
|
|
|
// O(log(N1+N2))
|
|
|
|
//
|
|
|
|
template<typename InputIterator1, typename InputIterator2, typename Compare>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
|
|
|
next_symmetric_difference(
|
|
|
|
InputIterator1 first1, InputIterator1 last1,
|
|
|
|
InputIterator2 first2, InputIterator2 last2,
|
|
|
|
Compare comp
|
|
|
|
)
|
|
|
|
{
|
|
|
|
typedef sprout::pair<InputIterator1, InputIterator2> type;
|
|
|
|
return first1 != last1
|
|
|
|
? first2 != last2
|
|
|
|
? comp(*first1, *first2)
|
|
|
|
? sprout::find_symmetric_difference(sprout::next(first1), last1, first2, last2, comp)
|
|
|
|
: sprout::find_symmetric_difference(first1, last1, sprout::next(first2), last2, comp)
|
|
|
|
: type(sprout::next(first1), first2)
|
|
|
|
: first2 != last2
|
|
|
|
? type(first1, sprout::next(first2))
|
|
|
|
: type(last1, last2)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
template<typename InputIterator1, typename InputIterator2>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
|
|
|
next_symmetric_difference(
|
|
|
|
InputIterator1 first1, InputIterator1 last1,
|
|
|
|
InputIterator2 first2, InputIterator2 last2
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return sprout::next_symmetric_difference(first1, last1, first2, last2, sprout::less<>());
|
|
|
|
}
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP
|