mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add range adaptor: merged, set operations
This commit is contained in:
parent
3472e8b94e
commit
9aa2a7c9b2
43 changed files with 1176 additions and 62 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace sprout {
|
|||
private:
|
||||
Predicate pred_;
|
||||
public:
|
||||
SPROUT_CONSTEXPR remove_if_filter(Predicate pred)
|
||||
explicit SPROUT_CONSTEXPR remove_if_filter(Predicate pred)
|
||||
: pred_(pred)
|
||||
{}
|
||||
template<typename U>
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace sprout {
|
|||
private:
|
||||
T value_;
|
||||
public:
|
||||
SPROUT_CONSTEXPR remove_filter(T const& value)
|
||||
explicit SPROUT_CONSTEXPR remove_filter(T const& value)
|
||||
: value_(value)
|
||||
{}
|
||||
template<typename U>
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace sprout {
|
|||
, comp(other.comp)
|
||||
{}
|
||||
public:
|
||||
set_difference_iterator()
|
||||
SPROUT_CONSTEXPR set_difference_iterator()
|
||||
: current(), lst1(), lst2(), comp()
|
||||
{}
|
||||
set_difference_iterator(set_difference_iterator const&) = default;
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace sprout {
|
|||
, comp(other.comp)
|
||||
{}
|
||||
public:
|
||||
set_intersection_iterator()
|
||||
SPROUT_CONSTEXPR set_intersection_iterator()
|
||||
: current(), lst1(), lst2(), comp()
|
||||
{}
|
||||
set_intersection_iterator(set_intersection_iterator const&) = default;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace sprout {
|
|||
protected:
|
||||
bool in_left;
|
||||
protected:
|
||||
set_symmetric_difference_iterator_impl()
|
||||
SPROUT_CONSTEXPR set_symmetric_difference_iterator_impl()
|
||||
: current(), lst1(), lst2(), comp(), in_left(true)
|
||||
{}
|
||||
set_symmetric_difference_iterator_impl(set_symmetric_difference_iterator_impl const&) = default;
|
||||
|
@ -128,7 +128,7 @@ namespace sprout {
|
|||
: impl_type(next, other.lst1, other.lst2, other.comp)
|
||||
{}
|
||||
public:
|
||||
set_symmetric_difference_iterator()
|
||||
SPROUT_CONSTEXPR set_symmetric_difference_iterator()
|
||||
: impl_type()
|
||||
{}
|
||||
set_symmetric_difference_iterator(set_symmetric_difference_iterator const&) = default;
|
||||
|
|
|
@ -69,10 +69,10 @@ namespace sprout {
|
|||
: current(next)
|
||||
, lst1(other.lst1), lst2(other.lst2)
|
||||
, comp(other.comp)
|
||||
, in_left(check_in_left(next.first, lst1, next.second, lst2, comp))
|
||||
, in_left(check_in_left(next.first, other.lst1, next.second, other.lst2, other.comp))
|
||||
{}
|
||||
public:
|
||||
set_union_iterator()
|
||||
SPROUT_CONSTEXPR set_union_iterator()
|
||||
: current(), lst1(), lst2(), comp(), in_left(true)
|
||||
{}
|
||||
set_union_iterator(set_union_iterator const&) = default;
|
||||
|
|
|
@ -2,36 +2,9 @@
|
|||
#define SPROUT_RANGE_ADAPTOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/adaptor/copied.hpp>
|
||||
#include <sprout/range/adaptor/reversed.hpp>
|
||||
#include <sprout/range/adaptor/transformed.hpp>
|
||||
#include <sprout/range/adaptor/replaced.hpp>
|
||||
#include <sprout/range/adaptor/replaced_if.hpp>
|
||||
#include <sprout/range/adaptor/filtered.hpp>
|
||||
#include <sprout/range/adaptor/counting.hpp>
|
||||
#include <sprout/range/adaptor/outdirected.hpp>
|
||||
#include <sprout/range/adaptor/piped.hpp>
|
||||
#include <sprout/range/adaptor/taken.hpp>
|
||||
#include <sprout/range/adaptor/taken_end.hpp>
|
||||
#include <sprout/range/adaptor/dropped.hpp>
|
||||
#include <sprout/range/adaptor/dropped_end.hpp>
|
||||
#include <sprout/range/adaptor/window.hpp>
|
||||
#include <sprout/range/adaptor/offset.hpp>
|
||||
#include <sprout/range/adaptor/adapted_taken.hpp>
|
||||
#include <sprout/range/adaptor/adapted_taken_end.hpp>
|
||||
#include <sprout/range/adaptor/adapted_dropped.hpp>
|
||||
#include <sprout/range/adaptor/adapted_dropped_end.hpp>
|
||||
#include <sprout/range/adaptor/adapted_window.hpp>
|
||||
#include <sprout/range/adaptor/adapted_offset.hpp>
|
||||
#include <sprout/range/adaptor/steps.hpp>
|
||||
#include <sprout/range/adaptor/jointed.hpp>
|
||||
#include <sprout/range/adaptor/alternated.hpp>
|
||||
#include <sprout/range/adaptor/deep_copied.hpp>
|
||||
#include <sprout/range/adaptor/indexed.hpp>
|
||||
#include <sprout/range/adaptor/valued.hpp>
|
||||
#include <sprout/range/adaptor/blanked.hpp>
|
||||
#include <sprout/range/adaptor/sized.hpp>
|
||||
#include <sprout/range/adaptor/size_enumed.hpp>
|
||||
#include <sprout/range/adaptor/modifying.hpp>
|
||||
#include <sprout/range/adaptor/reduction.hpp>
|
||||
#include <sprout/range/adaptor/various.hpp>
|
||||
#include <sprout/range/adaptor/wave.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_HPP
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/iterator/next.hpp>
|
||||
#include <sprout/iterator/alternate_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/transform_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/iterator/value_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/clamp_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/iterator/counting_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/dft_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
113
sprout/range/adaptor/filled.hpp
Normal file
113
sprout/range/adaptor/filled.hpp
Normal file
|
@ -0,0 +1,113 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_FILLED_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_BLANKED_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/value_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// filled_range
|
||||
//
|
||||
template<typename Range>
|
||||
class filled_range
|
||||
: public sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::value_iterator<typename sprout::container_traits<Range>::value_type>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::value_iterator<typename sprout::container_traits<Range>::value_type>
|
||||
> base_type;
|
||||
typedef typename base_type::range_type range_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
typedef typename base_type::value_type value_type;
|
||||
public:
|
||||
filled_range() = default;
|
||||
filled_range(filled_range const&) = default;
|
||||
SPROUT_CONSTEXPR filled_range(
|
||||
range_type& range,
|
||||
value_type const& value
|
||||
)
|
||||
: base_type(
|
||||
iterator(value, sprout::size(range)),
|
||||
iterator(value, 0)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// fill_holder
|
||||
//
|
||||
template<typename T>
|
||||
class fill_holder {
|
||||
public:
|
||||
typedef T value_type;
|
||||
private:
|
||||
value_type value_;
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR fill_holder(value_type const& value)
|
||||
: value_(value)
|
||||
{}
|
||||
SPROUT_CONSTEXPR value_type const& value() const {
|
||||
return value_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// filled_forwarder
|
||||
//
|
||||
class filled_forwarder {
|
||||
public:
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::fill_holder<T>
|
||||
operator()(T const& value) const {
|
||||
return sprout::adaptors::fill_holder<T>(value);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// filled
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::filled_forwarder filled = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename Range, typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::filled_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>
|
||||
operator|(Range&& lhs, sprout::adaptors::fill_holder<T> const& rhs) {
|
||||
return sprout::adaptors::filled_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<Range>(lhs),
|
||||
rhs.value()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename Range>
|
||||
struct container_construct_traits<sprout::adaptors::filled_range<Range> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::filled_range<Range>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_BLANKED_HPP
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/filter_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/idft_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/indexed_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/joint_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
152
sprout/range/adaptor/merged.hpp
Normal file
152
sprout/range/adaptor/merged.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_MERGED_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_MERGED_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/merge_iterator.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// merged_range
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare = sprout::less<> >
|
||||
class merged_range
|
||||
: public sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::merge_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::merge_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range1_type range1_type;
|
||||
typedef typename base_type::range2_type range2_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
merged_range() = default;
|
||||
merged_range(merged_range const&) = default;
|
||||
SPROUT_CONSTEXPR merged_range(range1_type& range1, range2_type& range2, Compare comp = Compare())
|
||||
: base_type(
|
||||
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp),
|
||||
iterator(sprout::end(range1), sprout::end(range1), sprout::end(range2), sprout::end(range2), comp)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// merge_holder
|
||||
//
|
||||
template<typename RRange, typename Compare = sprout::less<> >
|
||||
class merge_holder {
|
||||
public:
|
||||
typedef RRange range2_type;
|
||||
typedef Compare compare_type;
|
||||
private:
|
||||
sprout::value_holder<range2_type&> range_;
|
||||
Compare comp_;
|
||||
public:
|
||||
merge_holder() = default;
|
||||
merge_holder(merge_holder const&) = default;
|
||||
explicit SPROUT_CONSTEXPR merge_holder(range2_type& range, Compare comp = Compare())
|
||||
: range_(range)
|
||||
, comp_(comp)
|
||||
{}
|
||||
SPROUT_CONSTEXPR range2_type& range() const {
|
||||
return range_;
|
||||
}
|
||||
SPROUT_CONSTEXPR Compare compare() const {
|
||||
return comp_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// merged_forwarder
|
||||
//
|
||||
class merged_forwarder {
|
||||
public:
|
||||
template<typename RRange>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::merge_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>
|
||||
operator()(RRange&& range) {
|
||||
return sprout::adaptors::merge_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range)
|
||||
);
|
||||
}
|
||||
template<typename RRange, typename Compare>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::merge_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>
|
||||
operator()(RRange&& range, Compare comp) {
|
||||
return sprout::adaptors::merge_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range),
|
||||
comp
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// merged
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::merged_forwarder merged = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::merged_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>
|
||||
operator|(LRange&& lhs, sprout::adaptors::merge_holder<RRange, Compare> const& rhs) {
|
||||
return sprout::adaptors::merged_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<LRange>(lhs),
|
||||
rhs.range(),
|
||||
rhs.compare()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
struct container_construct_traits<sprout::adaptors::merged_range<LRange, RRange, Compare> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::merged_range<LRange, RRange, Compare>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_MERGED_HPP
|
21
sprout/range/adaptor/modifying.hpp
Normal file
21
sprout/range/adaptor/modifying.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_MODIFYING_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_MODIFYING_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/adaptor/copied.hpp>
|
||||
#include <sprout/range/adaptor/transformed.hpp>
|
||||
#include <sprout/range/adaptor/replaced.hpp>
|
||||
#include <sprout/range/adaptor/replaced_if.hpp>
|
||||
#include <sprout/range/adaptor/filled.hpp>
|
||||
#include <sprout/range/adaptor/filtered.hpp>
|
||||
#include <sprout/range/adaptor/removed.hpp>
|
||||
#include <sprout/range/adaptor/removed_if.hpp>
|
||||
#include <sprout/range/adaptor/reversed.hpp>
|
||||
#include <sprout/range/adaptor/merged.hpp>
|
||||
#include <sprout/range/adaptor/set_union.hpp>
|
||||
#include <sprout/range/adaptor/set_intersection.hpp>
|
||||
#include <sprout/range/adaptor/set_difference.hpp>
|
||||
#include <sprout/range/adaptor/set_symmetric_difference.hpp>
|
||||
#include <sprout/range/adaptor/clamped.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_MODIFYING_HPP
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/counting_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/transform_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
18
sprout/range/adaptor/reduction.hpp
Normal file
18
sprout/range/adaptor/reduction.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_REDUCTION_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_REDUCTION_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/adaptor/taken.hpp>
|
||||
#include <sprout/range/adaptor/taken_end.hpp>
|
||||
#include <sprout/range/adaptor/dropped.hpp>
|
||||
#include <sprout/range/adaptor/dropped_end.hpp>
|
||||
#include <sprout/range/adaptor/window.hpp>
|
||||
#include <sprout/range/adaptor/offset.hpp>
|
||||
#include <sprout/range/adaptor/adapted_taken.hpp>
|
||||
#include <sprout/range/adaptor/adapted_taken_end.hpp>
|
||||
#include <sprout/range/adaptor/adapted_dropped.hpp>
|
||||
#include <sprout/range/adaptor/adapted_dropped_end.hpp>
|
||||
#include <sprout/range/adaptor/adapted_window.hpp>
|
||||
#include <sprout/range/adaptor/adapted_offset.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_REDUCTION_HPP
|
116
sprout/range/adaptor/removed.hpp
Normal file
116
sprout/range/adaptor/removed.hpp
Normal file
|
@ -0,0 +1,116 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_REMOVED_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_REMOVED_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/filter_iterator.hpp>
|
||||
#include <sprout/iterator/remove_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// removed_range
|
||||
//
|
||||
template<typename Range>
|
||||
class removed_range
|
||||
: public sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::filter_iterator<
|
||||
sprout::remove_filter<typename sprout::container_traits<Range>::value_type>,
|
||||
typename sprout::container_traits<Range>::iterator
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::filter_iterator<
|
||||
sprout::remove_filter<typename sprout::container_traits<Range>::value_type>,
|
||||
typename sprout::container_traits<Range>::iterator
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range_type range_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
typedef typename base_type::value_type value_type;
|
||||
public:
|
||||
removed_range() = default;
|
||||
removed_range(removed_range const&) = default;
|
||||
SPROUT_CONSTEXPR removed_range(range_type& range, value_type const& value)
|
||||
: base_type(
|
||||
iterator(sprout::begin(range), typename iterator::predicate_type(value)),
|
||||
iterator(sprout::end(range), typename iterator::predicate_type(value))
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// remove_holder
|
||||
//
|
||||
template<typename T>
|
||||
class remove_holder {
|
||||
public:
|
||||
typedef T value_type;
|
||||
private:
|
||||
value_type value_;
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR remove_holder(value_type const& value)
|
||||
: value_(value)
|
||||
{}
|
||||
SPROUT_CONSTEXPR value_type const& value() const {
|
||||
return value_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// removed_forwarder
|
||||
//
|
||||
class removed_forwarder {
|
||||
public:
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::remove_holder<T>
|
||||
operator()(T const& value) {
|
||||
return sprout::adaptors::remove_holder<T>(value);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// removed
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::removed_forwarder removed = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename Range, typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::removed_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>
|
||||
operator|(Range&& lhs, sprout::adaptors::remove_holder<T> const& rhs) {
|
||||
return sprout::adaptors::removed_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<Range>(lhs),
|
||||
rhs.value()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename Range>
|
||||
struct container_construct_traits<sprout::adaptors::removed_range<Range> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::removed_range<Range>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_REMOVED_HPP
|
118
sprout/range/adaptor/removed_if.hpp
Normal file
118
sprout/range/adaptor/removed_if.hpp
Normal file
|
@ -0,0 +1,118 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/filter_iterator.hpp>
|
||||
#include <sprout/iterator/remove_if_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// removed_if_range
|
||||
//
|
||||
template<typename Predicate, typename Range>
|
||||
class removed_if_range
|
||||
: public sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::filter_iterator<
|
||||
sprout::remove_if_filter<Predicate>,
|
||||
typename sprout::container_traits<Range>::iterator
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef Predicate predicate_type;
|
||||
typedef sprout::adaptors::detail::adapted_range_default<
|
||||
Range,
|
||||
sprout::filter_iterator<
|
||||
sprout::remove_if_filter<Predicate>,
|
||||
typename sprout::container_traits<Range>::iterator
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range_type range_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
removed_if_range() = default;
|
||||
removed_if_range(removed_if_range const&) = default;
|
||||
SPROUT_CONSTEXPR removed_if_range(range_type& range, Predicate pred)
|
||||
: base_type(
|
||||
iterator(sprout::begin(range), typename iterator::predicate_type(pred)),
|
||||
iterator(sprout::end(range), typename iterator::predicate_type(pred))
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// remove_if_holder
|
||||
//
|
||||
template<typename Predicate>
|
||||
class remove_if_holder {
|
||||
public:
|
||||
typedef Predicate predicate_type;
|
||||
private:
|
||||
Predicate pred_;
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR remove_if_holder(Predicate pred)
|
||||
: pred_(pred)
|
||||
{}
|
||||
SPROUT_CONSTEXPR Predicate const& predicate() const {
|
||||
return pred_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// removed_if_forwarder
|
||||
//
|
||||
class removed_if_forwarder {
|
||||
public:
|
||||
template<typename Predicate>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::remove_if_holder<Predicate>
|
||||
operator()(Predicate pred) {
|
||||
return sprout::adaptors::remove_if_holder<Predicate>(pred);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// removed_if
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::removed_if_forwarder removed_if = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename Range, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::removed_if_range<
|
||||
Predicate,
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>
|
||||
operator|(Range&& lhs, sprout::adaptors::remove_if_holder<Predicate> const& rhs) {
|
||||
return sprout::adaptors::removed_if_range<
|
||||
Predicate,
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<Range>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<Range>(lhs),
|
||||
rhs.predicate()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename Predicate, typename Range>
|
||||
struct container_construct_traits<sprout::adaptors::removed_if_range<Predicate, Range> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::removed_if_range<Predicate, Range>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_REMOVED_IF_HPP
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/iterator/transform_iterator.hpp>
|
||||
#include <sprout/iterator/replace_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/iterator/transform_iterator.hpp>
|
||||
#include <sprout/iterator/replace_if_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/reverse_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/sawtooth_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
152
sprout/range/adaptor/set_difference.hpp
Normal file
152
sprout/range/adaptor/set_difference.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_SET_DIFFERENCE_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_SET_DIFFERENCE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/set_difference_iterator.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// set_difference_range
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare = sprout::less<> >
|
||||
class set_difference_range
|
||||
: public sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_difference_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_difference_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range1_type range1_type;
|
||||
typedef typename base_type::range2_type range2_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
set_difference_range() = default;
|
||||
set_difference_range(set_difference_range const&) = default;
|
||||
SPROUT_CONSTEXPR set_difference_range(range1_type& range1, range2_type& range2, Compare comp = Compare())
|
||||
: base_type(
|
||||
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp),
|
||||
iterator(sprout::end(range1), sprout::end(range1), sprout::end(range2), sprout::end(range2), comp)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// set_difference_holder
|
||||
//
|
||||
template<typename RRange, typename Compare = sprout::less<> >
|
||||
class set_difference_holder {
|
||||
public:
|
||||
typedef RRange range2_type;
|
||||
typedef Compare compare_type;
|
||||
private:
|
||||
sprout::value_holder<range2_type&> range_;
|
||||
Compare comp_;
|
||||
public:
|
||||
set_difference_holder() = default;
|
||||
set_difference_holder(set_difference_holder const&) = default;
|
||||
explicit SPROUT_CONSTEXPR set_difference_holder(range2_type& range, Compare comp = Compare())
|
||||
: range_(range)
|
||||
, comp_(comp)
|
||||
{}
|
||||
SPROUT_CONSTEXPR range2_type& range() const {
|
||||
return range_;
|
||||
}
|
||||
SPROUT_CONSTEXPR Compare compare() const {
|
||||
return comp_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_difference_forwarder
|
||||
//
|
||||
class set_difference_forwarder {
|
||||
public:
|
||||
template<typename RRange>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>
|
||||
operator()(RRange&& range) {
|
||||
return sprout::adaptors::set_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range)
|
||||
);
|
||||
}
|
||||
template<typename RRange, typename Compare>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>
|
||||
operator()(RRange&& range, Compare comp) {
|
||||
return sprout::adaptors::set_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range),
|
||||
comp
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_difference
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::set_difference_forwarder set_difference = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::set_difference_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>
|
||||
operator|(LRange&& lhs, sprout::adaptors::set_difference_holder<RRange, Compare> const& rhs) {
|
||||
return sprout::adaptors::set_difference_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<LRange>(lhs),
|
||||
rhs.range(),
|
||||
rhs.compare()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
struct container_construct_traits<sprout::adaptors::set_difference_range<LRange, RRange, Compare> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::set_difference_range<LRange, RRange, Compare>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SET_DIFFERENCE_HPP
|
152
sprout/range/adaptor/set_intersection.hpp
Normal file
152
sprout/range/adaptor/set_intersection.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_SET_INTERSECTION_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_SET_INTERSECTION_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/set_intersection_iterator.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// set_intersection_range
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare = sprout::less<> >
|
||||
class set_intersection_range
|
||||
: public sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_intersection_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_intersection_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range1_type range1_type;
|
||||
typedef typename base_type::range2_type range2_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
set_intersection_range() = default;
|
||||
set_intersection_range(set_intersection_range const&) = default;
|
||||
SPROUT_CONSTEXPR set_intersection_range(range1_type& range1, range2_type& range2, Compare comp = Compare())
|
||||
: base_type(
|
||||
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp),
|
||||
iterator(sprout::end(range1), sprout::end(range1), sprout::end(range2), sprout::end(range2), comp)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// set_intersection_holder
|
||||
//
|
||||
template<typename RRange, typename Compare = sprout::less<> >
|
||||
class set_intersection_holder {
|
||||
public:
|
||||
typedef RRange range2_type;
|
||||
typedef Compare compare_type;
|
||||
private:
|
||||
sprout::value_holder<range2_type&> range_;
|
||||
Compare comp_;
|
||||
public:
|
||||
set_intersection_holder() = default;
|
||||
set_intersection_holder(set_intersection_holder const&) = default;
|
||||
explicit SPROUT_CONSTEXPR set_intersection_holder(range2_type& range, Compare comp = Compare())
|
||||
: range_(range)
|
||||
, comp_(comp)
|
||||
{}
|
||||
SPROUT_CONSTEXPR range2_type& range() const {
|
||||
return range_;
|
||||
}
|
||||
SPROUT_CONSTEXPR Compare compare() const {
|
||||
return comp_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_intersection_forwarder
|
||||
//
|
||||
class set_intersection_forwarder {
|
||||
public:
|
||||
template<typename RRange>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_intersection_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>
|
||||
operator()(RRange&& range) {
|
||||
return sprout::adaptors::set_intersection_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range)
|
||||
);
|
||||
}
|
||||
template<typename RRange, typename Compare>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_intersection_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>
|
||||
operator()(RRange&& range, Compare comp) {
|
||||
return sprout::adaptors::set_intersection_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range),
|
||||
comp
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_intersection
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::set_intersection_forwarder set_intersection = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::set_intersection_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>
|
||||
operator|(LRange&& lhs, sprout::adaptors::set_intersection_holder<RRange, Compare> const& rhs) {
|
||||
return sprout::adaptors::set_intersection_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<LRange>(lhs),
|
||||
rhs.range(),
|
||||
rhs.compare()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
struct container_construct_traits<sprout::adaptors::set_intersection_range<LRange, RRange, Compare> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::set_intersection_range<LRange, RRange, Compare>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SET_INTERSECTION_HPP
|
152
sprout/range/adaptor/set_symmetric_difference.hpp
Normal file
152
sprout/range/adaptor/set_symmetric_difference.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_SET_SYMMETRIC_DIFFERENCE_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_SET_SYMMETRIC_DIFFERENCE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/set_symmetric_difference_iterator.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// set_symmetric_difference_range
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare = sprout::less<> >
|
||||
class set_symmetric_difference_range
|
||||
: public sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_symmetric_difference_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_symmetric_difference_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range1_type range1_type;
|
||||
typedef typename base_type::range2_type range2_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
set_symmetric_difference_range() = default;
|
||||
set_symmetric_difference_range(set_symmetric_difference_range const&) = default;
|
||||
SPROUT_CONSTEXPR set_symmetric_difference_range(range1_type& range1, range2_type& range2, Compare comp = Compare())
|
||||
: base_type(
|
||||
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp),
|
||||
iterator(sprout::end(range1), sprout::end(range1), sprout::end(range2), sprout::end(range2), comp)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// set_symmetric_difference_holder
|
||||
//
|
||||
template<typename RRange, typename Compare = sprout::less<> >
|
||||
class set_symmetric_difference_holder {
|
||||
public:
|
||||
typedef RRange range2_type;
|
||||
typedef Compare compare_type;
|
||||
private:
|
||||
sprout::value_holder<range2_type&> range_;
|
||||
Compare comp_;
|
||||
public:
|
||||
set_symmetric_difference_holder() = default;
|
||||
set_symmetric_difference_holder(set_symmetric_difference_holder const&) = default;
|
||||
explicit SPROUT_CONSTEXPR set_symmetric_difference_holder(range2_type& range, Compare comp = Compare())
|
||||
: range_(range)
|
||||
, comp_(comp)
|
||||
{}
|
||||
SPROUT_CONSTEXPR range2_type& range() const {
|
||||
return range_;
|
||||
}
|
||||
SPROUT_CONSTEXPR Compare compare() const {
|
||||
return comp_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_symmetric_difference_forwarder
|
||||
//
|
||||
class set_symmetric_difference_forwarder {
|
||||
public:
|
||||
template<typename RRange>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_symmetric_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>
|
||||
operator()(RRange&& range) {
|
||||
return sprout::adaptors::set_symmetric_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range)
|
||||
);
|
||||
}
|
||||
template<typename RRange, typename Compare>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_symmetric_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>
|
||||
operator()(RRange&& range, Compare comp) {
|
||||
return sprout::adaptors::set_symmetric_difference_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range),
|
||||
comp
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_symmetric_difference
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::set_symmetric_difference_forwarder set_symmetric_difference = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::set_symmetric_difference_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>
|
||||
operator|(LRange&& lhs, sprout::adaptors::set_symmetric_difference_holder<RRange, Compare> const& rhs) {
|
||||
return sprout::adaptors::set_symmetric_difference_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<LRange>(lhs),
|
||||
rhs.range(),
|
||||
rhs.compare()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
struct container_construct_traits<sprout::adaptors::set_symmetric_difference_range<LRange, RRange, Compare> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::set_symmetric_difference_range<LRange, RRange, Compare>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SET_SYMMETRIC_DIFFERENCE_HPP
|
152
sprout/range/adaptor/set_union.hpp
Normal file
152
sprout/range/adaptor/set_union.hpp
Normal file
|
@ -0,0 +1,152 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_SET_UNION_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_SET_UNION_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/pit.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/set_union_iterator.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace adaptors {
|
||||
//
|
||||
// set_union_range
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare = sprout::less<> >
|
||||
class set_union_range
|
||||
: public sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_union_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
>
|
||||
{
|
||||
public:
|
||||
typedef sprout::adaptors::detail::jointed_range_default<
|
||||
LRange, RRange,
|
||||
sprout::set_union_iterator<
|
||||
typename sprout::container_traits<LRange>::iterator,
|
||||
typename sprout::container_traits<RRange>::iterator,
|
||||
Compare
|
||||
>
|
||||
> base_type;
|
||||
typedef typename base_type::range1_type range1_type;
|
||||
typedef typename base_type::range2_type range2_type;
|
||||
typedef typename base_type::iterator iterator;
|
||||
public:
|
||||
set_union_range() = default;
|
||||
set_union_range(set_union_range const&) = default;
|
||||
SPROUT_CONSTEXPR set_union_range(range1_type& range1, range2_type& range2, Compare comp = Compare())
|
||||
: base_type(
|
||||
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2), comp),
|
||||
iterator(sprout::end(range1), sprout::end(range1), sprout::end(range2), sprout::end(range2), comp)
|
||||
)
|
||||
{}
|
||||
};
|
||||
|
||||
//
|
||||
// set_union_holder
|
||||
//
|
||||
template<typename RRange, typename Compare = sprout::less<> >
|
||||
class set_union_holder {
|
||||
public:
|
||||
typedef RRange range2_type;
|
||||
typedef Compare compare_type;
|
||||
private:
|
||||
sprout::value_holder<range2_type&> range_;
|
||||
Compare comp_;
|
||||
public:
|
||||
set_union_holder() = default;
|
||||
set_union_holder(set_union_holder const&) = default;
|
||||
explicit SPROUT_CONSTEXPR set_union_holder(range2_type& range, Compare comp = Compare())
|
||||
: range_(range)
|
||||
, comp_(comp)
|
||||
{}
|
||||
SPROUT_CONSTEXPR range2_type& range() const {
|
||||
return range_;
|
||||
}
|
||||
SPROUT_CONSTEXPR Compare compare() const {
|
||||
return comp_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_union_forwarder
|
||||
//
|
||||
class set_union_forwarder {
|
||||
public:
|
||||
template<typename RRange>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_union_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>
|
||||
operator()(RRange&& range) {
|
||||
return sprout::adaptors::set_union_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range)
|
||||
);
|
||||
}
|
||||
template<typename RRange, typename Compare>
|
||||
SPROUT_CONSTEXPR sprout::adaptors::set_union_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>
|
||||
operator()(RRange&& range, Compare comp) {
|
||||
return sprout::adaptors::set_union_holder<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<RRange>::type>::type,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<RRange>(range),
|
||||
comp
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// set_union
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::adaptors::set_union_forwarder set_union = {};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::adaptors::set_union_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>
|
||||
operator|(LRange&& lhs, sprout::adaptors::set_union_holder<RRange, Compare> const& rhs) {
|
||||
return sprout::adaptors::set_union_range<
|
||||
typename std::remove_reference<typename sprout::lvalue_reference<LRange>::type>::type,
|
||||
RRange,
|
||||
Compare
|
||||
>(
|
||||
sprout::lvalue_forward<LRange>(lhs),
|
||||
rhs.range(),
|
||||
rhs.compare()
|
||||
);
|
||||
}
|
||||
} // namespace adaptors
|
||||
|
||||
//
|
||||
// container_construct_traits
|
||||
//
|
||||
template<typename LRange, typename RRange, typename Compare>
|
||||
struct container_construct_traits<sprout::adaptors::set_union_range<LRange, RRange, Compare> >
|
||||
: public sprout::container_construct_traits<typename sprout::adaptors::set_union_range<LRange, RRange, Compare>::base_type>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SET_UNION_HPP
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/sinusoid_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/size_enum_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/range/adaptor/detail/sized_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/square_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/step_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/transform_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/triangle_iterator.hpp>
|
||||
#include <sprout/range/range_container.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/valued_iterator.hpp>
|
||||
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
|
||||
#include <sprout/range/algorithm/copy.hpp>
|
||||
#include <sprout/type_traits/lvalue_reference.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
|
|
18
sprout/range/adaptor/various.hpp
Normal file
18
sprout/range/adaptor/various.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef SPROUT_RANGE_ADAPTOR_VARIOUS_HPP
|
||||
#define SPROUT_RANGE_ADAPTOR_VARIOUS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/adaptor/piped.hpp>
|
||||
#include <sprout/range/adaptor/counting.hpp>
|
||||
#include <sprout/range/adaptor/outdirected.hpp>
|
||||
#include <sprout/range/adaptor/steps.hpp>
|
||||
#include <sprout/range/adaptor/jointed.hpp>
|
||||
#include <sprout/range/adaptor/alternated.hpp>
|
||||
#include <sprout/range/adaptor/deep_copied.hpp>
|
||||
#include <sprout/range/adaptor/indexed.hpp>
|
||||
#include <sprout/range/adaptor/valued.hpp>
|
||||
#include <sprout/range/adaptor/blanked.hpp>
|
||||
#include <sprout/range/adaptor/sized.hpp>
|
||||
#include <sprout/range/adaptor/size_enumed.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_ADAPTOR_VARIOUS_HPP
|
Loading…
Reference in a new issue