mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-01-21 20:36:37 +00:00
algorithm/* 実装変更
This commit is contained in:
parent
a79574f251
commit
41916cf0a5
9 changed files with 164 additions and 619 deletions
|
@ -1,52 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_MERGE_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_MERGE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return merge_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_2(
|
||||
>::type merge_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -56,79 +34,30 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_2(
|
||||
>::type merge_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return sizeof...(Args) < size
|
||||
? first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first2, *first1)
|
||||
? merge_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: merge_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
: merge_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::merge_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::fixed::detail::merge_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: sprout::fixed::detail::merge_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: first2 != last2
|
||||
? merge_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: merge_impl_3(result, args...)
|
||||
: merge_impl_3(result, args...)
|
||||
? sprout::fixed::detail::merge_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type merge_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? merge_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: merge_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type merge_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return merge_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// merge
|
||||
|
@ -149,7 +78,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
comp
|
||||
comp,
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -170,7 +100,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>()
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>(),
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_PARTITION_COPY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
|
|
|
@ -1,52 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_SET_DIFFERENCE_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_SET_DIFFERENCE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return set_difference_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_2(
|
||||
>::type set_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -56,81 +34,32 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_2(
|
||||
>::type set_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return sizeof...(Args) < size
|
||||
? first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? set_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_difference_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: comp(*first2, *first1)
|
||||
? set_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_difference_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_difference_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::fixed::detail::set_difference_impl(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::fixed::detail::set_difference_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: first2 != last2
|
||||
? set_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_difference_impl_3(result, args...)
|
||||
: set_difference_impl_3(result, args...)
|
||||
? sprout::fixed::detail::set_difference_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_difference_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? set_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: set_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type set_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return set_difference_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// set_difference
|
||||
|
@ -151,7 +80,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
comp
|
||||
comp,
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -172,7 +102,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>()
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>(),
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -1,52 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_SET_INTERSECTION_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_SET_INTERSECTION_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return set_intersection_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_2(
|
||||
>::type set_intersection_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -56,81 +34,32 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_2(
|
||||
>::type set_intersection_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return sizeof...(Args) < size
|
||||
? first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? set_intersection_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args...)
|
||||
? sprout::fixed::detail::set_intersection_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args...)
|
||||
: comp(*first2, *first1)
|
||||
? set_intersection_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_intersection_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args..., *first1)
|
||||
: set_intersection_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args...)
|
||||
? sprout::fixed::detail::set_intersection_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::fixed::detail::set_intersection_impl(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, size, args..., *first1)
|
||||
: sprout::fixed::detail::set_intersection_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args...)
|
||||
: first2 != last2
|
||||
? set_intersection_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_intersection_impl_3(result, args...)
|
||||
: set_intersection_impl_3(result, args...)
|
||||
? sprout::fixed::detail::set_intersection_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_intersection_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? set_intersection_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: set_intersection_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type set_intersection_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return set_intersection_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// set_intersection
|
||||
|
@ -151,7 +80,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
comp
|
||||
comp,
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -172,7 +102,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>()
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>(),
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -1,52 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_SET_SYMMETRIC_DIFFERENCE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return set_symmetric_difference_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_2(
|
||||
>::type set_symmetric_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -56,81 +34,32 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_2(
|
||||
>::type set_symmetric_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return sizeof...(Args) < size
|
||||
? first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? set_symmetric_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_symmetric_difference_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: comp(*first2, *first1)
|
||||
? set_symmetric_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: set_symmetric_difference_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args...)
|
||||
: set_symmetric_difference_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_symmetric_difference_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::fixed::detail::set_symmetric_difference_impl(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, size, args...)
|
||||
: sprout::fixed::detail::set_symmetric_difference_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: first2 != last2
|
||||
? set_symmetric_difference_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: set_symmetric_difference_impl_3(result, args...)
|
||||
: set_symmetric_difference_impl_3(result, args...)
|
||||
? sprout::fixed::detail::set_symmetric_difference_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_symmetric_difference_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: set_symmetric_difference_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type set_symmetric_difference_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return set_symmetric_difference_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// set_symmetric_difference
|
||||
|
@ -151,7 +80,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
comp
|
||||
comp,
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -172,7 +102,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>()
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>(),
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -1,52 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_SET_UNION_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_SET_UNION_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return set_union_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_2(
|
||||
>::type set_union_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -56,81 +34,32 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_2(
|
||||
>::type set_union_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return sizeof...(Args) < size
|
||||
? first1 != last1
|
||||
? first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? set_union_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_union_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: comp(*first2, *first1)
|
||||
? set_union_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: set_union_impl_2(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, offset, args..., *first1)
|
||||
: set_union_impl_2(sprout::next(first1), last1, first2, last2, result, comp, offset, args..., *first1)
|
||||
? sprout::fixed::detail::set_union_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::fixed::detail::set_union_impl(sprout::next(first1), last1, sprout::next(first2), last2, result, comp, size, args..., *first1)
|
||||
: sprout::fixed::detail::set_union_impl(sprout::next(first1), last1, first2, last2, result, comp, size, args..., *first1)
|
||||
: first2 != last2
|
||||
? set_union_impl_2(first1, last1, sprout::next(first2), last2, result, comp, offset, args..., *first2)
|
||||
: set_union_impl_3(result, args...)
|
||||
: set_union_impl_3(result, args...)
|
||||
? sprout::fixed::detail::set_union_impl(first1, last1, sprout::next(first2), last2, result, comp, size, args..., *first2)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type set_union_impl_1(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? set_union_impl_1(first1, last1, first2, last2, result, comp, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: set_union_impl_2(first1, last1, first2, last2, result, comp, offset + sprout::size(result), args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type set_union_impl(
|
||||
InputIterator1 first1,
|
||||
InputIterator1 last1,
|
||||
InputIterator2 first2,
|
||||
InputIterator2 last2,
|
||||
Result const& result,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return set_union_impl_1(first1, last1, first2, last2, result, comp, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// set_union
|
||||
|
@ -151,7 +80,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
comp
|
||||
comp,
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -172,7 +102,8 @@ namespace sprout {
|
|||
first2,
|
||||
last2,
|
||||
result,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>()
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Result>::value_type>(),
|
||||
sprout::size(result)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -49,7 +49,10 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::value_type const& p
|
||||
)
|
||||
{ // left を見つける
|
||||
return comp(*sprout::next(origin, l), p) ? sort_find_l<Container>(origin, comp, l + 1, p) : l;
|
||||
return comp(*sprout::next(origin, l), p)
|
||||
? sprout::fixed::detail::sort_find_l<Container>(origin, comp, l + 1, p)
|
||||
: l
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Iterator, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::difference_type sort_find_r(
|
||||
|
@ -59,7 +62,10 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::value_type const& p
|
||||
)
|
||||
{ // right を見つける
|
||||
return comp(p, *sprout::next(origin, r)) ? sort_find_r<Container>(origin, comp, r - 1, p) : r;
|
||||
return comp(p, *sprout::next(origin, r))
|
||||
? sprout::fixed::detail::sort_find_r<Container>(origin, comp, r - 1, p)
|
||||
: r
|
||||
;
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type swap_lr(
|
||||
|
@ -75,7 +81,10 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::difference_type l
|
||||
)
|
||||
{ // 左側をソート
|
||||
return start < l - 1 ? sort_start(cont, start, l - 1, comp) : sprout::clone(cont);
|
||||
return start < l - 1
|
||||
? sprout::fixed::detail::sort_start(cont, start, l - 1, comp)
|
||||
: sprout::clone(cont)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_part_r(
|
||||
|
@ -85,7 +94,10 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::difference_type r
|
||||
)
|
||||
{ // 右側をソート
|
||||
return r + 1 < end ? sort_start(cont, r + 1, end, comp) : sprout::clone(cont);
|
||||
return r + 1 < end
|
||||
? sprout::fixed::detail::sort_start(cont, r + 1, end, comp)
|
||||
: sprout::clone(cont)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_part_lr(
|
||||
|
@ -97,7 +109,12 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::difference_type r
|
||||
)
|
||||
{ // 左右に分けてソート
|
||||
return sort_part_r(sort_part_l(cont, start, comp, l), end, comp, r);
|
||||
return sprout::fixed::detail::sort_part_r(
|
||||
sprout::fixed::detail::sort_part_l(cont, start, comp, l),
|
||||
end,
|
||||
comp,
|
||||
r
|
||||
);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_next(
|
||||
|
@ -111,8 +128,20 @@ namespace sprout {
|
|||
)
|
||||
{ // left と right 比較して、左右に分けてソートするか、またはスワップしてこの範囲のソートを続ける
|
||||
return l >= r
|
||||
? sort_part_lr(cont, start, end, comp, l, r)
|
||||
: sort_lr(sprout::fixed::swap_element(cont, sprout::next(sprout::fixed_begin(cont), l), sprout::next(sprout::fixed_begin(cont), r)), start, end, comp, l + 1, r - 1, p)
|
||||
? sprout::fixed::detail::sort_part_lr(cont, start, end, comp, l, r)
|
||||
: sprout::fixed::detail::sort_lr(
|
||||
sprout::fixed::swap_element(
|
||||
cont,
|
||||
sprout::next(sprout::fixed_begin(cont), l),
|
||||
sprout::next(sprout::fixed_begin(cont), r)
|
||||
),
|
||||
start,
|
||||
end,
|
||||
comp,
|
||||
l + 1,
|
||||
r - 1,
|
||||
p
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
|
@ -126,13 +155,13 @@ namespace sprout {
|
|||
typename sprout::fixed_container_traits<Container>::value_type const& p
|
||||
)
|
||||
{ // left と right を検索
|
||||
return sort_next(
|
||||
return sprout::fixed::detail::sort_next(
|
||||
cont,
|
||||
start,
|
||||
end,
|
||||
comp,
|
||||
sort_find_l<Container>(sprout::fixed_begin(cont), comp, l, p),
|
||||
sort_find_r<Container>(sprout::fixed_begin(cont), comp, r, p),
|
||||
sprout::fixed::detail::sort_find_l<Container>(sprout::fixed_begin(cont), comp, l, p),
|
||||
sprout::fixed::detail::sort_find_r<Container>(sprout::fixed_begin(cont), comp, r, p),
|
||||
p
|
||||
);
|
||||
}
|
||||
|
@ -144,7 +173,15 @@ namespace sprout {
|
|||
Compare comp
|
||||
)
|
||||
{ // pivot を選択してソートを開始
|
||||
return sort_lr(cont, start, end, comp, start, end, sort_select_pivot<Container>(sprout::fixed_begin(cont), start, end));
|
||||
return sprout::fixed::detail::sort_lr(
|
||||
cont,
|
||||
start,
|
||||
end,
|
||||
comp,
|
||||
start,
|
||||
end,
|
||||
sprout::fixed::detail::sort_select_pivot<Container>(sprout::fixed_begin(cont), start, end)
|
||||
);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
|
|
|
@ -1,50 +1,27 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_STABLE_PARTITION_COPY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_4(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_4(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return stable_partition_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_3(
|
||||
>::type stable_partition_copy_impl_1(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -54,20 +31,20 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_3(
|
||||
>::type stable_partition_copy_impl_1(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return first != last && sizeof...(Args) < size
|
||||
? !pred(*first)
|
||||
? stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args..., *first)
|
||||
: stable_partition_copy_impl_3(sprout::next(first), last, result, pred, offset, args...)
|
||||
: stable_partition_copy_impl_4(result, args...)
|
||||
? sprout::fixed::detail::stable_partition_copy_impl_1(sprout::next(first), last, result, pred, size, args..., *first)
|
||||
: sprout::fixed::detail::stable_partition_copy_impl_1(sprout::next(first), last, result, pred, size, args...)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -75,13 +52,13 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_2(
|
||||
>::type stable_partition_copy_impl(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
BidirectionalIterator origin,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
BidirectionalIterator temp_first,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -91,68 +68,23 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_2(
|
||||
>::type stable_partition_copy_impl(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
BidirectionalIterator origin,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
BidirectionalIterator temp_first,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
return first != last && sizeof...(Args) < size
|
||||
? pred(*first)
|
||||
? stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args..., *first)
|
||||
: stable_partition_copy_impl_2(sprout::next(first), last, result, pred, offset, origin, args...)
|
||||
: stable_partition_copy_impl_3(origin, last, result, pred, offset, args...)
|
||||
;
|
||||
}
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_1(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type stable_partition_copy_impl_1(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? stable_partition_copy_impl_1(first, last, result, pred, offset, origin, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: stable_partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), origin, args...)
|
||||
? sprout::fixed::detail::stable_partition_copy_impl(sprout::next(first), last, result, pred, size, temp_first, args..., *first)
|
||||
: sprout::fixed::detail::stable_partition_copy_impl(sprout::next(first), last, result, pred, size, temp_first, args...)
|
||||
: sprout::fixed::detail::stable_partition_copy_impl_1(temp_first, last, result, pred, size, args...)
|
||||
;
|
||||
}
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy_impl(
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred
|
||||
)
|
||||
{
|
||||
return stable_partition_copy_impl_1(first, last, result, pred, sprout::fixed_begin_offset(result), first);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// stable_partition_copy
|
||||
|
@ -165,7 +97,7 @@ namespace sprout {
|
|||
Predicate pred
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::stable_partition_copy_impl(first, last, result, pred);
|
||||
return sprout::fixed::detail::stable_partition_copy_impl(first, last, result, pred, sprout::size(result), first);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
|
@ -20,9 +21,9 @@ namespace sprout {
|
|||
RandomAccessIterator first,
|
||||
RandomAccessIterator last,
|
||||
Result const& result,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
RandomAccessIterator pos1,
|
||||
RandomAccessIterator pos2,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
typename sprout::fixed_container_traits<Result>::size_type input_size
|
||||
|
@ -55,82 +56,25 @@ namespace sprout {
|
|||
first,
|
||||
last,
|
||||
result,
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Result>::fixed_size>::type(),
|
||||
pos1,
|
||||
pos2,
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Result>::fixed_size>::type(),
|
||||
sprout::fixed_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_3(
|
||||
Result const& result,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return swap_element_copy_impl_3(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_2(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
InputIterator pos1,
|
||||
InputIterator pos2,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_2(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
InputIterator pos1,
|
||||
InputIterator pos2,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? swap_element_copy_impl_2(sprout::next(first), last, result, pos1, pos2, offset, args..., first == pos1 ? *pos2 : first == pos2 ? *pos1 : *first)
|
||||
: swap_element_copy_impl_3(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_1(
|
||||
>::type swap_element_copy_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
InputIterator pos1,
|
||||
InputIterator pos2,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
|
@ -140,33 +84,22 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
sprout::fixed_container_traits<Result>::fixed_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type swap_element_copy_impl_1(
|
||||
>::type swap_element_copy_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
InputIterator pos1,
|
||||
InputIterator pos2,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
typename sprout::fixed_container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? swap_element_copy_impl_1(first, last, result, pos1, pos2, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: swap_element_copy_impl_2(first, last, result, pos1, pos2, offset + sprout::size(result), args...)
|
||||
return first != last && sizeof...(Args) < size
|
||||
? sprout::fixed::detail::swap_element_copy_impl(sprout::next(first), last, result, pos1, pos2, size, args..., first == pos1 ? *pos2 : first == pos2 ? *pos1 : *first)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type swap_element_copy_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
Result const& result,
|
||||
InputIterator pos1,
|
||||
InputIterator pos2
|
||||
)
|
||||
{
|
||||
return swap_element_copy_impl_1(first, last, result, pos1, pos2, pos1, pos2, sprout::fixed_begin_offset(result));
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type swap_element_copy(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
|
@ -176,11 +109,7 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::swap_element_copy_impl(
|
||||
first,
|
||||
last,
|
||||
result
|
||||
);
|
||||
return sprout::fixed::detail::swap_element_copy_impl(first, last, result, sprout::size(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
|
@ -196,14 +125,7 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
|
||||
return sprout::fixed::detail::swap_element_copy(
|
||||
first,
|
||||
last,
|
||||
result,
|
||||
pos1,
|
||||
pos2,
|
||||
category()
|
||||
);
|
||||
return sprout::fixed::detail::swap_element_copy(first, last, result, pos1, pos2, category());
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
Loading…
Reference in a new issue