[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __algorithm / make_heap.h
blob5239a99083f5041b5015fc091d500db9efd25622
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___ALGORITHM_MAKE_HEAP_H
10 #define _LIBCPP___ALGORITHM_MAKE_HEAP_H
12 #include <__cxx03/__algorithm/comp.h>
13 #include <__cxx03/__algorithm/comp_ref_type.h>
14 #include <__cxx03/__algorithm/iterator_operations.h>
15 #include <__cxx03/__algorithm/sift_down.h>
16 #include <__cxx03/__config>
17 #include <__cxx03/__iterator/iterator_traits.h>
18 #include <__cxx03/__utility/move.h>
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21 # pragma GCC system_header
22 #endif
24 _LIBCPP_PUSH_MACROS
25 #include <__cxx03/__undef_macros>
27 _LIBCPP_BEGIN_NAMESPACE_STD
29 template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
30 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
31 __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) {
32 __comp_ref_type<_Compare> __comp_ref = __comp;
34 using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type;
35 difference_type __n = __last - __first;
36 if (__n > 1) {
37 // start from the first parent, there is no need to consider children
38 for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) {
39 std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start);
44 template <class _RandomAccessIterator, class _Compare>
45 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
46 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
47 std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
50 template <class _RandomAccessIterator>
51 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
52 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
53 std::make_heap(std::move(__first), std::move(__last), __less<>());
56 _LIBCPP_END_NAMESPACE_STD
58 _LIBCPP_POP_MACROS
60 #endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H