mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
rename unfold -> recurrence, add-new unfold
This commit is contained in:
parent
a9308ae3ee
commit
b1b7a9fefc
19 changed files with 585 additions and 174 deletions
|
@ -17,6 +17,8 @@
|
|||
#include <sprout/algorithm/fit/generate_n.hpp>
|
||||
#include <sprout/algorithm/fit/unfold.hpp>
|
||||
#include <sprout/algorithm/fit/unfold_n.hpp>
|
||||
#include <sprout/algorithm/fit/recurrence.hpp>
|
||||
#include <sprout/algorithm/fit/recurrence_n.hpp>
|
||||
#include <sprout/algorithm/fit/remove.hpp>
|
||||
#include <sprout/algorithm/fit/remove_if.hpp>
|
||||
#include <sprout/algorithm/fit/remove_copy.hpp>
|
||||
|
|
44
sprout/algorithm/fit/recurrence.hpp
Normal file
44
sprout/algorithm/fit/recurrence.hpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIT_RECURRENCE_HPP
|
||||
#define SPROUT_ALGORITHM_FIT_RECURRENCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type recurrence_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::difference_type offset,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::recurrence(cont, gen, inits...)),
|
||||
offset,
|
||||
offset + sprout::size(cont)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// recurrence
|
||||
//
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type recurrence(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::recurrence_impl(cont, gen, sprout::internal_begin_offset(cont), inits...);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIT_RECURRENCE_HPP
|
47
sprout/algorithm/fit/recurrence_n.hpp
Normal file
47
sprout/algorithm/fit/recurrence_n.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIT_RECURRENCE_N_HPP
|
||||
#define SPROUT_ALGORITHM_FIT_RECURRENCE_N_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence_n.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type recurrence_n_impl(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::difference_type offset,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::recurrence_n(cont, n, gen, inits...)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(cont))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// recurrence_n
|
||||
//
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type recurrence_n(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::recurrence_n_impl(cont, n, gen, sprout::internal_begin_offset(cont), inits...);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIT_RECURRENCE_N_HPP
|
|
@ -11,16 +11,16 @@
|
|||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
template<typename Container, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type unfold_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::difference_type offset,
|
||||
Inits const&... inits
|
||||
Init const& init
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::unfold(cont, gen, inits...)),
|
||||
sprout::get_internal(sprout::fixed::unfold(cont, gen, init)),
|
||||
offset,
|
||||
offset + sprout::size(cont)
|
||||
);
|
||||
|
@ -29,14 +29,14 @@ namespace sprout {
|
|||
//
|
||||
// unfold
|
||||
//
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
template<typename Container, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type unfold(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
Init const& init
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::unfold_impl(cont, gen, sprout::internal_begin_offset(cont), inits...);
|
||||
return sprout::fit::detail::unfold_impl(cont, gen, sprout::internal_begin_offset(cont), init);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
template<typename Container, typename Size, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type unfold_n_impl(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::difference_type offset,
|
||||
Inits const&... inits
|
||||
Init const& init
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::unfold_n(cont, n, gen, inits...)),
|
||||
sprout::get_internal(sprout::fixed::unfold_n(cont, n, gen, init)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(cont))
|
||||
);
|
||||
|
@ -31,15 +31,15 @@ namespace sprout {
|
|||
//
|
||||
// unfold_n
|
||||
//
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
template<typename Container, typename Size, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type unfold_n(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
Init const& init
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::unfold_n_impl(cont, n, gen, sprout::internal_begin_offset(cont), inits...);
|
||||
return sprout::fit::detail::unfold_n_impl(cont, n, gen, sprout::internal_begin_offset(cont), init);
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#include <sprout/algorithm/fixed/generate_n.hpp>
|
||||
#include <sprout/algorithm/fixed/unfold.hpp>
|
||||
#include <sprout/algorithm/fixed/unfold_n.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence_n.hpp>
|
||||
#include <sprout/algorithm/fixed/remove.hpp>
|
||||
#include <sprout/algorithm/fixed/remove_if.hpp>
|
||||
#include <sprout/algorithm/fixed/remove_copy.hpp>
|
||||
|
|
|
@ -8,40 +8,39 @@
|
|||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/generator/functions.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename Container, typename Gen, typename... Args>
|
||||
template<typename Container, typename Next, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size == sizeof...(Args) + 1,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type generate_impl_1(
|
||||
Container const& cont, Gen const& gen,
|
||||
Container const& cont, Next const& next,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Container>(cont, size, args..., sprout::generators::generated_value(gen));
|
||||
return sprout::remake<Container>(cont, size, args..., sprout::generators::generated_value(next));
|
||||
}
|
||||
template<typename Container, typename Gen, typename... Args>
|
||||
template<typename Container, typename Next, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size != sizeof...(Args) + 1,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type
|
||||
generate_impl_1(
|
||||
Container const& cont, Gen const& gen,
|
||||
Container const& cont, Next const& next,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) + 1 < size
|
||||
? sprout::fixed::detail::generate_impl_1(
|
||||
cont, sprout::generators::next_generator(gen)(), size,
|
||||
args..., sprout::generators::generated_value(gen)
|
||||
cont, sprout::generators::next_generator(next)(), size,
|
||||
args..., sprout::generators::generated_value(next)
|
||||
)
|
||||
: sprout::detail::container_complate(cont, args..., sprout::generators::generated_value(gen))
|
||||
: sprout::detail::container_complate(cont, args..., sprout::generators::generated_value(next))
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator>
|
||||
|
@ -49,7 +48,7 @@ namespace sprout {
|
|||
sprout::container_traits<Container>::static_size == 0,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type generate_impl(
|
||||
Container const& cont, Generator const& gen,
|
||||
Container const& cont, Generator const& next,
|
||||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
|
@ -65,7 +64,7 @@ namespace sprout {
|
|||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
return size != 0
|
||||
return size > 0
|
||||
? sprout::fixed::detail::generate_impl_1(cont, gen(), size)
|
||||
: sprout::detail::container_complate(cont)
|
||||
;
|
||||
|
|
167
sprout/algorithm/fixed/recurrence.hpp
Normal file
167
sprout/algorithm/fixed/recurrence.hpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_RECURRENCE_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_RECURRENCE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/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<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize == 0,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return gen();
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename Head, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize != 0 && InitSize == sizeof...(Args) + 1,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
Head const& head,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return gen(head, args...);
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename Head, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize != 0 && InitSize != sizeof...(Args) + 1,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
Head const& head,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return call_gen<InitSize, Container>(gen, args...);
|
||||
}
|
||||
template<typename Container, typename Generator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type recurrence_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
return sprout::detail::container_complate(cont);
|
||||
}
|
||||
template<typename Container, typename Generator, typename Head, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size >= sizeof...(Inits) + 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Head const& head,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return size < sizeof...(Inits) + 1
|
||||
? sprout::fixed::detail::recurrence_impl_drop(cont, gen, size, inits...)
|
||||
: sprout::detail::container_complate(cont, head, inits...)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename Head, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size < sizeof...(Inits) + 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Head const& head,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::recurrence_impl_drop(cont, gen, size, inits...);
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl_1(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Container>(cont, sprout::size(cont), args...);
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl_1(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < size
|
||||
? sprout::fixed::detail::recurrence_impl_1<InitSize>(cont, gen, size, args..., sprout::fixed::detail::call_gen<InitSize, Container>(gen, args...))
|
||||
: sprout::detail::container_complate(cont, args...)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size > sizeof...(Inits)),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sizeof...(Inits) < size
|
||||
? sprout::fixed::detail::recurrence_impl_1<sizeof...(Inits)>(cont, gen, size, inits...)
|
||||
: sprout::fixed::detail::recurrence_impl_drop(cont, gen, size, inits...)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size <= sizeof...(Inits)),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type recurrence_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::recurrence_impl_drop(cont, gen, size, inits...);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// recurrence
|
||||
//
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type recurrence(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::recurrence_impl(cont, gen, sprout::size(cont), inits...);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::recurrence;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIXED_RECURRENCE_HPP
|
29
sprout/algorithm/fixed/recurrence_n.hpp
Normal file
29
sprout/algorithm/fixed/recurrence_n.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_RECURRENCE_N_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_RECURRENCE_N_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
//
|
||||
// recurrence_n
|
||||
//
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type recurrence_n(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::recurrence_impl(cont, gen, n, inits...);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::recurrence_n;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIXED_RECURRENCE_N_HPP
|
|
@ -1,163 +1,84 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_UNFOLD_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_UNFOLD_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/generator/functions.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
template<typename Container, typename Generator, typename Next, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize == 0,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
sprout::container_traits<Container>::static_size == sizeof...(Args) + 1,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl_1(
|
||||
Container const& cont, Generator const& gen, Next const& next,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return gen();
|
||||
return sprout::remake<Container>(cont, size, args..., sprout::generators::generated_value(next));
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename Head, typename... Args>
|
||||
template<typename Container, typename Generator, typename Next, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize != 0 && InitSize == sizeof...(Args) + 1,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
Head const& head,
|
||||
sprout::container_traits<Container>::static_size != sizeof...(Args) + 1,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type
|
||||
unfold_impl_1(
|
||||
Container const& cont, Generator const& gen, Next const& next,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return gen(head, args...);
|
||||
return sizeof...(Args) + 1 < size
|
||||
? sprout::fixed::detail::unfold_impl_1(
|
||||
cont, gen, gen(sprout::generators::next_generator(next)), size,
|
||||
args..., sprout::generators::generated_value(next)
|
||||
)
|
||||
: sprout::detail::container_complate(cont, args..., sprout::generators::generated_value(next))
|
||||
;
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename Head, typename... Args>
|
||||
template<typename Container, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
InitSize != 0 && InitSize != sizeof...(Args) + 1,
|
||||
typename sprout::container_traits<Container>::value_type
|
||||
>::type call_gen(
|
||||
Generator const& gen,
|
||||
Head const& head,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return call_gen<InitSize, Container>(gen, args...);
|
||||
}
|
||||
template<typename Container, typename Generator>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type unfold_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
sprout::container_traits<Container>::static_size == 0,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl(
|
||||
Container const& cont, Generator const& gen, Init const& init,
|
||||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
return sprout::detail::container_complate(cont);
|
||||
return sprout::remake<Container>(cont, size);
|
||||
}
|
||||
template<typename Container, typename Generator, typename Head, typename... Inits>
|
||||
template<typename Container, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size >= sizeof...(Inits) + 1),
|
||||
sprout::container_traits<Container>::static_size != 0,
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Head const& head,
|
||||
Inits const&... inits
|
||||
>::type
|
||||
unfold_impl(
|
||||
Container const& cont, Generator const& gen, Init const& init,
|
||||
typename sprout::container_traits<Container>::size_type size
|
||||
)
|
||||
{
|
||||
return size < sizeof...(Inits) + 1
|
||||
? sprout::fixed::detail::unfold_impl_drop(cont, gen, size, inits...)
|
||||
: sprout::detail::container_complate(cont, head, inits...)
|
||||
return size > 0
|
||||
? size > 1
|
||||
? sprout::fixed::detail::unfold_impl_1(cont, gen, gen(init), size, init)
|
||||
: sprout::detail::container_complate(cont, init)
|
||||
: sprout::detail::container_complate(cont)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename Head, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size < sizeof...(Inits) + 1),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl_drop(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Head const& head,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::unfold_impl_drop(cont, gen, size, inits...);
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl_1(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Container>(cont, sprout::size(cont), args...);
|
||||
}
|
||||
template<std::size_t InitSize, typename Container, typename Generator, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Container>::static_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl_1(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < size
|
||||
? sprout::fixed::detail::unfold_impl_1<InitSize>(cont, gen, size, args..., sprout::fixed::detail::call_gen<InitSize, Container>(gen, args...))
|
||||
: sprout::detail::container_complate(cont, args...)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size > sizeof...(Inits)),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sizeof...(Inits) < size
|
||||
? sprout::fixed::detail::unfold_impl_1<sizeof...(Inits)>(cont, gen, size, inits...)
|
||||
: sprout::fixed::detail::unfold_impl_drop(cont, gen, size, inits...)
|
||||
;
|
||||
}
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
(sprout::container_traits<Container>::static_size <= sizeof...(Inits)),
|
||||
typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
>::type unfold_impl(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
typename sprout::container_traits<Container>::size_type size,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::unfold_impl_drop(cont, gen, size, inits...);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// unfold
|
||||
//
|
||||
template<typename Container, typename Generator, typename... Inits>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type unfold(
|
||||
Container const& cont,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::unfold_impl(cont, gen, sprout::size(cont), inits...);
|
||||
template<typename Container, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
unfold(Container const& cont, Generator const& gen, Init const& init) {
|
||||
return sprout::fixed::detail::unfold_impl(cont, gen, init, sprout::size(cont));
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
|
@ -11,15 +11,15 @@ namespace sprout {
|
|||
//
|
||||
// unfold_n
|
||||
//
|
||||
template<typename Container, typename Size, typename Generator, typename... Inits>
|
||||
template<typename Container, typename Size, typename Generator, typename Init>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type unfold_n(
|
||||
Container const& cont,
|
||||
Size n,
|
||||
Generator const& gen,
|
||||
Inits const&... inits
|
||||
Init const& init
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::unfold_impl(cont, gen, n, inits...);
|
||||
return sprout::fixed::detail::unfold_impl(cont, gen, init, n);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
|
|
8
sprout/algorithm/recurrence.hpp
Normal file
8
sprout/algorithm/recurrence.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_ALGORITHM_RECURRENCE_HPP
|
||||
#define SPROUT_ALGORITHM_RECURRENCE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence.hpp>
|
||||
#include <sprout/algorithm/fit/recurrence.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_RECURRENCE_HPP
|
8
sprout/algorithm/recurrence_n.hpp
Normal file
8
sprout/algorithm/recurrence_n.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_ALGORITHM_RECURRENCE_N_HPP
|
||||
#define SPROUT_ALGORITHM_RECURRENCE_N_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/recurrence_n.hpp>
|
||||
#include <sprout/algorithm/fit/recurrence_n.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_RECURRENCE_N_HPP
|
Loading…
Add table
Add a link
Reference in a new issue