mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
porting sscrisk/CEL
This commit is contained in:
parent
ad60c8c530
commit
db20f64991
181 changed files with 2531 additions and 607 deletions
40
sprout/algorithm/is_heap_until.hpp
Normal file
40
sprout/algorithm/is_heap_until.hpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SPROUT_ALGORITHM_IS_HEAP_UNTIL_HPP
|
||||
#define SPROUT_ALGORITHM_IS_HEAP_UNTIL_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#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 {
|
||||
// Copyright (C) 2011 RiSK (sscrisk)
|
||||
|
||||
namespace detail {
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
SPROUT_CONSTEXPR RandomAccessIterator is_heap_until_impl(
|
||||
RandomAccessIterator first,
|
||||
RandomAccessIterator last,
|
||||
Compare comp,
|
||||
std::size_t n
|
||||
)
|
||||
{
|
||||
return first + n == last || !comp(first[n], first[(n - 1) / 2]) ? first + n
|
||||
: sprout::detail::is_heap_until_impl(first, last, comp, n + 1)
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// 25.4.6.5 is_heap
|
||||
template<typename RandomAccessIterator>
|
||||
SPROUT_CONSTEXPR RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessIterator last) {
|
||||
return sprout::is_heap_until(first, last, NS_SSCRISK_CEL_OR_SPROUT::less<decltype(*first)>());
|
||||
}
|
||||
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
SPROUT_CONSTEXPR RandomAccessIterator is_heap_until(RandomAccessIterator first, RandomAccessIterator last, Compare comp) {
|
||||
return NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) < 2 ? last : sprout::detail::is_heap_until_impl(first, last, comp, 1);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_IS_HEAP_UNTIL_HPP
|
Loading…
Add table
Add a link
Reference in a new issue