This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

62
cppdraft/make/heap.md Normal file
View File

@@ -0,0 +1,62 @@
[make.heap]
# 26 Algorithms library [[algorithms]](./#algorithms)
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#make.heap)
### 26.8.8 Heap operations [[alg.heap.operations]](alg.heap.operations#make.heap)
#### 26.8.8.4 make_heap [make.heap]
[🔗](#lib:make_heap)
`template<class RandomAccessIterator>
constexpr void make_heap(RandomAccessIterator first, RandomAccessIterator last);
template<class RandomAccessIterator, class Compare>
constexpr void make_heap(RandomAccessIterator first, RandomAccessIterator last,
Compare comp);
template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13Concept random_­access_­iterator[iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<I> S, class Comp = ranges::less,
class Proj = identity>
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8Concept sortable[alg.req.sortable]")<I, Comp, Proj>
constexpr I
ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {});
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6Other range refinements[range.refinements]") R, class Comp = ranges::less, class Proj = identity>
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8Concept sortable[alg.req.sortable]")<iterator_t<R>, Comp, Proj>
constexpr borrowed_iterator_t<R>
ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {});
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11035)
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11040)
*Preconditions*: For the overloads in namespace std,RandomAccessIterator meets
the [*Cpp17ValueSwappable*](swappable.requirements#:Cpp17ValueSwappable "16.4.4.3Swappable requirements[swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3Swappable requirements")) and
the type of *first meets
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) and[*Cpp17MoveAssignable*](utility.arg.requirements#:Cpp17MoveAssignable "16.4.4.2Template argument requirements[utility.arg.requirements]") (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements")) requirements[.](#2.sentence-1)
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11049)
*Effects*: Constructs a heap with respect to comp and proj out of the range [first, last)[.](#3.sentence-1)
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11054)
*Returns*: last for the overloads in namespace ranges[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11058)
*Complexity*: At most 3(last - first) comparisons and twice as many projections[.](#5.sentence-1)