File indexing completed on 2026-05-03 08:13:08
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
0010 #define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H
0011
0012 #include <__algorithm/comp.h>
0013 #include <__algorithm/comp_ref_type.h>
0014 #include <__config>
0015 #include <__iterator/iterator_traits.h>
0016
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 # pragma GCC system_header
0019 #endif
0020
0021 _LIBCPP_BEGIN_NAMESPACE_STD
0022
0023 template <class _Compare, class _RandomAccessIterator>
0024 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
0025 __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
0026 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
0027 difference_type __len = __last - __first;
0028 difference_type __p = 0;
0029 difference_type __c = 1;
0030 _RandomAccessIterator __pp = __first;
0031 while (__c < __len) {
0032 _RandomAccessIterator __cp = __first + __c;
0033 if (__comp(*__pp, *__cp))
0034 return __cp;
0035 ++__c;
0036 ++__cp;
0037 if (__c == __len)
0038 return __last;
0039 if (__comp(*__pp, *__cp))
0040 return __cp;
0041 ++__p;
0042 ++__pp;
0043 __c = 2 * __p + 1;
0044 }
0045 return __last;
0046 }
0047
0048 template <class _RandomAccessIterator, class _Compare>
0049 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
0050 is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
0051 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
0052 }
0053
0054 template <class _RandomAccessIterator>
0055 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
0056 is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) {
0057 return std::__is_heap_until(__first, __last, __less<>());
0058 }
0059
0060 _LIBCPP_END_NAMESPACE_STD
0061
0062 #endif