mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
support STL container: set operation algorithms
This commit is contained in:
parent
ee8602f6a3
commit
271f348972
17 changed files with 1488 additions and 76 deletions
49
sprout/algorithm/next_union.hpp
Normal file
49
sprout/algorithm/next_union.hpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef SPROUT_ALGORITHM_NEXT_UNION_HPP
|
||||
#define SPROUT_ALGORITHM_NEXT_UNION_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// next_union
|
||||
//
|
||||
// recursion depth:
|
||||
// O(1)
|
||||
//
|
||||
template<typename InputIterator1, typename InputIterator2, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
||||
next_union(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator1, InputIterator2> type;
|
||||
return first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? type(sprout::next(first1), first2)
|
||||
: comp(*first2, *first1)
|
||||
? type(first1, sprout::next(first2))
|
||||
: type(sprout::next(first1), sprout::next(first2))
|
||||
: 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_union(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
InputIterator2 first2, InputIterator2 last2
|
||||
)
|
||||
{
|
||||
return sprout::next_union(first1, last1, first2, last2, sprout::less<>());
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_NEXT_UNION_HPP
|
Loading…
Add table
Add a link
Reference in a new issue