mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-05-10 09:23:30 +00:00
fix recursion depth O(logN): some algorithms
This commit is contained in:
parent
28697ee7a8
commit
5019f6aa96
162 changed files with 3600 additions and 1659 deletions
|
@ -43,6 +43,72 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::adjacent_find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::less_than<int>(11)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::less_than<int>(6)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(11)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(6)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::less_than<int>(11)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::less_than<int>(6)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(11)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::all_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(6)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::any_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 0);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
5
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
11
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 0);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
5
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 2);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
11
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 0);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
5
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 4);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
11
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 0);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
5
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 2);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
11
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -38,12 +38,80 @@ namespace testspr {
|
|||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
sprout::begin(arr1),
|
||||
sprout::begin(arr1) + 5,
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::is_odd<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::less_than<int>(8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::is_odd<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::is_odd<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::less_than<int>(8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::is_odd<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::count_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result == 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -83,6 +83,148 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::equal(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
8
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
11
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
8
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
11
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
8
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
11
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
8
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
11
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -91,6 +91,127 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 2);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 2);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 2);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_end(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -91,6 +91,164 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::reduct_forward(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::reduct_forward(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3))
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::reduct_random_access(sprout::end(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 3);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_first_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::reduct_random_access(sprout::end(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(7)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(7)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(7)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(7)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::less_than<int>(8)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::less_than<int>(11)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(8)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(11)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::less_than<int>(8)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::less_than<int>(11)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::end(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(8)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::find_if_not(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::less_than<int>(11)
|
||||
).base();
|
||||
TESTSPR_BOTH_ASSERT(found == sprout::begin(arr1) + 5);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -83,6 +83,148 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::end(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_forward(sprout::begin(arr1)),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_forward(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::is_permutation(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -83,6 +83,148 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first == sprout::begin(arr1));
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_input(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3))
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 7);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr2)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1) + 5);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto found = sprout::mismatch(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::reduct_random_access(sprout::begin(arr3)),
|
||||
testspr::equal_to<int>()
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(found.first.base() == sprout::begin(arr1));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(5)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::none_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(10)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -44,6 +44,74 @@ namespace testspr {
|
|||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(4)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(9)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(4)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_input(sprout::begin(arr1)),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(9)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(4)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::end(arr1)),
|
||||
testspr::greater_than<int>(9)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(4)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(result);
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto result = sprout::one_of(
|
||||
testspr::reduct_random_access(sprout::begin(arr1)),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 5),
|
||||
testspr::greater_than<int>(9)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(!result);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator
|
||||
adjacent_find_impl_ra_1(RandomAccessIterator found, RandomAccessIterator last) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(found, last) == 1 ? last
|
||||
adjacent_find_impl_check_ra(RandomAccessIterator found, RandomAccessIterator last) {
|
||||
return sprout::distance(found, last) == 1 ? last
|
||||
: found
|
||||
;
|
||||
}
|
||||
|
@ -27,7 +28,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (pred(*first, *last) ? first : last)
|
||||
: sprout::detail::adjacent_find_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2,
|
||||
(sprout::distance(first, last) - pivot) / 2,
|
||||
sprout::detail::adjacent_find_impl_ra(
|
||||
first, sprout::next(first, pivot), pred,
|
||||
pivot / 2,
|
||||
|
@ -37,30 +38,70 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
RandomAccessIterator
|
||||
>::type
|
||||
adjacent_find(
|
||||
RandomAccessIterator first, RandomAccessIterator last, BinaryPredicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last || NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) == 1 ? last
|
||||
: adjacent_find_impl_ra_1(
|
||||
return first == last || sprout::distance(first, last) == 1 ? last
|
||||
: adjacent_find_impl_check_ra(
|
||||
sprout::detail::adjacent_find_impl_ra(
|
||||
first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1), pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1) / 2, first
|
||||
first, sprout::next(first, sprout::distance(first, last) - 1), pred,
|
||||
(sprout::distance(first, last) - 1) / 2, first
|
||||
),
|
||||
last
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
template<typename ForwardIterator>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find_impl(ForwardIterator first, ForwardIterator next, ForwardIterator last, BinaryPredicate pred) {
|
||||
return next == last ? last
|
||||
: pred(*first, *next) ? first
|
||||
: sprout::detail::adjacent_find_impl(next, sprout::next(next), last, pred)
|
||||
adjacent_find_impl_check(sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> const& current) {
|
||||
return !sprout::tuples::get<2>(current) ? sprout::tuples::get<1>(current)
|
||||
: sprout::tuples::get<0>(current)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool>
|
||||
adjacent_find_impl_1(
|
||||
sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> const& current,
|
||||
ForwardIterator last, BinaryPredicate pred, typename std::iterator_traits<ForwardIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> type;
|
||||
return sprout::tuples::get<2>(current) || sprout::tuples::get<1>(current) == last ? current
|
||||
: n == 1 ? pred(*sprout::tuples::get<0>(current), *sprout::tuples::get<1>(current))
|
||||
? type(sprout::tuples::get<0>(current), sprout::tuples::get<1>(current), true)
|
||||
: type(sprout::tuples::get<1>(current), sprout::next(sprout::tuples::get<1>(current)), false)
|
||||
: sprout::detail::adjacent_find_impl_1(
|
||||
sprout::detail::adjacent_find_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool>
|
||||
adjacent_find_impl(
|
||||
sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> const& current,
|
||||
ForwardIterator last, BinaryPredicate pred, typename std::iterator_traits<ForwardIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> type;
|
||||
return sprout::tuples::get<2>(current) || sprout::tuples::get<1>(current) == last ? current
|
||||
: sprout::detail::adjacent_find_impl(
|
||||
sprout::detail::adjacent_find_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
|
@ -70,8 +111,11 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<ForwardIterator, ForwardIterator, bool> type;
|
||||
return first == last ? last
|
||||
: sprout::detail::adjacent_find_impl(first, sprout::next(first), last, pred)
|
||||
: sprout::detail::adjacent_find_impl_check(
|
||||
sprout::detail::adjacent_find_impl(type(first, sprout::next(first), false), last, pred, 1)
|
||||
)
|
||||
;
|
||||
}
|
||||
} //namespace detail
|
||||
|
@ -79,8 +123,7 @@ namespace sprout {
|
|||
// 25.2.8 Adjacent find
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename ForwardIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_ALL_OF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,28 +24,60 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::all_of_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
bool
|
||||
>::type
|
||||
all_of(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? true
|
||||
: sprout::detail::all_of_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::all_of_impl_ra(first, last, pred, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
all_of_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? true
|
||||
: pred(*first) && sprout::detail::all_of_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
all_of_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return !current.second || current.first == last ? current
|
||||
: n == 1 ? pred(*current.first) ? type(sprout::next(current.first), true) : type(current.first, false)
|
||||
: sprout::detail::all_of_impl_1(
|
||||
sprout::detail::all_of_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
all_of_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return !current.second || current.first == last ? current
|
||||
: sprout::detail::all_of_impl(
|
||||
sprout::detail::all_of_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -53,15 +87,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::all_of_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::all_of_impl(type(first, true), last, pred, 1).second;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.1 All of
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,7 +21,7 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::all_of_equal_impl_ra(
|
||||
sprout::next(first, pivot), last, value,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -34,7 +33,7 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
return first == last ? true
|
||||
: sprout::detail::all_of_equal_impl_ra(first, last, value, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::all_of_equal_impl_ra(first, last, value, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_ANY_OF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,28 +24,60 @@ namespace sprout {
|
|||
)
|
||||
|| sprout::detail::any_of_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
bool
|
||||
>::type
|
||||
any_of(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? false
|
||||
: sprout::detail::any_of_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::any_of_impl_ra(first, last, pred, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
any_of_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? false
|
||||
: pred(*first) || sprout::detail::any_of_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
any_of_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: n == 1 ? pred(*current.first) ? type(current.first, true) : type(sprout::next(current.first), false)
|
||||
: sprout::detail::any_of_impl_1(
|
||||
sprout::detail::any_of_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
any_of_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: sprout::detail::any_of_impl(
|
||||
sprout::detail::any_of_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -53,15 +87,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::any_of_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::any_of_impl(type(first, false), last, pred, 1).second;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.2 Any of
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,7 +21,7 @@ namespace sprout {
|
|||
)
|
||||
|| sprout::detail::any_of_equal_impl_ra(
|
||||
sprout::next(first, pivot), last, value,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -34,7 +33,7 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
return first == last ? false
|
||||
: sprout::detail::any_of_equal_impl_ra(first, last, value, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::any_of_equal_impl_ra(first, last, value, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_COUNT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,28 +24,60 @@ namespace sprout {
|
|||
)
|
||||
+ sprout::detail::count_impl_ra(
|
||||
sprout::next(first, pivot), last, value,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
>::type
|
||||
count(
|
||||
RandomAccessIterator first, RandomAccessIterator last, T const& value,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? 0
|
||||
: sprout::detail::count_impl_ra(first, last, value, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::count_impl_ra(first, last, value, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_impl(InputIterator first, InputIterator last, T const& value) {
|
||||
return first == last ? 0
|
||||
: (*first == value ? 1 : 0) + sprout::detail::count_impl(sprout::next(first), last, value)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_impl_1(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, T const& value, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.first == last ? current
|
||||
: n == 1 ? type(sprout::next(current.first), current.second + (*current.first == value ? 1 : 0))
|
||||
: sprout::detail::count_impl_1(
|
||||
sprout::detail::count_impl_1(
|
||||
current,
|
||||
last, value, n / 2
|
||||
),
|
||||
last, value, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_impl(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, T const& value, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.first == last ? current
|
||||
: sprout::detail::count_impl(
|
||||
sprout::detail::count_impl_1(
|
||||
current,
|
||||
last, value, n
|
||||
),
|
||||
last, value, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename T>
|
||||
|
@ -53,15 +87,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::count_impl(first, last, value);
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return sprout::detail::count_impl(type(first, 0), last, value, 1).second;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.9 Count
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_COUNT_IF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,28 +24,60 @@ namespace sprout {
|
|||
)
|
||||
+ sprout::detail::count_if_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
>::type
|
||||
count_if(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? 0
|
||||
: sprout::detail::count_if_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::count_if_impl_ra(first, last, pred, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_if_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? 0
|
||||
: (pred(*first) ? 1 : 0) + sprout::detail::count_if_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_if_impl_1(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.first == last ? current
|
||||
: n == 1 ? type(sprout::next(current.first), current.second + (pred(*current.first) ? 1 : 0))
|
||||
: sprout::detail::count_if_impl_1(
|
||||
sprout::detail::count_if_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_if_impl(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.first == last ? current
|
||||
: sprout::detail::count_if_impl(
|
||||
sprout::detail::count_if_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -53,15 +87,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::count_if_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return sprout::detail::count_if_impl(type(first, 0), last, pred, 1).second;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.9 Count
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -24,7 +24,7 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::equal_impl_ra(
|
||||
sprout::next(first1, pivot), last1, sprout::next(first2, pivot), pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2
|
||||
(sprout::distance(first1, last1) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -38,17 +38,48 @@ namespace sprout {
|
|||
return first1 == last1 ? true
|
||||
: sprout::detail::equal_impl_ra(
|
||||
first1, last1, first2, pred,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2
|
||||
sprout::distance(first1, last1) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
equal_impl(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred) {
|
||||
return first1 == last1 ? true
|
||||
: pred(*first1, *first2) && sprout::detail::equal_impl(sprout::next(first1), last1, sprout::next(first2), pred)
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, bool>
|
||||
equal_impl_1(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, bool> const& current,
|
||||
InputIterator1 last1, BinaryPredicate pred, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return !sprout::tuples::get<2>(current) || sprout::tuples::get<0>(current) == last1 ? current
|
||||
: n == 1 ? pred(*sprout::tuples::get<0>(current), *sprout::tuples::get<1>(current))
|
||||
? type(sprout::next(sprout::tuples::get<0>(current)), sprout::next(sprout::tuples::get<1>(current)), true)
|
||||
: type(sprout::tuples::get<0>(current), sprout::tuples::get<1>(current), false)
|
||||
: sprout::detail::equal_impl_1(
|
||||
sprout::detail::equal_impl_1(
|
||||
current,
|
||||
last1, pred, n / 2
|
||||
),
|
||||
last1, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, bool>
|
||||
equal_impl(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, bool> const& current,
|
||||
InputIterator1 last1, BinaryPredicate pred, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return !sprout::tuples::get<2>(current) || sprout::tuples::get<0>(current) == last1 ? current
|
||||
: sprout::detail::equal_impl(
|
||||
sprout::detail::equal_impl_1(
|
||||
current,
|
||||
last1, pred, n
|
||||
),
|
||||
last1, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
|
@ -58,15 +89,17 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::equal_impl(first1, last1, first2, pred);
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return sprout::tuples::get<2>(
|
||||
sprout::detail::equal_impl(type(first1, first2, true), last1, pred, 1)
|
||||
);
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.11 Equal
|
||||
//
|
||||
// recursion depth:
|
||||
// [first1, last1), first2 are RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_FIND_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -19,7 +21,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (*first == value ? first : last)
|
||||
: sprout::detail::find_impl_ra(
|
||||
sprout::next(first, pivot), last, value,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2,
|
||||
(sprout::distance(first, last) - pivot) / 2,
|
||||
sprout::detail::find_impl_ra(
|
||||
first, sprout::next(first, pivot), value,
|
||||
pivot / 2,
|
||||
|
@ -29,23 +31,55 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
RandomAccessIterator
|
||||
>::type
|
||||
find(
|
||||
RandomAccessIterator first, RandomAccessIterator last, T const& value,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? last
|
||||
: sprout::detail::find_impl_ra(first, last, value, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, first)
|
||||
: sprout::detail::find_impl_ra(first, last, value, sprout::distance(first, last) / 2, first)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
find_impl(InputIterator first, InputIterator last, T const& value) {
|
||||
return first == last || *first == value ? first
|
||||
: sprout::detail::find_impl(sprout::next(first), last, value)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, T const& value, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: n == 1 ? *current.first == value ? type(current.first, true) : type(sprout::next(current.first), false)
|
||||
: sprout::detail::find_impl_1(
|
||||
sprout::detail::find_impl_1(
|
||||
current,
|
||||
last, value, n / 2
|
||||
),
|
||||
last, value, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, T const& value, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: sprout::detail::find_impl(
|
||||
sprout::detail::find_impl_1(
|
||||
current,
|
||||
last, value, n
|
||||
),
|
||||
last, value, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename T>
|
||||
|
@ -55,15 +89,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::find_impl(first, last, value);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::find_impl(type(first, false), last, value, 1).first;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.5 Find
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/search.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/detail/algorithm/search_one.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename RandomAccessIterator1>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator1
|
||||
find_end_impl_ra_1(RandomAccessIterator1 first1, RandomAccessIterator1 result, RandomAccessIterator1 searched) {
|
||||
find_end_impl_check_ra(RandomAccessIterator1 first1, RandomAccessIterator1 result, RandomAccessIterator1 searched) {
|
||||
return searched == first1 ? searched
|
||||
: result
|
||||
;
|
||||
|
@ -29,13 +29,13 @@ namespace sprout {
|
|||
{
|
||||
return searched == last1_ ? result
|
||||
: searched < first1 ? pivot == 0
|
||||
? sprout::detail::find_end_impl_ra_1(
|
||||
? sprout::detail::find_end_impl_check_ra(
|
||||
first1, searched,
|
||||
sprout::detail::search_one(first1, last1_, first2, last2, pred)
|
||||
)
|
||||
: sprout::detail::find_end_impl_ra(
|
||||
sprout::next(first1, pivot), last1, first2, last2, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2, last1_, searched,
|
||||
(sprout::distance(first1, last1) - pivot) / 2, last1_, searched,
|
||||
sprout::detail::find_end_impl_ra(
|
||||
first1, sprout::next(first1, pivot), first2, last2, pred,
|
||||
pivot / 2, last1_, searched,
|
||||
|
@ -45,7 +45,7 @@ namespace sprout {
|
|||
: pivot == 0 ? sprout::detail::search_one(first1, last1_, first2, last2, pred)
|
||||
: sprout::detail::find_end_impl_ra(
|
||||
sprout::next(first1, pivot), last1, first2, last2, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2, last1_, result,
|
||||
(sprout::distance(first1, last1) - pivot) / 2, last1_, result,
|
||||
sprout::detail::find_end_impl_ra(
|
||||
first1, sprout::next(first1, pivot), first2, last2, pred,
|
||||
pivot / 2, last1_, result,
|
||||
|
@ -55,7 +55,10 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator1
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator1>::value,
|
||||
RandomAccessIterator1
|
||||
>::type
|
||||
find_end(
|
||||
RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
|
@ -66,25 +69,60 @@ namespace sprout {
|
|||
return first1 == last1 ? last1
|
||||
: sprout::detail::find_end_impl_ra(
|
||||
first1, last1, first2, last2, pred,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2, last1, last1,
|
||||
sprout::distance(first1, last1) / 2, last1, last1,
|
||||
first1
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
template<typename ForwardIterator1>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator1, ForwardIterator1>
|
||||
find_end_impl_check(sprout::pair<ForwardIterator1, ForwardIterator1> const& current, ForwardIterator1 last1, ForwardIterator1 searched) {
|
||||
typedef sprout::pair<ForwardIterator1, ForwardIterator1> type;
|
||||
return searched == current.first ? type(sprout::next(current.first), searched)
|
||||
: searched == last1 ? type(last1, current.second)
|
||||
: type(sprout::next(current.first), current.second)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
find_end_impl(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred,
|
||||
ForwardIterator1 result
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator1, ForwardIterator1>
|
||||
find_end_impl_1(
|
||||
sprout::pair<ForwardIterator1, ForwardIterator1> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
return first1 == last1 ? result
|
||||
typedef sprout::pair<ForwardIterator1, ForwardIterator1> type;
|
||||
return current.first == last1 ? current
|
||||
: n == 1 ? sprout::detail::find_end_impl_check(
|
||||
current, last1,
|
||||
sprout::detail::search_one(current.first, last1, first2, last2, pred)
|
||||
)
|
||||
: sprout::detail::find_end_impl_1(
|
||||
sprout::detail::find_end_impl_1(
|
||||
current,
|
||||
last1, first2, last2, pred, n / 2
|
||||
),
|
||||
last1, first2, last2, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator1, ForwardIterator1>
|
||||
find_end_impl(
|
||||
sprout::pair<ForwardIterator1, ForwardIterator1> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<ForwardIterator1, ForwardIterator1> type;
|
||||
return current.first == last1 ? current
|
||||
: sprout::detail::find_end_impl(
|
||||
sprout::search(sprout::next(first1), last1, first2, last2, pred), last1, first2, last2, pred,
|
||||
first1
|
||||
sprout::detail::find_end_impl_1(
|
||||
current,
|
||||
last1, first2, last2, pred, n
|
||||
),
|
||||
last1, first2, last2, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -97,22 +135,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return first2 == last2 ? last1
|
||||
: sprout::detail::find_end_impl(
|
||||
sprout::search(first1, last1, first2, last2, pred), last1, first2, last2, pred,
|
||||
last1
|
||||
)
|
||||
;
|
||||
typedef sprout::pair<ForwardIterator1, ForwardIterator1> type;
|
||||
return sprout::detail::find_end_impl(type(first1, last1), last1, first2, last2, pred, 1).second;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// 25.2.6 Find end
|
||||
//
|
||||
// recursion depth:
|
||||
// [first1, last1) is RandomAccessIterator -> O(log N1)
|
||||
// otherwise -> O(N1)
|
||||
// [first2, last2) is RandomAccessIterator -> O(log N2)
|
||||
// otherwise -> O(N2)
|
||||
// O(log (N1+N2))
|
||||
//
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include <sprout/functional/bind2nd.hpp>
|
||||
#include <sprout/algorithm/find_if.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -24,7 +25,7 @@ namespace sprout {
|
|||
: pivot == 0 ? sprout::find_if(first2, last2, sprout::bind2nd(pred, *first1)) != last2 ? first1 : last1
|
||||
: sprout::detail::find_first_of_impl_ra(
|
||||
sprout::next(first1, pivot), last1, first2, last2, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2,
|
||||
(sprout::distance(first1, last1) - pivot) / 2,
|
||||
sprout::detail::find_first_of_impl_ra(
|
||||
first1, sprout::next(first1, pivot), first2, last2, pred,
|
||||
pivot / 2,
|
||||
|
@ -34,7 +35,10 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator1
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator1>::value,
|
||||
RandomAccessIterator1
|
||||
>::type
|
||||
find_first_of(
|
||||
RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
|
@ -45,22 +49,50 @@ namespace sprout {
|
|||
return first1 == last1 ? last1
|
||||
: sprout::detail::find_first_of_impl_ra(
|
||||
first1, last1, first2, last2,
|
||||
pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2, first1
|
||||
pred, sprout::distance(first1, last1) / 2, first1
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
find_first_of_impl(
|
||||
InputIterator1 first1, InputIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, bool>
|
||||
find_first_of_impl_1(
|
||||
sprout::pair<InputIterator1, bool> current,
|
||||
InputIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
return first1 == last1 || sprout::find_if(first2, last2, sprout::bind2nd(pred, *first1)) != last2 ? first1
|
||||
: sprout::detail::find_first_of_impl(sprout::next(first1), last1, first2, last2, pred)
|
||||
typedef sprout::pair<InputIterator1, bool> type;
|
||||
return current.second || current.first == last1 ? current
|
||||
: n == 1 ? sprout::find_if(first2, last2, sprout::bind2nd(pred, *current.first)) != last2
|
||||
? type(current.first, true)
|
||||
: type(sprout::next(current.first), false)
|
||||
: sprout::detail::find_first_of_impl_1(
|
||||
sprout::detail::find_first_of_impl_1(
|
||||
current,
|
||||
last1, first2, last2, pred, n / 2
|
||||
),
|
||||
last1, first2, last2, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, bool>
|
||||
find_first_of_impl(
|
||||
sprout::pair<InputIterator1, bool> current,
|
||||
InputIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator1, bool> type;
|
||||
return current.second || current.first == last1 ? current
|
||||
: sprout::detail::find_first_of_impl(
|
||||
sprout::detail::find_first_of_impl_1(
|
||||
current,
|
||||
last1, first2, last2, pred, n
|
||||
),
|
||||
last1, first2, last2, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
|
@ -72,17 +104,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::find_first_of_impl(first1, last1, first2, last2, pred);
|
||||
typedef sprout::pair<InputIterator1, bool> type;
|
||||
return sprout::detail::find_first_of_impl(type(first1, false), last1, first2, last2, pred, 1).first;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.7 Find first
|
||||
//
|
||||
// recursion depth:
|
||||
// [first1, last1) is RandomAccessIterator -> O(log N1)
|
||||
// otherwise -> O(N1)
|
||||
// [first2, last2) is RandomAccessIterator -> O(log N2)
|
||||
// otherwise -> O(N2)
|
||||
// O(log (N1+N2))
|
||||
//
|
||||
template<typename InputIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator1
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_FIND_IF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -19,7 +21,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (pred(*first) ? first : last)
|
||||
: sprout::detail::find_if_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2,
|
||||
(sprout::distance(first, last) - pivot) / 2,
|
||||
sprout::detail::find_if_impl_ra(
|
||||
first, sprout::next(first, pivot), pred,
|
||||
pivot / 2,
|
||||
|
@ -29,23 +31,55 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
RandomAccessIterator
|
||||
>::type
|
||||
find_if(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? last
|
||||
: sprout::detail::find_if_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, first)
|
||||
: sprout::detail::find_if_impl_ra(first, last, pred, sprout::distance(first, last) / 2, first)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
find_if_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last || pred(*first) ? first
|
||||
: sprout::detail::find_if_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_if_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: n == 1 ? pred(*current.first) ? type(current.first, true) : type(sprout::next(current.first), false)
|
||||
: sprout::detail::find_if_impl_1(
|
||||
sprout::detail::find_if_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_if_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: sprout::detail::find_if_impl(
|
||||
sprout::detail::find_if_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -55,15 +89,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::find_if_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::find_if_impl(type(first, false), last, pred, 1).first;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.5 Find
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_FIND_IF_NOT_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -19,7 +21,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (!pred(*first) ? first : last)
|
||||
: sprout::detail::find_if_not_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2,
|
||||
(sprout::distance(first, last) - pivot) / 2,
|
||||
sprout::detail::find_if_not_impl_ra(
|
||||
first, sprout::next(first, pivot), pred,
|
||||
pivot / 2,
|
||||
|
@ -29,23 +31,55 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR RandomAccessIterator
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
RandomAccessIterator
|
||||
>::type
|
||||
find_if_not(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? last
|
||||
: sprout::detail::find_if_not_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2, first)
|
||||
: sprout::detail::find_if_not_impl_ra(first, last, pred, sprout::distance(first, last) / 2, first)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
find_if_not_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last || !pred(*first) ? first
|
||||
: sprout::detail::find_if_not_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_if_not_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: n == 1 ? !pred(*current.first) ? type(current.first, true) : type(sprout::next(current.first), false)
|
||||
: sprout::detail::find_if_not_impl_1(
|
||||
sprout::detail::find_if_not_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
find_if_not_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return current.second || current.first == last ? current
|
||||
: sprout::detail::find_if_not_impl(
|
||||
sprout::detail::find_if_not_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -55,15 +89,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::find_if_not_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::find_if_not_impl(type(first, false), last, pred, 1).first;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.5 Find
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -26,7 +26,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::clamp_range_copy(first, last, result, low, high, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -58,7 +58,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::clamp_range_copy(first, last, result, low, high)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::copy(first, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
|||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::copy_backward(first, last, result)),
|
||||
offset - NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result)),
|
||||
offset - NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result)),
|
||||
offset
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -24,7 +24,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::copy_until(first, last, result, pred)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if(first, last, pred)),
|
||||
sprout::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if(first, last, pred)),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -24,7 +24,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::copy_while(first, last, result, pred)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if_not(first, last, pred)),
|
||||
sprout::distance(first, NS_SSCRISK_CEL_OR_SPROUT::find_if_not(first, last, pred)),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/algorithm/fixed/make_partial_heap.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::make_partial_heap(cont, middle, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
offset + sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -46,7 +46,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::make_partial_heap(cont, middle)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
offset + sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -26,7 +26,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::merge(first1, last1, first2, last2, result, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) + NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2),
|
||||
sprout::distance(first1, last1) + sprout::distance(first2, last2),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
@ -60,7 +60,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::merge(first1, last1, first2, last2, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) + NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2),
|
||||
sprout::distance(first1, last1) + sprout::distance(first2, last2),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/algorithm/fixed/nth_element.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::nth_element(cont, nth, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), nth) + 1
|
||||
offset + sprout::distance(sprout::begin(cont), nth) + 1
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -46,7 +46,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::nth_element(cont, nth)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), nth) + 1
|
||||
offset + sprout::distance(sprout::begin(cont), nth) + 1
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/algorithm/fixed/partial_sort.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::partial_sort(cont, middle, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
offset + sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -46,7 +46,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::partial_sort(cont, middle)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
offset + sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/detail/algorithm/count_n_if.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
|
@ -28,7 +28,7 @@ namespace sprout {
|
|||
offset + sprout::detail::count_n_if(
|
||||
first,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last),
|
||||
sprout::distance(first, last),
|
||||
sprout::size(result)
|
||||
),
|
||||
pred
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -24,7 +24,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::remove_copy(first, last, result, value)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count(first, last, value),
|
||||
sprout::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count(first, last, value),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -24,7 +24,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::remove_copy_if(first, last, result, pred)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count_if(first, last, pred),
|
||||
sprout::distance(first, last) - NS_SSCRISK_CEL_OR_SPROUT::count_if(first, last, pred),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::replace_copy(first, last, result, old_value, new_value)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::replace_copy_if(first, last, result, pred, new_value)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::reverse_copy(first, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::rotate_copy(first, middle, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/detail/algorithm/set_overlap_count.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -27,7 +27,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_difference(first1, last1, first2, last2, result, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
sprout::distance(first1, last1)
|
||||
- sprout::detail::set_overlap_count(first1, last1, first2, last2, comp)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
@ -63,7 +63,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_difference(first1, last1, first2, last2, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
sprout::distance(first1, last1)
|
||||
- sprout::detail::set_overlap_count(first1, last1, first2, last2)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/detail/algorithm/set_overlap_count.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
+ NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2)
|
||||
sprout::distance(first1, last1)
|
||||
+ sprout::distance(first2, last2)
|
||||
- 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2, comp)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
@ -64,8 +64,8 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_symmetric_difference(first1, last1, first2, last2, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
+ NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2)
|
||||
sprout::distance(first1, last1)
|
||||
+ sprout::distance(first2, last2)
|
||||
- 2 * sprout::detail::set_overlap_count(first1, last1, first2, last2)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/detail/algorithm/set_overlap_count.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -27,8 +27,8 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_union(first1, last1, first2, last2, result, comp)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
+ NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2)
|
||||
sprout::distance(first1, last1)
|
||||
+ sprout::distance(first2, last2)
|
||||
- sprout::detail::set_overlap_count(first1, last1, first2, last2, comp)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
@ -64,8 +64,8 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::set_union(first1, last1, first2, last2, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
+ NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2)
|
||||
sprout::distance(first1, last1)
|
||||
+ sprout::distance(first2, last2)
|
||||
- sprout::detail::set_overlap_count(first1, last1, first2, last2)
|
||||
,
|
||||
sprout::size(result)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::swap_element_copy(first, last, result, pos1, pos2)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -23,7 +23,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::transform(first, last, result, op)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first, last), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -47,7 +47,7 @@ namespace sprout {
|
|||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::transform(first1, last1, first2, result, op)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), sprout::size(result))
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(sprout::distance(first1, last1), sprout::size(result))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/detail/algorithm/overlap_count.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
|
@ -25,7 +25,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::unique_copy(first, last, result)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - sprout::detail::overlap_count(first, last),
|
||||
sprout::distance(first, last) - sprout::detail::overlap_count(first, last),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
@ -52,7 +52,7 @@ namespace sprout {
|
|||
sprout::get_internal(sprout::fixed::unique_copy(first, last, result, pred)),
|
||||
offset,
|
||||
offset + NS_SSCRISK_CEL_OR_SPROUT::min(
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - sprout::detail::overlap_count(first, last, pred),
|
||||
sprout::distance(first, last) - sprout::detail::overlap_count(first, last, pred),
|
||||
sprout::size(result)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/algorithm/clamp.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -54,7 +53,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Compare, typename... Args>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/math/comparison.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -47,7 +46,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename... Args>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/math/comparison.hpp>
|
||||
#include <sprout/detail/container_complate_backward.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -47,7 +46,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_end_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename BidirectionalIterator, typename Result, typename... Args>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/algorithm/fixed/swap_element.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -205,7 +204,7 @@ namespace sprout {
|
|||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::internal_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::internal_begin(cont), sprout::end(cont) - 1),
|
||||
sprout::distance(sprout::internal_begin(cont), sprout::end(cont) - 1),
|
||||
comp
|
||||
);
|
||||
}
|
||||
|
@ -226,7 +225,7 @@ namespace sprout {
|
|||
return sprout::fixed::detail::sort_start(
|
||||
cont,
|
||||
sprout::internal_begin_offset(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::internal_begin(cont), sprout::end(cont) - 1),
|
||||
sprout::distance(sprout::internal_begin(cont), sprout::end(cont) - 1),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Container>::value_type>()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/algorithm/fixed/pop_heap.hpp>
|
||||
#include <sprout/algorithm/fixed/make_heap.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -69,7 +68,7 @@ namespace sprout {
|
|||
cont, comp,
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
//
|
||||
|
@ -82,7 +81,7 @@ namespace sprout {
|
|||
cont, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Container>::value_type>(),
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -33,7 +32,7 @@ namespace sprout {
|
|||
)
|
||||
: sprout::fixed::detail::next_permutation_impl_4<Result>(
|
||||
sprout::fixed::swap_element(cont, i, sprout::prev(j)),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, ii)
|
||||
sprout::distance(first, ii)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <sprout/algorithm/fixed/swap_element.hpp>
|
||||
#include <sprout/algorithm/fixed/make_partial_heap.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -54,7 +53,7 @@ namespace sprout {
|
|||
cont, comp,
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), nth)
|
||||
sprout::distance(sprout::begin(cont), nth)
|
||||
);
|
||||
}
|
||||
template<typename Container>
|
||||
|
@ -64,7 +63,7 @@ namespace sprout {
|
|||
cont, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Container>::value_type>(),
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), nth)
|
||||
sprout::distance(sprout::begin(cont), nth)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <sprout/algorithm/fixed/make_partial_heap.hpp>
|
||||
#include <sprout/algorithm/fixed/sort_heap.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -38,7 +38,7 @@ namespace sprout {
|
|||
cont, comp,
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
template<typename Container>
|
||||
|
@ -48,7 +48,7 @@ namespace sprout {
|
|||
cont, NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Container>::value_type>(),
|
||||
sprout::internal_begin_offset(cont),
|
||||
sprout::size(cont),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), middle)
|
||||
sprout::distance(sprout::begin(cont), middle)
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <sprout/sub_array.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -33,7 +32,7 @@ namespace sprout {
|
|||
)
|
||||
: sprout::fixed::detail::prev_permutation_impl_4<Result>(
|
||||
sprout::fixed::swap_element(cont, i, sprout::prev(j)),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, ii)
|
||||
sprout::distance(first, ii)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -50,7 +49,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename T, typename... Args>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -49,7 +48,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename T, typename Predicate, typename... Args>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename BidirectionalIterator, typename Result, typename... Args>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -30,9 +29,9 @@ namespace sprout {
|
|||
result,
|
||||
sprout::size(result),
|
||||
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
|
||||
? (Indexes < offset + NS_SSCRISK_CEL_OR_SPROUT::distance(middle, last)
|
||||
? (Indexes < offset + sprout::distance(middle, last)
|
||||
? middle[Indexes - offset]
|
||||
: first[(Indexes - offset) - NS_SSCRISK_CEL_OR_SPROUT::distance(first, middle)]
|
||||
: first[(Indexes - offset) - sprout::distance(first, middle)]
|
||||
)
|
||||
: *sprout::next(sprout::internal_begin(result), Indexes)
|
||||
)...
|
||||
|
@ -54,7 +53,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -56,7 +55,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename ForwardIterator, typename Result, typename... Args>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/detail/container_complate.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
|
@ -49,7 +48,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename UnaryOperation, typename... Args>
|
||||
|
@ -139,7 +138,7 @@ namespace sprout {
|
|||
sprout::index_range<0, sprout::container_traits<Result>::static_size>::make(),
|
||||
sprout::internal_begin_offset(result),
|
||||
sprout::size(result),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)
|
||||
sprout::distance(first1, last1)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Result, typename BinaryOperation, typename... Args>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -27,7 +26,7 @@ namespace sprout {
|
|||
pivot / 2
|
||||
),
|
||||
last2, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2
|
||||
(sprout::distance(first1, last1) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -41,7 +40,7 @@ namespace sprout {
|
|||
return first1 == last1 ? first2 == last2
|
||||
: sprout::detail::includes_impl_ra(
|
||||
first1, last1, first2, last2, comp,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2
|
||||
sprout::distance(first1, last1) / 2
|
||||
)
|
||||
== last2
|
||||
;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -54,7 +53,7 @@ namespace sprout {
|
|||
is_heap_until(RandomAccessIterator first, RandomAccessIterator last, Compare comp) {
|
||||
return sprout::detail::is_heap_until_impl(
|
||||
first, last, comp,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last)
|
||||
sprout::distance(first, last)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include <sprout/functional/bind2nd.hpp>
|
||||
#include <sprout/algorithm/count_if.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/detail/algorithm/count_n_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -16,20 +17,20 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR bool
|
||||
is_permutation_impl_ra(
|
||||
RandomAccessIterator1 first1, RandomAccessIterator1 last1,
|
||||
RandomAccessIterator2 first2, RandomAccessIterator2 last2,
|
||||
RandomAccessIterator2 first2, typename std::iterator_traits<RandomAccessIterator2>::difference_type d2,
|
||||
BinaryPredicate pred,
|
||||
typename std::iterator_traits<RandomAccessIterator1>::difference_type pivot
|
||||
)
|
||||
{
|
||||
return pivot == 0 ? sprout::count_if(first1, last1, sprout::bind2nd(pred, *first1))
|
||||
<= sprout::count_if(first2, last2, sprout::bind2nd(pred, *first1))
|
||||
<= sprout::detail::count_n_if(first2, d2, sprout::bind2nd(pred, *first1))
|
||||
: sprout::detail::is_permutation_impl_ra(
|
||||
first1, last1, first2, last2,
|
||||
first1, last1, first2, d2,
|
||||
pred, pivot / 2
|
||||
)
|
||||
&& sprout::detail::is_permutation_impl_ra(
|
||||
sprout::next(first1, pivot), last1, first2, last2,
|
||||
pred, (NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2
|
||||
sprout::next(first1, pivot), last1, first2, d2,
|
||||
pred, (sprout::distance(first1, last1) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -42,25 +43,52 @@ namespace sprout {
|
|||
{
|
||||
return first1 == last1 ? true
|
||||
: sprout::detail::is_permutation_impl_ra(
|
||||
first1, last1, first2, sprout::next(first2, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)),
|
||||
pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2
|
||||
first1, last1, first2, sprout::distance(first1, last1),
|
||||
pred, sprout::distance(first1, last1) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
is_permutation_impl(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1,
|
||||
ForwardIterator2 first2, ForwardIterator2 last2,
|
||||
BinaryPredicate pred
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator1, bool>
|
||||
is_permutation_impl_1(
|
||||
sprout::pair<ForwardIterator1, bool> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 first2, typename std::iterator_traits<ForwardIterator2>::difference_type d2,
|
||||
BinaryPredicate pred, typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
return first1 == last1 ? true
|
||||
: sprout::count_if(first1, last1, sprout::bind2nd(pred, *first1))
|
||||
<= sprout::count_if(first2, last2, sprout::bind2nd(pred, *first1))
|
||||
&& sprout::detail::is_permutation_impl(sprout::next(first1), last1, first2, last2, pred)
|
||||
typedef sprout::pair<ForwardIterator1, bool> type;
|
||||
return !current.second || current.first == last1 ? current
|
||||
: n == 1 ? sprout::count_if(current.first, last1, sprout::bind2nd(pred, *current.first))
|
||||
<= sprout::detail::count_n_if(first2, d2, sprout::bind2nd(pred, *current.first))
|
||||
? type(sprout::next(current.first), true)
|
||||
: type(current.first, false)
|
||||
: sprout::detail::is_permutation_impl_1(
|
||||
sprout::detail::is_permutation_impl_1(
|
||||
current,
|
||||
last1, first2, d2, pred, n / 2
|
||||
),
|
||||
last1, first2, d2, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<ForwardIterator1, bool>
|
||||
is_permutation_impl(
|
||||
sprout::pair<ForwardIterator1, bool> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 first2, typename std::iterator_traits<ForwardIterator2>::difference_type d2,
|
||||
BinaryPredicate pred, typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<ForwardIterator1, bool> type;
|
||||
return !current.second || current.first == last1 ? current
|
||||
: sprout::detail::is_permutation_impl(
|
||||
sprout::detail::is_permutation_impl_1(
|
||||
current,
|
||||
last1, first2, d2, pred, n
|
||||
),
|
||||
last1, first2, d2, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
|
@ -70,17 +98,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::is_permutation_impl(
|
||||
first1, last1, first2, sprout::next(first2, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1)), pred
|
||||
);
|
||||
typedef sprout::pair<ForwardIterator1, bool> type;
|
||||
return sprout::detail::is_permutation_impl(type(first1, true), last1, first2, sprout::distance(first1, last1), pred, 1).second;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// 25.2.12 Is permutation
|
||||
//
|
||||
// recursion depth:
|
||||
// [first1, last1), first2 are RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N^2)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/is_sorted_until.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -24,7 +23,7 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::is_sorted_impl_ra(
|
||||
sprout::next(first, pivot), last, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -35,10 +34,10 @@ namespace sprout {
|
|||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last || NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) == 1 ? true
|
||||
return first == last || sprout::distance(first, last) == 1 ? true
|
||||
: sprout::detail::is_sorted_impl_ra(
|
||||
first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1), comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1) / 2
|
||||
first, sprout::next(first, sprout::distance(first, last) - 1), comp,
|
||||
(sprout::distance(first, last) - 1) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -20,7 +19,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (comp(*last, *first) ? first : last)
|
||||
: sprout::detail::is_sorted_until_impl_ra(
|
||||
sprout::next(first, pivot), last, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2,
|
||||
(sprout::distance(first, last) - pivot) / 2,
|
||||
sprout::detail::is_sorted_until_impl_ra(
|
||||
first, sprout::next(first, pivot), comp,
|
||||
pivot / 2,
|
||||
|
@ -36,11 +35,11 @@ namespace sprout {
|
|||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last || NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) == 1 ? last
|
||||
return first == last || sprout::distance(first, last) == 1 ? last
|
||||
: sprout::next(
|
||||
sprout::detail::is_sorted_until_impl_ra(
|
||||
first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1), comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1) / 2, first
|
||||
first, sprout::next(first, sprout::distance(first, last) - 1), comp,
|
||||
(sprout::distance(first, last) - 1) / 2, first
|
||||
)
|
||||
)
|
||||
;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/algorithm/min.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -34,7 +33,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (comp(*first1, *first2) || comp(*first2, *first1) ? found_type(first1, first2) : found_type(last1, last2))
|
||||
: sprout::detail::lexicographical_compare_impl_ra_1(
|
||||
sprout::next(first1, pivot), last1, sprout::next(first2, pivot), last2, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2,
|
||||
(sprout::distance(first1, last1) - pivot) / 2,
|
||||
sprout::detail::lexicographical_compare_impl_ra_1(
|
||||
first1, sprout::next(first1, pivot), first2, sprout::next(first2, pivot), comp,
|
||||
pivot / 2,
|
||||
|
@ -70,7 +69,7 @@ namespace sprout {
|
|||
: first1 == last1 ? true
|
||||
: sprout::detail::lexicographical_compare_impl_ra(
|
||||
first1, last1, first2, last2, comp,
|
||||
sprout::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2))
|
||||
sprout::min(sprout::distance(first1, last1), sprout::distance(first2, last2))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -21,9 +20,9 @@ namespace sprout {
|
|||
lower_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) {
|
||||
return first == last ? last
|
||||
: sprout::next(first) == last ? comp(*first, value) ? last : first
|
||||
: comp(*sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value)
|
||||
? sprout::lower_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value, comp)
|
||||
: sprout::lower_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value, comp)
|
||||
: comp(*sprout::next(first, sprout::distance(first, last) / 2), value)
|
||||
? sprout::lower_bound(sprout::next(first, sprout::distance(first, last) / 2), last, value, comp)
|
||||
: sprout::lower_bound(first, sprout::next(first, sprout::distance(first, last) / 2), value, comp)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -30,7 +29,7 @@ namespace sprout {
|
|||
),
|
||||
sprout::detail::max_element_impl_ra(
|
||||
sprout::next(first, pivot), last, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
),
|
||||
comp
|
||||
)
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
return first == last ? last
|
||||
: sprout::detail::max_element_impl_ra(
|
||||
first, last, comp,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2
|
||||
sprout::distance(first, last) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -30,7 +29,7 @@ namespace sprout {
|
|||
),
|
||||
sprout::detail::min_element_impl_ra(
|
||||
sprout::next(first, pivot), last, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
),
|
||||
comp
|
||||
)
|
||||
|
@ -46,7 +45,7 @@ namespace sprout {
|
|||
return first == last ? last
|
||||
: sprout::detail::min_element_impl_ra(
|
||||
first, last, comp,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2
|
||||
sprout::distance(first, last) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -34,7 +33,7 @@ namespace sprout {
|
|||
),
|
||||
sprout::detail::minmax_element_impl_ra(
|
||||
sprout::next(first, pivot), last, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
),
|
||||
comp
|
||||
)
|
||||
|
@ -50,7 +49,7 @@ namespace sprout {
|
|||
return first == last ? sprout::pair<RandomAccessIterator, RandomAccessIterator>(last, last)
|
||||
: sprout::detail::minmax_element_impl_ra(
|
||||
first, last, comp,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2
|
||||
sprout::distance(first, last) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -15,7 +15,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::pair<RandomAccessIterator1, RandomAccessIterator2>
|
||||
mismatch_impl_ra_1(RandomAccessIterator1 first1, RandomAccessIterator2 first2, RandomAccessIterator1 found) {
|
||||
return sprout::pair<RandomAccessIterator1, RandomAccessIterator2>{
|
||||
found, sprout::next(first2, NS_SSCRISK_CEL_OR_SPROUT::distance(first1, found))
|
||||
found, sprout::next(first2, sprout::distance(first1, found))
|
||||
};
|
||||
}
|
||||
template<typename RandomAccessIterator1, typename RandomAccessIterator2, typename BinaryPredicate>
|
||||
|
@ -29,7 +29,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (!pred(*first1, *first2) ? first1 : last1)
|
||||
: sprout::detail::mismatch_impl_ra(
|
||||
sprout::next(first1, pivot), last1, sprout::next(first2, pivot), pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2,
|
||||
(sprout::distance(first1, last1) - pivot) / 2,
|
||||
sprout::detail::mismatch_impl_ra(
|
||||
first1, sprout::next(first1, pivot), first2, pred,
|
||||
pivot / 2,
|
||||
|
@ -50,19 +50,57 @@ namespace sprout {
|
|||
first1, first2,
|
||||
sprout::detail::mismatch_impl_ra(
|
||||
first1, last1, first2, pred,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2, first1
|
||||
sprout::distance(first1, last1) / 2, first1
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
template<typename InputIterator1, typename InputIterator2>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
||||
mismatch_impl(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred) {
|
||||
return first1 == last1 || !pred(*first1, *first2)
|
||||
? sprout::pair<InputIterator1, InputIterator2>{first1, first2}
|
||||
: sprout::detail::mismatch_impl(sprout::next(first1), last1, sprout::next(first2))
|
||||
mismatch_impl_check(sprout::tuples::tuple<InputIterator1, InputIterator2, bool> const& current) {
|
||||
return sprout::pair<InputIterator1, InputIterator2>(
|
||||
sprout::tuples::get<0>(current),
|
||||
sprout::tuples::get<1>(current)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, bool>
|
||||
mismatch_impl_1(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, bool> const& current,
|
||||
InputIterator1 last1, BinaryPredicate pred, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return sprout::tuples::get<2>(current) || sprout::tuples::get<0>(current) == last1 ? current
|
||||
: n == 1 ? !pred(*sprout::tuples::get<0>(current), *sprout::tuples::get<1>(current))
|
||||
? type(sprout::tuples::get<0>(current), sprout::tuples::get<1>(current), true)
|
||||
: type(sprout::next(sprout::tuples::get<0>(current)), sprout::next(sprout::tuples::get<1>(current)), false)
|
||||
: sprout::detail::mismatch_impl_1(
|
||||
sprout::detail::mismatch_impl_1(
|
||||
current,
|
||||
last1, pred, n / 2
|
||||
),
|
||||
last1, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, bool>
|
||||
mismatch_impl(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, bool> const& current,
|
||||
InputIterator1 last1, BinaryPredicate pred, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return sprout::tuples::get<2>(current) || sprout::tuples::get<0>(current) == last1 ? current
|
||||
: sprout::detail::mismatch_impl(
|
||||
sprout::detail::mismatch_impl_1(
|
||||
current,
|
||||
last1, pred, n
|
||||
),
|
||||
last1, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
|
@ -72,15 +110,17 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::mismatch_impl(first1, last1, first2, pred);
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, bool> type;
|
||||
return sprout::detail::mismatch_impl_check(
|
||||
sprout::detail::mismatch_impl(type(first1, first2, false), last1, pred, 1)
|
||||
);
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.10 Mismatch
|
||||
//
|
||||
// recursion depth:
|
||||
// [first1, last1), first2 are RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#define SPROUT_ALGORITHM_NONE_OF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,28 +24,60 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::none_of_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
bool
|
||||
>::type
|
||||
none_of(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? true
|
||||
: sprout::detail::none_of_impl_ra(first, last, pred, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::none_of_impl_ra(first, last, pred, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
none_of_impl(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? true
|
||||
: !pred(*first) && sprout::detail::none_of_impl(sprout::next(first), last, pred)
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
none_of_impl_1(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return !current.second || current.first == last ? current
|
||||
: n == 1 ? !pred(*current.first) ? type(sprout::next(current.first), true) : type(current.first, false)
|
||||
: sprout::detail::none_of_impl_1(
|
||||
sprout::detail::none_of_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, bool>
|
||||
none_of_impl(
|
||||
sprout::pair<InputIterator, bool> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return !current.second || current.first == last ? current
|
||||
: sprout::detail::none_of_impl(
|
||||
sprout::detail::none_of_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
|
@ -53,15 +87,15 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::none_of_impl(first, last, pred);
|
||||
typedef sprout::pair<InputIterator, bool> type;
|
||||
return sprout::detail::none_of_impl(type(first, true), last, pred, 1).second;
|
||||
}
|
||||
} //namespace detail
|
||||
|
||||
// 25.2.3 None of
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template <typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,7 +21,7 @@ namespace sprout {
|
|||
)
|
||||
&& sprout::detail::none_of_equal_impl_ra(
|
||||
sprout::next(first, pivot), last, value,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -34,7 +33,7 @@ namespace sprout {
|
|||
)
|
||||
{
|
||||
return first == last ? true
|
||||
: sprout::detail::none_of_equal_impl_ra(first, last, value, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
: sprout::detail::none_of_equal_impl_ra(first, last, value, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,25 +8,122 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of_impl_ra_1(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type pivot
|
||||
)
|
||||
{
|
||||
return pivot == 0 ? !pred(*first)
|
||||
: sprout::detail::one_of_impl_ra_1(
|
||||
first, sprout::next(first, pivot), pred,
|
||||
pivot / 2
|
||||
)
|
||||
&& sprout::detail::one_of_impl_ra_1(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of_impl_ra(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type pivot
|
||||
)
|
||||
{
|
||||
return pivot == 0 ? pred(*first)
|
||||
: sprout::detail::one_of_impl_ra(
|
||||
first, sprout::next(first, pivot), pred,
|
||||
pivot / 2
|
||||
)
|
||||
? sprout::detail::one_of_impl_ra_1(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
: sprout::detail::one_of_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
bool
|
||||
>::type
|
||||
one_of(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last ? true
|
||||
: sprout::detail::one_of_impl_ra(first, last, pred, sprout::distance(first, last) / 2)
|
||||
;
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
one_of_impl_1(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.second > 1 || current.first == last ? current
|
||||
: n == 1 ? current.second == 0
|
||||
? type(sprout::next(current.first), pred(*current.first) ? 1 : 0)
|
||||
: !pred(*current.first) ? type(sprout::next(current.first), 1) : type(current.first, 2)
|
||||
: sprout::detail::one_of_impl_1(
|
||||
sprout::detail::one_of_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
one_of_impl(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return current.second > 1 || current.first == last ? current
|
||||
: sprout::detail::one_of_impl(
|
||||
sprout::detail::one_of_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of_impl(InputIterator found, InputIterator last, Predicate pred) {
|
||||
return found != last
|
||||
&& sprout::none_of(sprout::next(found), last, pred)
|
||||
;
|
||||
one_of(
|
||||
InputIterator first, InputIterator last, Predicate pred,
|
||||
void*
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return sprout::detail::one_of_impl(type(first, 0), last, pred, 1).second == 1;
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// one_of
|
||||
//
|
||||
// recursion depth:
|
||||
// [first, last) is RandomAccessIterator -> O(log N)
|
||||
// otherwise -> O(N)
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR bool
|
||||
one_of(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return sprout::detail::one_of_impl(sprout::find_if(first, last, pred), last, pred);
|
||||
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
|
||||
return sprout::detail::one_of(first, last, pred, category());
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
@ -15,11 +14,11 @@ namespace sprout {
|
|||
return mid == last ? mid
|
||||
: pred(*mid) ? sprout::detail::partition_point_impl(
|
||||
sprout::next(mid), last, pred,
|
||||
sprout::next(mid, 1 + NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::next(mid), last) / 2)
|
||||
sprout::next(mid, 1 + sprout::distance(sprout::next(mid), last) / 2)
|
||||
)
|
||||
: sprout::detail::partition_point_impl(
|
||||
first, mid, pred,
|
||||
sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, mid) / 2)
|
||||
sprout::next(first, sprout::distance(first, mid) / 2)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -36,7 +35,7 @@ namespace sprout {
|
|||
partition_point(ForwardIterator first, ForwardIterator last, Predicate pred) {
|
||||
return sprout::detail::partition_point_impl(
|
||||
first, last, pred,
|
||||
sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2)
|
||||
sprout::next(first, sprout::distance(first, last) / 2)
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include <sprout/detail/algorithm/search_one.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -22,7 +21,7 @@ namespace sprout {
|
|||
: pivot == 0 ? sprout::detail::search_one(first1, last1_, first2, last2, pred)
|
||||
: sprout::detail::search_impl_ra(
|
||||
sprout::next(first1, pivot), last1, first2, last2, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2, last1_,
|
||||
(sprout::distance(first1, last1) - pivot) / 2, last1_,
|
||||
sprout::detail::search_impl_ra(
|
||||
first1, sprout::next(first1, pivot), first2, last2, pred,
|
||||
pivot / 2, last1_,
|
||||
|
@ -43,7 +42,7 @@ namespace sprout {
|
|||
return first1 == last1 ? last1
|
||||
: sprout::detail::search_impl_ra(
|
||||
first1, last1, first2, last2, pred,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2, last1, first1
|
||||
sprout::distance(first1, last1) / 2, last1, first1
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/algorithm/min.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -37,7 +36,7 @@ namespace sprout {
|
|||
: pivot == 0 ? (comp(*first1, *first2) || comp(*first2, *first1) ? found_type(first1, first2) : found_type(last1, last2))
|
||||
: sprout::detail::tristate_lexicographical_compare_impl_ra_1(
|
||||
sprout::next(first1, pivot), last1, sprout::next(first2, pivot), last2, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2,
|
||||
(sprout::distance(first1, last1) - pivot) / 2,
|
||||
sprout::detail::tristate_lexicographical_compare_impl_ra_1(
|
||||
first1, sprout::next(first1, pivot), first2, sprout::next(first2, pivot), comp,
|
||||
pivot / 2,
|
||||
|
@ -73,7 +72,7 @@ namespace sprout {
|
|||
: first1 == last1 ? -1
|
||||
: sprout::detail::tristate_lexicographical_compare_impl_ra(
|
||||
first1, last1, first2, last2, comp,
|
||||
sprout::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2))
|
||||
sprout::min(sprout::distance(first1, last1), sprout::distance(first2, last2))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
@ -164,7 +163,7 @@ namespace sprout {
|
|||
)
|
||||
: sprout::detail::tristate_lexicographical_compare_2_impl_ra_1(
|
||||
sprout::next(first1, pivot), last1, delim1, sprout::next(first2, pivot), last2, delim2, comp,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) - pivot) / 2,
|
||||
(sprout::distance(first1, last1) - pivot) / 2,
|
||||
sprout::detail::tristate_lexicographical_compare_2_impl_ra_1(
|
||||
first1, sprout::next(first1, pivot), delim1, first2, sprout::next(first2, pivot), delim2, comp,
|
||||
pivot / 2,
|
||||
|
@ -204,7 +203,7 @@ namespace sprout {
|
|||
: first1 == last1 || (!comp(*first1, delim1) && !comp(delim1, *first1)) ? -1
|
||||
: sprout::detail::tristate_lexicographical_compare_2_impl_ra(
|
||||
first1, last1, delim1, first2, last2, delim2, comp,
|
||||
sprout::min(NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1), NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2))
|
||||
sprout::min(sprout::distance(first1, last1), sprout::distance(first2, last2))
|
||||
)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -21,9 +20,9 @@ namespace sprout {
|
|||
upper_bound(ForwardIterator first, ForwardIterator last, T const& value, Compare comp) {
|
||||
return first == last ? last
|
||||
: sprout::next(first) == last ? !comp(value, *first) ? last : first
|
||||
: !comp(value, *sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2))
|
||||
? sprout::upper_bound(sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), last, value, comp)
|
||||
: sprout::upper_bound(first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) / 2), value, comp)
|
||||
: !comp(value, *sprout::next(first, sprout::distance(first, last) / 2))
|
||||
? sprout::upper_bound(sprout::next(first, sprout::distance(first, last) / 2), last, value, comp)
|
||||
: sprout::upper_bound(first, sprout::next(first, sprout::distance(first, last) / 2), value, comp)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/begin.hpp>
|
||||
#include <sprout/container/internal_begin.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||
internal_begin_offset(Container const& cont) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::internal_begin(cont), sprout::begin(cont));
|
||||
return sprout::distance(sprout::internal_begin(cont), sprout::begin(cont));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/begin.hpp>
|
||||
#include <sprout/container/internal_end.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||
internal_begin_offset_backward(Container const& cont) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), sprout::internal_end(cont));
|
||||
return sprout::distance(sprout::begin(cont), sprout::internal_end(cont));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/end.hpp>
|
||||
#include <sprout/container/internal_begin.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||
internal_end_offset(Container const& cont) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::internal_begin(cont), sprout::end(cont));
|
||||
return sprout::distance(sprout::internal_begin(cont), sprout::end(cont));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/end.hpp>
|
||||
#include <sprout/container/internal_end.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||
internal_end_offset_backward(Container const& cont) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::end(cont), sprout::internal_end(cont));
|
||||
return sprout::distance(sprout::end(cont), sprout::internal_end(cont));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/begin.hpp>
|
||||
#include <sprout/container/end.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type
|
||||
size(Container const& cont) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(sprout::begin(cont), sprout::end(cont));
|
||||
return sprout::distance(sprout::begin(cont), sprout::end(cont));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/ptr_index_iterator.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
// 7.21.6.3 strlen ŠÖ<C5A0>”
|
||||
|
@ -18,7 +18,7 @@ namespace sprout {
|
|||
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
strlen(char const* s, std::size_t n) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(
|
||||
return sprout::distance(
|
||||
sprout::as_iterator(s),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::find(sprout::as_iterator(s), sprout::as_iterator(s, n), '\0')
|
||||
);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/ptr_index_iterator.hpp>
|
||||
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -20,7 +20,7 @@ namespace sprout {
|
|||
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
wcslen(wchar_t const* s, std::size_t n) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(
|
||||
return sprout::distance(
|
||||
sprout::as_iterator(s),
|
||||
NS_SSCRISK_CEL_OR_SPROUT::find(sprout::as_iterator(s), sprout::as_iterator(s, n), L'\0')
|
||||
);
|
||||
|
|
|
@ -2,45 +2,68 @@
|
|||
#define SPROUT_DETAIL_ALGORITHM_COUNT_N_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/algorithm/count.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Size, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
template<typename RandomAccessIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
>::type
|
||||
count_n(
|
||||
InputIterator first, Size n, T const& value,
|
||||
RandomAccessIterator first, typename std::iterator_traits<RandomAccessIterator>::difference_type n, T const& value,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return sprout::count(first, sprout::next(first, n), value);
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename Size, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n_impl(InputIterator first, Size n, T const& value) {
|
||||
return n == 0 ? 0
|
||||
: (*first == value ? 1 : 0) + sprout::detail::count_n_impl(sprout::next(first), n - 1, value)
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_n_impl(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
T const& value, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return n == 1 ? type(sprout::next(current.first), current.second + (*current.first == value ? 1 : 0))
|
||||
: sprout::detail::count_n_impl(
|
||||
sprout::detail::count_n_impl(
|
||||
current,
|
||||
value, n / 2
|
||||
),
|
||||
value, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Size, typename T>
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n(
|
||||
InputIterator first, Size n, T const& value,
|
||||
InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, T const& value,
|
||||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::count_n_impl(first, n, value);
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return n == 0 ? 0
|
||||
: sprout::detail::count_n_impl(type(first, 0), value, n).second
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// count_n
|
||||
//
|
||||
template<typename InputIterator, typename Size, typename T>
|
||||
// recursion depth:
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n(InputIterator first, Size n, T const& value) {
|
||||
count_n(InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, T const& value) {
|
||||
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
|
||||
return sprout::detail::count_n(first, n, value, category());
|
||||
}
|
||||
|
|
|
@ -2,45 +2,68 @@
|
|||
#define SPROUT_DETAIL_ALGORITHM_COUNT_N_IF_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/utility/pair.hpp>
|
||||
#include <sprout/algorithm/count_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Size, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
template<typename RandomAccessIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::pred,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
>::type
|
||||
count_n_if(
|
||||
InputIterator first, Size n, Predicate pred,
|
||||
RandomAccessIterator first, typename std::iterator_traits<RandomAccessIterator>::difference_type n, Predicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return sprout::count_if(first, sprout::next(first, n), pred);
|
||||
return sprout::count(first, sprout::next(first, n), pred);
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename Size, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n_if_impl(InputIterator first, Size n, Predicate pred) {
|
||||
return n == 0 ? 0
|
||||
: (pred(*first) ? 1 : 0) + sprout::detail::count_n_if(sprout::next(first), n - 1, pred)
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
count_n_if_impl(
|
||||
sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
Predicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return n == 1 ? type(sprout::next(current.first), current.second + (pred(*current.first) ? 1 : 0))
|
||||
: sprout::detail::count_n_if_impl(
|
||||
sprout::detail::count_n_if_impl(
|
||||
current,
|
||||
pred, n / 2
|
||||
),
|
||||
pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Size, typename Predicate>
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n_if(
|
||||
InputIterator first, Size n, Predicate pred,
|
||||
InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, Predicate pred,
|
||||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::count_n_if_impl(first, n, pred);
|
||||
typedef sprout::pair<InputIterator, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return n == 0 ? 0
|
||||
: sprout::detail::count_n_if_impl(type(first, 0), pred, n).second
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// count_n_if
|
||||
//
|
||||
template<typename InputIterator, typename Size, typename Predicate>
|
||||
// recursion depth:
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_n_if(InputIterator first, Size n, Predicate pred) {
|
||||
count_n_if(InputIterator first, typename std::iterator_traits<InputIterator>::difference_type n, Predicate pred) {
|
||||
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
|
||||
return sprout::detail::count_n_if(first, n, pred, category());
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
|
@ -23,52 +24,89 @@ namespace sprout {
|
|||
)
|
||||
+ sprout::detail::overlap_count_impl_ra(
|
||||
sprout::next(first, pivot), last, pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - pivot) / 2
|
||||
(sprout::distance(first, last) - pivot) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename RandomAccessIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::is_constant_distance_iterator<RandomAccessIterator>::value,
|
||||
typename std::iterator_traits<RandomAccessIterator>::difference_type
|
||||
>::type
|
||||
overlap_count(
|
||||
RandomAccessIterator first, RandomAccessIterator last, BinaryPredicate pred,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return first == last || NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) == 1 ? 0
|
||||
return first == last || sprout::distance(first, last) == 1 ? 0
|
||||
: sprout::detail::overlap_count_impl_ra(
|
||||
first, sprout::next(first, NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1), pred,
|
||||
(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) - 1) / 2
|
||||
first, sprout::next(first, sprout::distance(first, last) - 1), pred,
|
||||
(sprout::distance(first, last) - 1) / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
overlap_count_impl(
|
||||
InputIterator first, InputIterator last, BinaryPredicate pred,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& value
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
overlap_count_impl_1(
|
||||
sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, BinaryPredicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
return first == last ? 0
|
||||
: pred(*first, value) ? 1 + sprout::detail::overlap_count_impl(sprout::next(first), last, pred, value)
|
||||
: sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first)
|
||||
typedef sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return sprout::tuples::get<0>(current) == last ? current
|
||||
: n == 1 ? type(
|
||||
sprout::next(sprout::tuples::get<0>(current)), *sprout::tuples::get<0>(current),
|
||||
sprout::tuples::get<2>(current) + (pred(*sprout::tuples::get<0>(current), sprout::tuples::get<1>(current)) ? 1 : 0)
|
||||
)
|
||||
: sprout::detail::overlap_count_impl_1(
|
||||
sprout::detail::overlap_count_impl_1(
|
||||
current,
|
||||
last, pred, n / 2
|
||||
),
|
||||
last, pred, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type>
|
||||
overlap_count_impl(
|
||||
sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> const& current,
|
||||
InputIterator last, BinaryPredicate pred, typename std::iterator_traits<InputIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return sprout::tuples::get<0>(current) == last ? current
|
||||
: sprout::detail::overlap_count_impl(
|
||||
sprout::detail::overlap_count_impl_1(
|
||||
current,
|
||||
last, pred, n
|
||||
),
|
||||
last, pred, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
overlap_count_impl(
|
||||
overlap_count(
|
||||
InputIterator first, InputIterator last, BinaryPredicate pred,
|
||||
void*
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator, typename std::iterator_traits<InputIterator>::value_type, typename std::iterator_traits<InputIterator>::difference_type> type;
|
||||
return first == last ? 0
|
||||
: sprout::detail::overlap_count_impl(sprout::next(first), last, pred, *first)
|
||||
: sprout::tuples::get<2>(
|
||||
sprout::detail::overlap_count_impl(type(sprout::next(first), *first, 0), last, pred, 1)
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// overlap_count
|
||||
//
|
||||
// recursion depth:
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
overlap_count(InputIterator first, InputIterator last, BinaryPredicate pred) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/functional/equal_to.hpp>
|
||||
#include <sprout/algorithm/mismatch.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -17,12 +17,7 @@ namespace sprout {
|
|||
RandomAccessIterator1 first1, RandomAccessIterator1 last1, RandomAccessIterator2 first2, RandomAccessIterator2 last2, BinaryPredicate pred
|
||||
)
|
||||
{
|
||||
return sprout::detail::mismatch_impl_ra(
|
||||
first1, last1, first2, pred,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) / 2, first1
|
||||
)
|
||||
== last1
|
||||
? first1
|
||||
return sprout::mismatch(first1, last1, first2, pred).first == last1 ? first1
|
||||
: last1
|
||||
;
|
||||
}
|
||||
|
@ -33,25 +28,57 @@ namespace sprout {
|
|||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(first1, last1) < NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2) ? last1
|
||||
return sprout::distance(first1, last1) < sprout::distance(first2, last2) ? last1
|
||||
: first1 == last1 ? first1
|
||||
: sprout::detail::search_one_impl_ra(
|
||||
first1, sprout::next(first1, NS_SSCRISK_CEL_OR_SPROUT::distance(first2, last2)), first2, last2, pred
|
||||
first1, sprout::next(first1, sprout::distance(first2, last2)), first2, last2, pred
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
search_one_impl(
|
||||
ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
ForwardIterator1 first1_
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool>
|
||||
search_one_impl_1(
|
||||
sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
ForwardIterator1 first1_, typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
return first2 == last2 ? first1_
|
||||
: first1 == last1 ? last1
|
||||
: !pred(*first1, *first2) ? first1
|
||||
: sprout::detail::search_one_impl(sprout::next(first1), last1, sprout::next(first2), last2, pred, first1_)
|
||||
typedef sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> type;
|
||||
return sprout::tuples::get<2>(current) ? current
|
||||
: sprout::tuples::get<1>(current) == last2 ? type(first1_, last2, true)
|
||||
: sprout::tuples::get<0>(current) == last1 ? type(last1, last2, true)
|
||||
: n == 1 ? !pred(*sprout::tuples::get<0>(current), *sprout::tuples::get<1>(current))
|
||||
? type(sprout::next(sprout::tuples::get<0>(current)), last2, true)
|
||||
: type(sprout::next(sprout::tuples::get<0>(current)), sprout::next(sprout::tuples::get<1>(current)), false)
|
||||
: sprout::detail::search_one_impl_1(
|
||||
sprout::detail::search_one_impl_1(
|
||||
current,
|
||||
last1, last2, pred, first1_, n / 2
|
||||
),
|
||||
last1, last2, pred, first1_, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool>
|
||||
search_one_impl(
|
||||
sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> const& current,
|
||||
ForwardIterator1 last1, ForwardIterator2 last2, BinaryPredicate pred,
|
||||
ForwardIterator1 first1_, typename std::iterator_traits<ForwardIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> type;
|
||||
return sprout::tuples::get<2>(current) ? current
|
||||
: sprout::tuples::get<1>(current) == last2 ? type(first1_, last2, true)
|
||||
: sprout::tuples::get<0>(current) == last1 ? type(last1, last2, true)
|
||||
: sprout::detail::search_one_impl(
|
||||
sprout::detail::search_one_impl_1(
|
||||
current,
|
||||
last1, last2, pred, first1_, n
|
||||
),
|
||||
last1, last2, pred, first1_, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
|
@ -61,12 +88,18 @@ namespace sprout {
|
|||
void*
|
||||
)
|
||||
{
|
||||
return sprout::detail::search_one_impl(first1, last1, first2, last2, pred, first1);
|
||||
typedef sprout::tuples::tuple<ForwardIterator1, ForwardIterator2, bool> type;
|
||||
return sprout::tuples::get<0>(
|
||||
sprout::detail::search_one_impl(type(first1, first2, false), last1, last2, pred, first1, 1)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// search_one
|
||||
//
|
||||
// recursion depth:
|
||||
// O(log (N1+N2))
|
||||
//
|
||||
template<typename ForwardIterator1, typename ForwardIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator1
|
||||
search_one(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred) {
|
||||
|
|
|
@ -4,13 +4,68 @@
|
|||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/type_traits/is_iterator.hpp>
|
||||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/functional/less.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIterator1, typename InputIterator2, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type>
|
||||
set_overlap_count_impl_1(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type> const& current,
|
||||
InputIterator1 last1, InputIterator2 last2, Compare comp, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type> type;
|
||||
return sprout::tuples::get<0>(current) == last1 || sprout::tuples::get<1>(current) == last2 ? current
|
||||
: n == 1 ? comp(*sprout::tuples::get<0>(current), *sprout::tuples::get<1>(current)) ? type(
|
||||
sprout::next(sprout::tuples::get<0>(current)), sprout::tuples::get<1>(current),
|
||||
sprout::tuples::get<2>(current)
|
||||
)
|
||||
: comp(*sprout::tuples::get<1>(current), *sprout::tuples::get<0>(current)) ? type(
|
||||
sprout::tuples::get<0>(current), sprout::next(sprout::tuples::get<1>(current)),
|
||||
sprout::tuples::get<2>(current)
|
||||
)
|
||||
: type(
|
||||
sprout::next(sprout::tuples::get<0>(current)), sprout::next(sprout::tuples::get<1>(current)),
|
||||
sprout::tuples::get<2>(current) + 1
|
||||
)
|
||||
: sprout::detail::set_overlap_count_impl_1(
|
||||
sprout::detail::set_overlap_count_impl_1(
|
||||
current,
|
||||
last1, last2, comp, n / 2
|
||||
),
|
||||
last1, last2, comp, n - n / 2
|
||||
)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator1, typename InputIterator2, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type>
|
||||
set_overlap_count_impl(
|
||||
sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type> const& current,
|
||||
InputIterator1 last1, InputIterator2 last2, Compare comp, typename std::iterator_traits<InputIterator1>::difference_type n
|
||||
)
|
||||
{
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type> type;
|
||||
return sprout::tuples::get<0>(current) == last1 || sprout::tuples::get<1>(current) == last2 ? current
|
||||
: sprout::detail::set_overlap_count_impl(
|
||||
sprout::detail::set_overlap_count_impl_1(
|
||||
current,
|
||||
last1, last2, comp, n
|
||||
),
|
||||
last1, last2, comp, n * 2
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
//
|
||||
// set_overlap_count
|
||||
//
|
||||
// recursion depth:
|
||||
// O(log N)
|
||||
//
|
||||
template<typename InputIterator1, typename InputIterator2, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator1>::difference_type
|
||||
set_overlap_count(
|
||||
|
@ -19,14 +74,10 @@ namespace sprout {
|
|||
Compare comp
|
||||
)
|
||||
{
|
||||
return first1 != last1 && first2 != last2
|
||||
? comp(*first1, *first2)
|
||||
? sprout::detail::set_overlap_count(sprout::next(first1), last1, first2, last2, comp)
|
||||
: comp(*first2, *first1)
|
||||
? sprout::detail::set_overlap_count(first1, last1, sprout::next(first2), last2, comp)
|
||||
: 1 + sprout::detail::set_overlap_count(sprout::next(first1), last1, sprout::next(first2), last2, comp)
|
||||
: 0
|
||||
;
|
||||
typedef sprout::tuples::tuple<InputIterator1, InputIterator2, typename std::iterator_traits<InputIterator1>::difference_type> type;
|
||||
return sprout::tuples::get<2>(
|
||||
sprout::detail::set_overlap_count_impl(type(first1, first2, 0), last1, last2, comp, 1)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename InputIterator1, typename InputIterator2>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <sprout/iterator/type_traits/common.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/utility/limited.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -279,19 +279,6 @@ namespace sprout {
|
|||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_distance
|
||||
//
|
||||
template<typename LIterator, typename RIterator>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::alternate_iterator<LIterator, RIterator> >::difference_type
|
||||
iterator_distance(
|
||||
sprout::alternate_iterator<LIterator, RIterator> first,
|
||||
sprout::alternate_iterator<LIterator, RIterator> last
|
||||
)
|
||||
{
|
||||
return last - first;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_next
|
||||
//
|
||||
|
@ -300,15 +287,6 @@ namespace sprout {
|
|||
iterator_next(sprout::alternate_iterator<LIterator, RIterator> const& it) {
|
||||
return it.next();
|
||||
}
|
||||
template<typename LIterator, typename RIterator>
|
||||
inline SPROUT_CONSTEXPR sprout::alternate_iterator<LIterator, RIterator>
|
||||
iterator_next(
|
||||
sprout::alternate_iterator<LIterator, RIterator> const& it,
|
||||
typename sprout::alternate_iterator<LIterator, RIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_prev
|
||||
|
@ -318,15 +296,6 @@ namespace sprout {
|
|||
iterator_prev(sprout::alternate_iterator<LIterator, RIterator> const& it) {
|
||||
return it.prev();
|
||||
}
|
||||
template<typename LIterator, typename RIterator>
|
||||
inline SPROUT_CONSTEXPR sprout::alternate_iterator<LIterator, RIterator>
|
||||
iterator_prev(
|
||||
sprout::alternate_iterator<LIterator, RIterator> const& it,
|
||||
typename sprout::alternate_iterator<LIterator, RIterator>::difference_type n
|
||||
)
|
||||
{
|
||||
return it - n;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ITERATOR_ALTERNATE_ITERATOR_HPP
|
||||
|
|
|
@ -189,15 +189,6 @@ namespace sprout {
|
|||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_distance
|
||||
//
|
||||
template<typename Iterator, typename Traits>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::bytes_iterator<Iterator, Traits> >::difference_type
|
||||
iterator_distance(sprout::bytes_iterator<Iterator, Traits> first, sprout::bytes_iterator<Iterator, Traits> last) {
|
||||
return last - first;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_next
|
||||
//
|
||||
|
@ -206,15 +197,6 @@ namespace sprout {
|
|||
iterator_next(sprout::bytes_iterator<Iterator, Traits> const& it) {
|
||||
return it.next();
|
||||
}
|
||||
template<typename Iterator, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits>
|
||||
iterator_next(
|
||||
sprout::bytes_iterator<Iterator, Traits> const& it,
|
||||
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
|
||||
)
|
||||
{
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_prev
|
||||
|
@ -224,15 +206,6 @@ namespace sprout {
|
|||
iterator_prev(sprout::bytes_iterator<Iterator, Traits> const& it) {
|
||||
return it.prev();
|
||||
}
|
||||
template<typename Iterator, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::bytes_iterator<Iterator, Traits>
|
||||
iterator_prev(
|
||||
sprout::bytes_iterator<Iterator, Traits> const& it,
|
||||
typename sprout::bytes_iterator<Iterator, Traits>::difference_type n
|
||||
)
|
||||
{
|
||||
return it - n;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ITERATOR_BYTES_ITERATOR_HPP
|
||||
|
|
|
@ -215,15 +215,6 @@ namespace sprout {
|
|||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_distance
|
||||
//
|
||||
template<typename Iterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::clamp_iterator<Iterator, Compare> >::difference_type
|
||||
iterator_distance(sprout::clamp_iterator<Iterator, Compare> first, sprout::clamp_iterator<Iterator, Compare> last) {
|
||||
return last - first;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_next
|
||||
//
|
||||
|
@ -232,15 +223,6 @@ namespace sprout {
|
|||
iterator_next(sprout::clamp_iterator<Iterator, Compare> const& it) {
|
||||
return it.next();
|
||||
}
|
||||
template<typename Iterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::clamp_iterator<Iterator, Compare>
|
||||
iterator_next(
|
||||
sprout::clamp_iterator<Iterator, Compare> const& it,
|
||||
typename sprout::clamp_iterator<Iterator, Compare>::difference_type n
|
||||
)
|
||||
{
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_prev
|
||||
|
@ -250,15 +232,6 @@ namespace sprout {
|
|||
iterator_prev(sprout::clamp_iterator<Iterator, Compare> const& it) {
|
||||
return it.prev();
|
||||
}
|
||||
template<typename Iterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR sprout::clamp_iterator<Iterator, Compare>
|
||||
iterator_prev(
|
||||
sprout::clamp_iterator<Iterator, Compare> const& it,
|
||||
typename sprout::clamp_iterator<Iterator, Compare>::difference_type n
|
||||
)
|
||||
{
|
||||
return it - n;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // SPROUT_ITERATOR_CLAMP_ITERATOR_HPP
|
||||
|
|
|
@ -184,15 +184,6 @@ namespace sprout {
|
|||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_distance
|
||||
//
|
||||
template<typename Incrementable>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::counting_iterator<Incrementable> >::difference_type
|
||||
iterator_distance(sprout::counting_iterator<Incrementable> first, sprout::counting_iterator<Incrementable> last) {
|
||||
return last - first;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_next
|
||||
//
|
||||
|
@ -201,15 +192,6 @@ namespace sprout {
|
|||
iterator_next(sprout::counting_iterator<Incrementable> const& it) {
|
||||
return it.next();
|
||||
}
|
||||
template<typename Incrementable>
|
||||
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable>
|
||||
iterator_next(
|
||||
sprout::counting_iterator<Incrementable> const& it,
|
||||
typename sprout::counting_iterator<Incrementable>::difference_type n
|
||||
)
|
||||
{
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_prev
|
||||
|
@ -219,15 +201,6 @@ namespace sprout {
|
|||
iterator_prev(sprout::counting_iterator<Incrementable> const& it) {
|
||||
return it.prev();
|
||||
}
|
||||
template<typename Incrementable>
|
||||
inline SPROUT_CONSTEXPR sprout::counting_iterator<Incrementable>
|
||||
iterator_prev(
|
||||
sprout::counting_iterator<Incrementable> const& it,
|
||||
typename sprout::counting_iterator<Incrementable>::difference_type n
|
||||
)
|
||||
{
|
||||
return it - n;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/utility/swap.hpp>
|
||||
#include <sprout/numeric/dft/dft_element.hpp>
|
||||
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -60,7 +60,7 @@ namespace sprout {
|
|||
dft_iterator(dft_iterator const&) = default;
|
||||
SPROUT_CONSTEXPR dft_iterator(iterator_type first, iterator_type last, difference_type index = 0)
|
||||
: first_(first), last_(last), index_(index)
|
||||
, size_(NS_SSCRISK_CEL_OR_SPROUT::distance(first, last))
|
||||
, size_(sprout::distance(first, last))
|
||||
{}
|
||||
SPROUT_CONSTEXPR dft_iterator next() const {
|
||||
return dft_iterator(first_, last_, index_, index_ + 1, size_);
|
||||
|
@ -164,15 +164,6 @@ namespace sprout {
|
|||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_distance
|
||||
//
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR typename std::iterator_traits<sprout::dft_iterator<Iterator> >::difference_type
|
||||
iterator_distance(sprout::dft_iterator<Iterator> first, sprout::dft_iterator<Iterator> last) {
|
||||
return last - first;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_next
|
||||
//
|
||||
|
@ -181,15 +172,6 @@ namespace sprout {
|
|||
iterator_next(sprout::dft_iterator<Iterator> const& it) {
|
||||
return it.next();
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR sprout::dft_iterator<Iterator>
|
||||
iterator_next(
|
||||
sprout::dft_iterator<Iterator> const& it,
|
||||
typename sprout::dft_iterator<Iterator>::difference_type n
|
||||
)
|
||||
{
|
||||
return it + n;
|
||||
}
|
||||
|
||||
//
|
||||
// iterator_prev
|
||||
|
@ -199,15 +181,6 @@ namespace sprout {
|
|||
iterator_prev(sprout::dft_iterator<Iterator> const& it) {
|
||||
return it.prev();
|
||||
}
|
||||
template<typename Iterator>
|
||||
inline SPROUT_CONSTEXPR sprout::dft_iterator<Iterator>
|
||||
iterator_prev(
|
||||
sprout::dft_iterator<Iterator> const& it,
|
||||
typename sprout::dft_iterator<Iterator>::difference_type n
|
||||
)
|
||||
{
|
||||
return it - n;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ITERATOR_DFT_ITERATOR_HPP
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue