add some range algorithms

This commit is contained in:
bolero-MURAKAMI 2013-01-26 22:19:35 +09:00
parent 271f348972
commit 3472e8b94e
8 changed files with 336 additions and 0 deletions

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_DIFFERENCE_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/find_difference.hpp>
namespace sprout {
namespace range {
//
// find_difference
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_difference(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::find_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_difference(Range1&& range1, Range2&& range2) {
return sprout::find_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_DIFFERENCE_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_INTERSECTION_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_INTERSECTION_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/find_intersection.hpp>
namespace sprout {
namespace range {
//
// find_intersection
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_intersection(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::find_intersection(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_intersection(Range1&& range1, Range2&& range2) {
return sprout::find_intersection(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_INTERSECTION_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_FIND_SYMMETRIC_DIFFERENCE_HPP
#define SPROUT_RANGE_ALGORITHM_FIND_SYMMETRIC_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/find_symmetric_difference.hpp>
namespace sprout {
namespace range {
//
// find_symmetric_difference
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_symmetric_difference(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::find_symmetric_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
find_symmetric_difference(Range1&& range1, Range2&& range2) {
return sprout::find_symmetric_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_FIND_SYMMETRIC_DIFFERENCE_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_NEXT_DIFFERENCE_HPP
#define SPROUT_RANGE_ALGORITHM_NEXT_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/next_difference.hpp>
namespace sprout {
namespace range {
//
// next_difference
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_difference(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::next_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_difference(Range1&& range1, Range2&& range2) {
return sprout::next_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NEXT_DIFFERENCE_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_NEXT_INTERSECTION_HPP
#define SPROUT_RANGE_ALGORITHM_NEXT_INTERSECTION_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/next_intersection.hpp>
namespace sprout {
namespace range {
//
// next_intersection
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_intersection(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::next_intersection(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_intersection(Range1&& range1, Range2&& range2) {
return sprout::next_intersection(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NEXT_INTERSECTION_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP
#define SPROUT_RANGE_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/next_symmetric_difference.hpp>
namespace sprout {
namespace range {
//
// next_symmetric_difference
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_symmetric_difference(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::next_symmetric_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_symmetric_difference(Range1&& range1, Range2&& range2) {
return sprout::next_symmetric_difference(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NEXT_SYMMETRIC_DIFFERENCE_HPP

View file

@ -0,0 +1,47 @@
#ifndef SPROUT_RANGE_ALGORITHM_NEXT_UNION_HPP
#define SPROUT_RANGE_ALGORITHM_NEXT_UNION_HPP
#include <sprout/config.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/utility/pair.hpp>
#include <sprout/range/type_traits/lvalue_iterator.hpp>
#include <sprout/algorithm/next_union.hpp>
namespace sprout {
namespace range {
//
// next_union
//
template<typename Range1, typename Range2, typename Compare>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_union(Range1&& range1, Range2&& range2, Compare comp) {
return sprout::next_union(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2)),
comp
);
}
template<typename Range1, typename Range2>
inline SPROUT_CONSTEXPR sprout::pair<
typename sprout::range::lvalue_iterator<Range1>::type,
typename sprout::range::lvalue_iterator<Range2>::type
>
next_union(Range1&& range1, Range2&& range2) {
return sprout::next_union(
sprout::begin(sprout::forward<Range1>(range1)),
sprout::end(sprout::forward<Range1>(range1)),
sprout::begin(sprout::forward<Range2>(range2)),
sprout::end(sprout::forward<Range2>(range2))
);
}
} // namespace range
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NEXT_UNION_HPP

View file

@ -43,5 +43,12 @@
#include <sprout/range/algorithm/is_decreasing.hpp> #include <sprout/range/algorithm/is_decreasing.hpp>
#include <sprout/range/algorithm/is_strictly_increasing.hpp> #include <sprout/range/algorithm/is_strictly_increasing.hpp>
#include <sprout/range/algorithm/is_strictly_decreasing.hpp> #include <sprout/range/algorithm/is_strictly_decreasing.hpp>
#include <sprout/range/algorithm/find_intersection.hpp>
#include <sprout/range/algorithm/find_difference.hpp>
#include <sprout/range/algorithm/find_symmetric_difference.hpp>
#include <sprout/range/algorithm/next_union.hpp>
#include <sprout/range/algorithm/next_intersection.hpp>
#include <sprout/range/algorithm/next_difference.hpp>
#include <sprout/range/algorithm/next_symmetric_difference.hpp>
#endif // #ifndef SPROUT_RANGE_ALGORITHM_NON_MODIFYIING_HPP #endif // #ifndef SPROUT_RANGE_ALGORITHM_NON_MODIFYIING_HPP