mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-01-23 20:46:37 +00:00
range/numeric.hpp 追加
algorithm/* fix
This commit is contained in:
parent
510a265ea5
commit
42d73cc4d5
18 changed files with 407 additions and 131 deletions
|
@ -1,11 +1,12 @@
|
|||
#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>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -61,7 +62,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < offset
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? pred(*first)
|
||||
? partition_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args...)
|
||||
: partition_copy_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
|
||||
|
@ -96,7 +97,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? partition_copy_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: partition_copy_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
|
||||
;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_REMOVE_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/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -61,7 +62,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < offset
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? *first == value
|
||||
? remove_copy_impl_2(sprout::next(first), last, result, value, offset, args...)
|
||||
: remove_copy_impl_2(sprout::next(first), last, result, value, offset, args..., *first)
|
||||
|
@ -96,7 +97,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? remove_copy_impl_1(first, last, result, value, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: remove_copy_impl_2(first, last, result, value, offset + sprout::size(result), args...)
|
||||
;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_REMOVE_COPY_IF_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/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -61,7 +62,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < offset
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? pred(*first)
|
||||
? remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args...)
|
||||
: remove_copy_if_impl_2(sprout::next(first), last, result, pred, offset, args..., *first)
|
||||
|
@ -96,7 +97,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? remove_copy_if_impl_1(first, last, result, pred, offset, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)))
|
||||
: remove_copy_if_impl_2(first, last, result, pred, offset + sprout::size(result), args...)
|
||||
;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -32,7 +33,7 @@ namespace sprout {
|
|||
result,
|
||||
sprout::size(result),
|
||||
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
|
||||
? *sprout::next(first, Indexes - offset) == old_value ? new_value : *sprout::next(first, Indexes - offset)
|
||||
? NS_SSCRISK_CEL_OR_SPROUT_DETAIL::equal_to<T>()(*sprout::next(first, Indexes - offset), old_value) ? new_value : *sprout::next(first, Indexes - offset)
|
||||
: *sprout::next(sprout::fixed_begin(result), Indexes)
|
||||
)...
|
||||
);
|
||||
|
|
|
@ -14,6 +14,24 @@
|
|||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_lr(
|
||||
Container const& cont,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type start,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type end,
|
||||
Compare comp,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type l,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type r,
|
||||
typename sprout::fixed_container_traits<Container>::value_type const& p
|
||||
);
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort_start(
|
||||
Container const& cont,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type start,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type end,
|
||||
Compare comp
|
||||
);
|
||||
|
||||
template<typename Container, typename Iterator>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::value_type const& sort_select_pivot(
|
||||
Iterator origin,
|
||||
|
@ -128,64 +146,80 @@ namespace sprout {
|
|||
{ // pivot を選択してソートを開始
|
||||
return sort_lr(cont, start, end, comp, start, end, sort_select_pivot<Container>(sprout::fixed_begin(cont), start, end));
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::fixed_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1),
|
||||
comp
|
||||
);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::fixed_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>()
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
|
||||
// sort
|
||||
//
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::fixed_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1),
|
||||
comp
|
||||
);
|
||||
return sprout::fixed::detail::sort(cont, comp);
|
||||
}
|
||||
//
|
||||
// sort
|
||||
//
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::fixed_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::fixed_begin(cont), sprout::end(cont) - 1),
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>()
|
||||
);
|
||||
return sprout::fixed::detail::sort(cont);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#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/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -34,13 +35,13 @@ namespace sprout {
|
|||
return stable_partition_copy_impl_4(result, args..., *sprout::next(sprout::fixed_begin(result), sizeof...(Args)));
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename Result, typename Predicate, typename... 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(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
|
@ -49,20 +50,20 @@ namespace sprout {
|
|||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Predicate, typename... 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(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < offset
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? !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...)
|
||||
|
@ -70,82 +71,82 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename Result, typename Predicate, typename... 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_2(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
InputIterator origin,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Predicate, typename... 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_2(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
InputIterator origin,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < offset
|
||||
return first != last && sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? 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 InputIterator, typename Result, typename Predicate, typename... 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(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
InputIterator origin,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Predicate, typename... 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(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred,
|
||||
typename sprout::fixed_container_traits<Result>::difference_type offset,
|
||||
InputIterator origin,
|
||||
BidirectionalIterator origin,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
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...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Predicate>
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy_impl(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred
|
||||
)
|
||||
|
@ -156,10 +157,10 @@ namespace sprout {
|
|||
//
|
||||
// stable_partition_copy
|
||||
//
|
||||
template<typename InputIterator, typename Result, typename Predicate>
|
||||
template<typename BidirectionalIterator, typename Result, typename Predicate>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type stable_partition_copy(
|
||||
InputIterator first,
|
||||
InputIterator last,
|
||||
BidirectionalIterator first,
|
||||
BidirectionalIterator last,
|
||||
Result const& result,
|
||||
Predicate pred
|
||||
)
|
||||
|
|
|
@ -198,62 +198,77 @@ namespace sprout {
|
|||
{
|
||||
return stable_sort_impl_1(cont, comp, sprout::index_tuple<Indexes...>(), sprout::index_tuple<>(), sprout::index_tuple<>(), sprout::index_tuple<>());
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::stable_sort_impl(
|
||||
cont,
|
||||
comp,
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
|
||||
);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::stable_sort_impl(
|
||||
cont,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>(),
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// stable_sort
|
||||
//
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type stable_sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container, typename Compare>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::stable_sort_impl(
|
||||
cont,
|
||||
comp,
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
|
||||
);
|
||||
return sprout::fixed::detail::stable_sort(cont, comp);
|
||||
}
|
||||
//
|
||||
// stable_sort
|
||||
//
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size <= 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::clone(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size > 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type stable_sort(
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Container>::type stable_sort(
|
||||
Container const& cont
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::stable_sort_impl(
|
||||
cont,
|
||||
NS_SSCRISK_CEL_OR_SPROUT_DETAIL::less<typename sprout::fixed_container_traits<Container>::value_type>(),
|
||||
typename sprout::index_range<0, sprout::fixed_container_traits<Container>::fixed_size>::type()
|
||||
);
|
||||
return sprout::fixed::detail::stable_sort(cont);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_UNIQUE_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_UNIQUE_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/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -46,7 +47,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args..., head);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Head, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
|
@ -61,7 +62,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) + 1 < offset
|
||||
return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
|
||||
? !(head == *first)
|
||||
? unique_copy_impl_2(sprout::next(first), last, result, offset, *first, args..., head)
|
||||
: unique_copy_impl_2(sprout::next(first), last, result, offset, head, args...)
|
||||
|
@ -94,9 +95,11 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? unique_copy_impl_1(first, last, result, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
|
||||
: unique_copy_impl_2(sprout::next(first), last, result, offset + sprout::size(result), *first, args...)
|
||||
: first != last
|
||||
? unique_copy_impl_2(sprout::next(first), last, result, offset + sprout::size(result), *first, args...)
|
||||
: unique_copy_impl_3(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
|
@ -137,7 +140,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args...);
|
||||
return sprout::remake_clone<Result, Result>(result, sprout::size(result), args..., head);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename BinaryPredicate, typename Head, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
|
@ -153,7 +156,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) + 1 < offset
|
||||
return first != last && sizeof...(Args) + 1 < static_cast<std::size_t>(offset)
|
||||
? !pred(head, *first)
|
||||
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset, *first, args..., head)
|
||||
: unique_copy_impl_2(sprout::next(first), last, result, pred, offset, head, args...)
|
||||
|
@ -188,9 +191,11 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? unique_copy_impl_1(first, last, result, pred, offset, args..., *(sprout::fixed_begin(result) + sizeof...(Args)))
|
||||
: unique_copy_impl_2(sprout::next(first), last, result, pred, offset + sprout::size(result), *first, args...)
|
||||
: first != last
|
||||
? unique_copy_impl_2(sprout::next(first), last, result, pred, offset + sprout::size(result), *first, args...)
|
||||
: unique_copy_impl_3(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename BinaryPredicate>
|
||||
|
|
|
@ -6,6 +6,19 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
//
|
||||
// equal_to
|
||||
//
|
||||
template<typename T>
|
||||
class equal_to
|
||||
: public std::binary_function<T, T, bool>
|
||||
{
|
||||
public:
|
||||
SPROUT_CONSTEXPR bool operator()(T const& lhs, T const& rhs) const {
|
||||
return lhs == rhs;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// less
|
||||
//
|
||||
|
|
8
sprout/range/numeric.hpp
Normal file
8
sprout/range/numeric.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/numeric/fixed.hpp>
|
||||
#include <sprout/range/numeric/fit.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_HPP
|
8
sprout/range/numeric/adjacent_difference.hpp
Normal file
8
sprout/range/numeric/adjacent_difference.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/numeric/fixed/adjacent_difference.hpp>
|
||||
#include <sprout/range/numeric/fit/adjacent_difference.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_ADJACENT_DIFFERENCE_HPP
|
8
sprout/range/numeric/fit.hpp
Normal file
8
sprout/range/numeric/fit.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIT_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIT_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/numeric/fit/partial_sum.hpp>
|
||||
#include <sprout/range/numeric/fit/adjacent_difference.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_HPP
|
40
sprout/range/numeric/fit/adjacent_difference.hpp
Normal file
40
sprout/range/numeric/fit/adjacent_difference.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/numeric/fit/adjacent_difference.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace range {
|
||||
namespace fit {
|
||||
//
|
||||
// adjacent_difference
|
||||
//
|
||||
template<typename Input, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type adjacent_difference(
|
||||
Input const& input,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fit::adjacent_difference(sprout::begin(input), sprout::end(input), result);
|
||||
}
|
||||
//
|
||||
// adjacent_difference
|
||||
//
|
||||
template<typename Input, typename Result, typename BinaryOperation>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type adjacent_difference(
|
||||
Input const& input,
|
||||
Result const& result,
|
||||
BinaryOperation binary_op
|
||||
)
|
||||
{
|
||||
return sprout::fit::adjacent_difference(sprout::begin(input), sprout::end(input), result, binary_op);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace range
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_ADJACENT_DIFFERENCE_HPP
|
40
sprout/range/numeric/fit/partial_sum.hpp
Normal file
40
sprout/range/numeric/fit/partial_sum.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/numeric/fit/partial_sum.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace range {
|
||||
namespace fit {
|
||||
//
|
||||
// partial_sum
|
||||
//
|
||||
template<typename Input, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type partial_sum(
|
||||
Input const& input,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fit::partial_sum(sprout::begin(input), sprout::end(input), result);
|
||||
}
|
||||
//
|
||||
// partial_sum
|
||||
//
|
||||
template<typename Input, typename Result, typename BinaryOperation>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fit::result_of::algorithm<Result>::type partial_sum(
|
||||
Input const& input,
|
||||
Result const& result,
|
||||
BinaryOperation binary_op
|
||||
)
|
||||
{
|
||||
return sprout::fit::partial_sum(sprout::begin(input), sprout::end(input), result, binary_op);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace range
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIT_PARTIAL_SUM_HPP
|
8
sprout/range/numeric/fixed.hpp
Normal file
8
sprout/range/numeric/fixed.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIXED_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIXED_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/numeric/fixed/partial_sum.hpp>
|
||||
#include <sprout/range/numeric/fixed/adjacent_difference.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_HPP
|
42
sprout/range/numeric/fixed/adjacent_difference.hpp
Normal file
42
sprout/range/numeric/fixed/adjacent_difference.hpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/numeric/fixed/adjacent_difference.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace range {
|
||||
namespace fixed {
|
||||
//
|
||||
// adjacent_difference
|
||||
//
|
||||
template<typename Input, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type adjacent_difference(
|
||||
Input const& input,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::adjacent_difference(sprout::begin(input), sprout::end(input), result);
|
||||
}
|
||||
//
|
||||
// adjacent_difference
|
||||
//
|
||||
template<typename Input, typename Result, typename BinaryOperation>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type adjacent_difference(
|
||||
Input const& input,
|
||||
Result const& result,
|
||||
BinaryOperation binary_op
|
||||
)
|
||||
{
|
||||
return sprout::fixed::adjacent_difference(sprout::begin(input), sprout::end(input), result, binary_op);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::range::fixed::adjacent_difference;
|
||||
} // namespace range
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_ADJACENT_DIFFERENCE_HPP
|
42
sprout/range/numeric/fixed/partial_sum.hpp
Normal file
42
sprout/range/numeric/fixed/partial_sum.hpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/numeric/fixed/partial_sum.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace range {
|
||||
namespace fixed {
|
||||
//
|
||||
// partial_sum
|
||||
//
|
||||
template<typename Input, typename Result>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type partial_sum(
|
||||
Input const& input,
|
||||
Result const& result
|
||||
)
|
||||
{
|
||||
return sprout::fixed::partial_sum(sprout::begin(input), sprout::end(input), result);
|
||||
}
|
||||
//
|
||||
// partial_sum
|
||||
//
|
||||
template<typename Input, typename Result, typename BinaryOperation>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed::result_of::algorithm<Result>::type partial_sum(
|
||||
Input const& input,
|
||||
Result const& result,
|
||||
BinaryOperation binary_op
|
||||
)
|
||||
{
|
||||
return sprout::fixed::partial_sum(sprout::begin(input), sprout::end(input), result, binary_op);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::range::fixed::partial_sum;
|
||||
} // namespace range
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_FIXED_PARTIAL_SUM_HPP
|
8
sprout/range/numeric/partial_sum.hpp
Normal file
8
sprout/range/numeric/partial_sum.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP
|
||||
#define SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/range/numeric/fixed/partial_sum.hpp>
|
||||
#include <sprout/range/numeric/fit/partial_sum.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RANGE_NUMERIC_PARTIAL_SUM_HPP
|
Loading…
Reference in a new issue