mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +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
|
@ -21,6 +21,8 @@
|
|||
#include "./generate_n.cpp"
|
||||
#include "./unfold.cpp"
|
||||
#include "./unfold_n.cpp"
|
||||
#include "./recurrence.cpp"
|
||||
#include "./recurrence_n.cpp"
|
||||
#include "./remove.cpp"
|
||||
#include "./remove_if.cpp"
|
||||
#include "./remove_copy.cpp"
|
||||
|
@ -84,6 +86,8 @@ namespace testspr {
|
|||
testspr::algorithm_fill_n_test();
|
||||
testspr::algorithm_unfold_test();
|
||||
testspr::algorithm_unfold_n_test();
|
||||
testspr::algorithm_recurrence_test();
|
||||
testspr::algorithm_recurrence_n_test();
|
||||
testspr::algorithm_remove_test();
|
||||
testspr::algorithm_remove_if_test();
|
||||
testspr::algorithm_remove_copy_test();
|
||||
|
|
80
libs/algorithm/test/recurrence.cpp
Normal file
80
libs/algorithm/test/recurrence.cpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
#ifndef SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_CPP
|
||||
#define SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_CPP
|
||||
|
||||
#include <sprout/algorithm/recurrence.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
static void algorithm_recurrence_test() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
|
||||
// 生成
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::recurrence(
|
||||
arr1,
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 10>{{2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::fit::recurrence(
|
||||
arr1,
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 10>{{2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}}
|
||||
));
|
||||
}
|
||||
// 生成
|
||||
// 範囲の切り出し
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::recurrence(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 6>{{2, 4, 8, 16, 32, 64}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(recurrenced),
|
||||
array<int, 10>{{1, 2, 2, 4, 8, 16, 32, 64, 9, 10}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::fit::recurrence(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 6>{{2, 4, 8, 16, 32, 64}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(recurrenced),
|
||||
array<int, 10>{{1, 2, 2, 4, 8, 16, 32, 64, 9, 10}}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#ifndef TESTSPR_CPP_INCLUDE
|
||||
# define TESTSPR_TEST_FUNCTION testspr::algorithm_recurrence_test
|
||||
# include <testspr/include_main.hpp>
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_CPP
|
84
libs/algorithm/test/recurrence_n.cpp
Normal file
84
libs/algorithm/test/recurrence_n.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#ifndef SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_N_CPP
|
||||
#define SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_N_CPP
|
||||
|
||||
#include <sprout/algorithm/recurrence_n.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/container.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
static void algorithm_recurrence_n_test() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
|
||||
// 生成
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::recurrence_n(
|
||||
arr1,
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 10>{{1, 2, 4, 8, 5, 6, 7, 8, 9, 10}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::fit::recurrence_n(
|
||||
arr1,
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 4>{{1, 2, 4, 8}}
|
||||
));
|
||||
}
|
||||
// 生成
|
||||
// 範囲の切り出し
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::recurrence_n(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 6>{{1, 2, 4, 8, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(recurrenced),
|
||||
array<int, 10>{{1, 2, 1, 2, 4, 8, 7, 8, 9, 10}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto recurrenced = sprout::fit::recurrence_n(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
recurrenced,
|
||||
array<int, 4>{{1, 2, 4, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(recurrenced),
|
||||
array<int, 10>{{1, 2, 1, 2, 4, 8, 7, 8, 9, 10}}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#ifndef TESTSPR_CPP_INCLUDE
|
||||
# define TESTSPR_TEST_FUNCTION testspr::algorithm_recurrence_n_test
|
||||
# include <testspr/include_main.hpp>
|
||||
#endif
|
||||
|
||||
#endif // #ifndef SPROUT_LIBS_ALGORITHM_TEST_RECURRENCE_N_CPP
|
|
@ -11,29 +11,29 @@ namespace testspr {
|
|||
static void algorithm_unfold_test() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{}};
|
||||
|
||||
// <20>¶<EFBFBD>¬
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::unfold(
|
||||
arr1,
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 10>{{2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}}
|
||||
array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::fit::unfold(
|
||||
arr1,
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 10>{{2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}}
|
||||
array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}
|
||||
));
|
||||
}
|
||||
// <20>¶<EFBFBD>¬
|
||||
|
@ -41,31 +41,31 @@ namespace testspr {
|
|||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::unfold(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 6>{{2, 4, 8, 16, 32, 64}}
|
||||
array<int, 6>{{1, 2, 3, 4, 5, 6}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(unfolded),
|
||||
array<int, 10>{{1, 2, 2, 4, 8, 16, 32, 64, 9, 10}}
|
||||
array<int, 10>{{0, 0, 1, 2, 3, 4, 5, 6, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::fit::unfold(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
testspr::x2<int>(),
|
||||
2
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 6>{{2, 4, 8, 16, 32, 64}}
|
||||
array<int, 6>{{1, 2, 3, 4, 5, 6}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(unfolded),
|
||||
array<int, 10>{{1, 2, 2, 4, 8, 16, 32, 64, 9, 10}}
|
||||
array<int, 10>{{0, 0, 1, 2, 3, 4, 5, 6, 0, 0}}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,31 +11,31 @@ namespace testspr {
|
|||
static void algorithm_unfold_n_test() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto arr1 = array<int, 10>{{}};
|
||||
|
||||
// <20>¶<EFBFBD>¬
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::unfold_n(
|
||||
arr1,
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 10>{{1, 2, 4, 8, 5, 6, 7, 8, 9, 10}}
|
||||
array<int, 10>{{1, 2, 3, 4, 0, 0, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::fit::unfold_n(
|
||||
arr1,
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 4>{{1, 2, 4, 8}}
|
||||
array<int, 4>{{1, 2, 3, 4}}
|
||||
));
|
||||
}
|
||||
// <20>¶<EFBFBD>¬
|
||||
|
@ -44,32 +44,32 @@ namespace testspr {
|
|||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::unfold_n(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 6>{{1, 2, 4, 8, 7, 8}}
|
||||
array<int, 6>{{1, 2, 3, 4, 0, 0}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(unfolded),
|
||||
array<int, 10>{{1, 2, 1, 2, 4, 8, 7, 8, 9, 10}}
|
||||
array<int, 10>{{0, 0, 1, 2, 3, 4, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto unfolded = sprout::fit::unfold_n(
|
||||
sprout::sub(arr1, 2, 8),
|
||||
4,
|
||||
testspr::x2<int>(),
|
||||
testspr::unf_iota<int>(),
|
||||
1
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
unfolded,
|
||||
array<int, 4>{{1, 2, 4, 8}}
|
||||
array<int, 4>{{1, 2, 3, 4}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(unfolded),
|
||||
array<int, 10>{{1, 2, 1, 2, 4, 8, 7, 8, 9, 10}}
|
||||
array<int, 10>{{0, 0, 1, 2, 3, 4, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -176,6 +176,22 @@ namespace testspr {
|
|||
{}
|
||||
SPROUT_CONSTEXPR result operator()() const { return result{val, gen_iota(val + 1)}; }
|
||||
};
|
||||
//
|
||||
// unf_iota
|
||||
//
|
||||
template<typename T>
|
||||
struct unf_iota {
|
||||
public:
|
||||
struct result {
|
||||
public:
|
||||
T val;
|
||||
public:
|
||||
SPROUT_CONSTEXPR T const& generated_value() const { return val; }
|
||||
SPROUT_CONSTEXPR T const& next_generator() const { return val; }
|
||||
};
|
||||
public:
|
||||
SPROUT_CONSTEXPR result operator()(T const& val) const { return result{val + 1}; }
|
||||
};
|
||||
|
||||
//
|
||||
// distance
|
||||
|
|
Loading…
Reference in a new issue