mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-02 14:04:20 +00:00
add algorithm clamp, clamp_range_copy, clamp_range
This commit is contained in:
parent
de41f5c880
commit
79ea4f0885
29 changed files with 870 additions and 11 deletions
|
@ -14,7 +14,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred) {
|
||||
return first == last || sprout::next(first) == last ? last
|
||||
: pred(*first, *(sprout::next(first))) != false ? first
|
||||
: pred(*first, *(sprout::next(first))) ? first
|
||||
: sprout::adjacent_find(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR bool
|
||||
all_of(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? true
|
||||
: pred(*first) == true && sprout::all_of(sprout::next(first), last, pred)
|
||||
: pred(*first) && sprout::all_of(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR bool
|
||||
any_of(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? false
|
||||
: pred(*first) == true || sprout::any_of(sprout::next(first), last, pred)
|
||||
: pred(*first) || sprout::any_of(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
30
sprout/algorithm/clamp.hpp
Normal file
30
sprout/algorithm/clamp.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef SPROUT_ALGORITHM_CLAMP_HPP
|
||||
#define SPROUT_ALGORITHM_CLAMP_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// clamp
|
||||
//
|
||||
template<typename T, typename Compare>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
clamp(T const& value, typename std::common_type<T>::type const& low, typename std::common_type<T>::type const& high, Compare comp) {
|
||||
return comp(value, low) ? low
|
||||
: comp(high, value) ? high
|
||||
: value
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
clamp(T const& value, typename std::common_type<T>::type const& low, typename std::common_type<T>::type const& high) {
|
||||
return sprout::clamp(
|
||||
value, low, high,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::less<T>()
|
||||
);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_CLAMP_HPP
|
8
sprout/algorithm/clamp_range.hpp
Normal file
8
sprout/algorithm/clamp_range.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_ALGORITHM_CLAMP_RANGE_HPP
|
||||
#define SPROUT_ALGORITHM_CLAMP_RANGE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range.hpp>
|
||||
#include <sprout/algorithm/fit/clamp_range.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_CLAMP_RANGE_HPP
|
8
sprout/algorithm/clamp_range_copy.hpp
Normal file
8
sprout/algorithm/clamp_range_copy.hpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef SPROUT_ALGORITHM_CLAMP_RANGE_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_CLAMP_RANGE_COPY_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range_copy.hpp>
|
||||
#include <sprout/algorithm/fit/clamp_range_copy.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_CLAMP_RANGE_COPY_HPP
|
|
@ -13,7 +13,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR typename std::iterator_traits<InputIterator>::difference_type
|
||||
count_if(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? 0
|
||||
: (pred(*first) != false ? 1 : 0) + sprout::count_if(sprout::next(first), last, pred)
|
||||
: (pred(*first) ? 1 : 0) + sprout::count_if(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR bool
|
||||
equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred) {
|
||||
return first1 == last1 ? true
|
||||
: pred(*first1, *first2) != false && sprout::equal(sprout::next(first1), last1, sprout::next(first2), pred)
|
||||
: pred(*first1, *first2) && sprout::equal(sprout::next(first1), last1, sprout::next(first2), pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace sprout {
|
|||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
find_if(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last || pred(*first) != false ? first
|
||||
return first == last || pred(*first) ? first
|
||||
: sprout::find_if(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace sprout {
|
|||
template<typename InputIterator, typename Predicate>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
find_if_not(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last || pred(*first) == false ? first
|
||||
return first == last || !pred(*first) ? first
|
||||
: sprout::find_if_not(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include <sprout/algorithm/fit/sort_heap.hpp>
|
||||
#include <sprout/algorithm/fit/next_permutation.hpp>
|
||||
#include <sprout/algorithm/fit/prev_permutation.hpp>
|
||||
#include <sprout/algorithm/fit/clamp_range_copy.hpp>
|
||||
#include <sprout/algorithm/fit/clamp_range.hpp>
|
||||
#include <sprout/algorithm/fit/random_swap.hpp>
|
||||
#include <sprout/algorithm/fit/random_swap_result.hpp>
|
||||
#include <sprout/algorithm/fit/bogo_sort.hpp>
|
||||
|
|
79
sprout/algorithm/fit/clamp_range.hpp
Normal file
79
sprout/algorithm/fit/clamp_range.hpp
Normal file
|
@ -0,0 +1,79 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIT_CLAMP_RANGE_HPP
|
||||
#define SPROUT_ALGORITHM_FIT_CLAMP_RANGE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range.hpp>
|
||||
#include <sprout/algorithm/fit/result_of.hpp>
|
||||
#include <sprout/sub_array.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename Container, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
||||
clamp_range_impl(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high,
|
||||
Compare comp,
|
||||
typename sprout::container_traits<Container>::difference_type offset
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::clamp_range(cont, low, high, comp)),
|
||||
offset,
|
||||
offset + sprout::size(cont)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// clamp_range
|
||||
//
|
||||
template<typename Container, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
||||
clamp_range(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::clamp_range_impl(cont, low, high, comp, sprout::internal_begin_offset(cont));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
||||
clamp_range_impl(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high,
|
||||
typename sprout::container_traits<Container>::difference_type offset
|
||||
)
|
||||
{
|
||||
return sprout::sub_copy(
|
||||
sprout::get_internal(sprout::fixed::clamp_range(cont, low, high)),
|
||||
offset,
|
||||
offset + sprout::size(cont)
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// clamp_range
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Container>::type
|
||||
clamp_range(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::clamp_range_impl(cont, low, high, sprout::internal_begin_offset(cont));
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIT_CLAMP_RANGE_HPP
|
81
sprout/algorithm/fit/clamp_range_copy.hpp
Normal file
81
sprout/algorithm/fit/clamp_range_copy.hpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIT_CLAMP_RANGE_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIT_CLAMP_RANGE_COPY_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range_copy.hpp>
|
||||
#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
|
||||
|
||||
namespace sprout {
|
||||
namespace fit {
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type
|
||||
clamp_range_copy_impl(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
typename sprout::container_traits<Result>::difference_type offset
|
||||
)
|
||||
{
|
||||
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))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// clamp_range_copy
|
||||
//
|
||||
template<typename InputIterator, typename Result, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::clamp_range_copy_impl(first, last, result, low, high, comp, sprout::internal_begin_offset(result));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type
|
||||
clamp_range_copy_impl(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
typename sprout::container_traits<Result>::difference_type offset
|
||||
)
|
||||
{
|
||||
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))
|
||||
);
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// clamp_range_copy
|
||||
//
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fit::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high
|
||||
)
|
||||
{
|
||||
return sprout::fit::detail::clamp_range_copy_impl(first, last, result, low, high, sprout::internal_begin_offset(result));
|
||||
}
|
||||
} // namespace fit
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIT_CLAMP_RANGE_COPY_HPP
|
|
@ -52,6 +52,8 @@
|
|||
#include <sprout/algorithm/fixed/sort_heap.hpp>
|
||||
#include <sprout/algorithm/fixed/next_permutation.hpp>
|
||||
#include <sprout/algorithm/fixed/prev_permutation.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range_copy.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range.hpp>
|
||||
#include <sprout/algorithm/fixed/swap_element.hpp>
|
||||
#include <sprout/algorithm/fixed/swap_element_copy.hpp>
|
||||
#include <sprout/algorithm/fixed/random_swap.hpp>
|
||||
|
|
41
sprout/algorithm/fixed/clamp_range.hpp
Normal file
41
sprout/algorithm/fixed/clamp_range.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/algorithm/fixed/clamp_range_copy.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace fixed {
|
||||
//
|
||||
// clamp_range
|
||||
//
|
||||
template<typename Container, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
clamp_range(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
return sprout::fixed::clamp_range_copy(sprout::begin(cont), sprout::end(cont), cont, low, high, comp);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Container>::type
|
||||
clamp_range(
|
||||
Container const& cont,
|
||||
typename sprout::container_traits<Container>::value_type const& low,
|
||||
typename sprout::container_traits<Container>::value_type const& high
|
||||
)
|
||||
{
|
||||
return sprout::fixed::clamp_range_copy(sprout::begin(cont), sprout::end(cont), cont, low, high);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::clamp_range;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_HPP
|
145
sprout/algorithm/fixed/clamp_range_copy.hpp
Normal file
145
sprout/algorithm/fixed/clamp_range_copy.hpp
Normal file
|
@ -0,0 +1,145 @@
|
|||
#ifndef SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_COPY_HPP
|
||||
#define SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_COPY_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
#include <sprout/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 {
|
||||
namespace fixed {
|
||||
namespace detail {
|
||||
template<typename RandomAccessIterator, typename Result, typename Compare, sprout::index_t... Indexes>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
clamp_range_copy_impl_ra(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Result const& result,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& low,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
sprout::index_tuple<Indexes...>,
|
||||
typename sprout::container_traits<Result>::difference_type offset,
|
||||
typename sprout::container_traits<Result>::size_type size,
|
||||
typename sprout::container_traits<Result>::size_type input_size
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(
|
||||
result,
|
||||
sprout::size(result),
|
||||
(Indexes >= offset && Indexes < offset + size && Indexes < offset + input_size
|
||||
? sprout::clamp(first[Indexes - offset], low, high, comp)
|
||||
: *sprout::next(sprout::internal_begin(result), Indexes)
|
||||
)...
|
||||
);
|
||||
}
|
||||
template<typename RandomAccessIterator, typename Result, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
RandomAccessIterator first, RandomAccessIterator last, Result const& result,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& low,
|
||||
typename std::iterator_traits<RandomAccessIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
std::random_access_iterator_tag*
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::clamp_range_copy_impl_ra(
|
||||
first, last, result, low, high, comp,
|
||||
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)
|
||||
);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Compare, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size == sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type
|
||||
clamp_range_copy_impl(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
typename sprout::container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake<Result>(result, sprout::size(result), args...);
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Compare, typename... Args>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::container_traits<Result>::static_size != sizeof...(Args),
|
||||
typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
>::type
|
||||
clamp_range_copy_impl(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
typename sprout::container_traits<Result>::size_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return first != last && sizeof...(Args) < size
|
||||
? clamp_range_copy_impl(
|
||||
sprout::next(first), last, result, low, high, comp,
|
||||
size,
|
||||
args..., sprout::clamp(*first, low, high, comp)
|
||||
)
|
||||
: sprout::detail::container_complate(result, args...)
|
||||
;
|
||||
}
|
||||
template<typename InputIterator, typename Result, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp,
|
||||
void*
|
||||
)
|
||||
{
|
||||
return sprout::fixed::detail::clamp_range_copy_impl(first, last, result, low, high, comp, sprout::size(result));
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// clamp_range_copy
|
||||
//
|
||||
template<typename InputIterator, typename Result, typename Compare>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high,
|
||||
Compare comp
|
||||
)
|
||||
{
|
||||
typedef typename std::iterator_traits<InputIterator>::iterator_category* category;
|
||||
return sprout::fixed::detail::clamp_range_copy(first, last, result, low, high, comp, category());
|
||||
}
|
||||
template<typename InputIterator, typename Result>
|
||||
inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm<Result>::type
|
||||
clamp_range_copy(
|
||||
InputIterator first, InputIterator last, Result const& result,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& low,
|
||||
typename std::iterator_traits<InputIterator>::value_type const& high
|
||||
)
|
||||
{
|
||||
return sprout::fixed::clamp_range_copy(
|
||||
first, last, result, low, high,
|
||||
NS_SSCRISK_CEL_OR_SPROUT::less<typename std::iterator_traits<InputIterator>::value_type>()
|
||||
);
|
||||
}
|
||||
} // namespace fixed
|
||||
|
||||
using sprout::fixed::clamp_range_copy;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_FIXED_CLAMP_RANGE_COPY_HPP
|
|
@ -21,7 +21,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp) {
|
||||
return first == last || sprout::next(first) == last ? last
|
||||
: comp(*(sprout::next(first)), *first) != false ? sprout::next(first)
|
||||
: comp(*(sprout::next(first)), *first) ? sprout::next(first)
|
||||
: sprout::is_sorted_until(sprout::next(first), last)
|
||||
;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace sprout {
|
|||
template<typename InputIterator1, typename InputIterator2, typename BinaryPredicate>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<InputIterator1, InputIterator2>
|
||||
mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate pred) {
|
||||
return first1 == last1 || pred(*first1, *first2) == false
|
||||
return first1 == last1 || !pred(*first1, *first2)
|
||||
? sprout::pair<InputIterator1, InputIterator2>{first1, first2}
|
||||
: sprout::mismatch(sprout::next(first1), last1, sprout::next(first2))
|
||||
;
|
||||
|
|
|
@ -45,5 +45,6 @@
|
|||
#include <sprout/algorithm/is_decreasing.hpp>
|
||||
#include <sprout/algorithm/is_strictly_increasing.hpp>
|
||||
#include <sprout/algorithm/is_strictly_decreasing.hpp>
|
||||
#include <sprout/algorithm/clamp.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_NON_MODIFYIING_HPP
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR bool
|
||||
none_of(InputIterator first, InputIterator last, Predicate pred) {
|
||||
return first == last ? true
|
||||
: pred(*first) == false && sprout::none_of(sprout::next(first), last, pred)
|
||||
: !pred(*first) && sprout::none_of(sprout::next(first), last, pred)
|
||||
;
|
||||
}
|
||||
} // namespace sprout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue