418 lines
24 KiB
Markdown
418 lines
24 KiB
Markdown
[alg.heap.operations]
|
||
|
||
# 26 Algorithms library [[algorithms]](./#algorithms)
|
||
|
||
## 26.8 Sorting and related operations [[alg.sorting]](alg.sorting#alg.heap.operations)
|
||
|
||
### 26.8.8 Heap operations [alg.heap.operations]
|
||
|
||
#### [26.8.8.1](#general) General [[alg.heap.operations.general]](alg.heap.operations.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10877)
|
||
|
||
A random access range [a, b) is a[*heap with respect to comp and proj*](#def:heap_with_respect_to_comp_and_proj "26.8.8.1 General [alg.heap.operations.general]") for a comparator and projection comp and proj if its elements are organized such that:
|
||
|
||
- [(1.1)](#general-1.1)
|
||
|
||
With N = b - a, for all i, 0<i<N, bool(invoke(comp, invoke(proj, a[âiâ12â]), invoke(proj, a[i]))) is false[.](#general-1.1.sentence-1)
|
||
|
||
- [(1.2)](#general-1.2)
|
||
|
||
*a may be removed by pop_heap, or
|
||
a new element added by push_heap,
|
||
in O(logN) time[.](#general-1.2.sentence-1)
|
||
|
||
[2](#general-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10894)
|
||
|
||
These properties make heaps useful as priority queues[.](#general-2.sentence-1)
|
||
|
||
[3](#general-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10897)
|
||
|
||
make_heap converts a range into a heap andsort_heap turns a heap into a sorted sequence[.](#general-3.sentence-1)
|
||
|
||
#### [26.8.8.2](#push.heap) push_heap [[push.heap]](push.heap)
|
||
|
||
[ð](#lib:push_heap)
|
||
|
||
`template<class RandomAccessIterator>
|
||
constexpr void push_heap(RandomAccessIterator first, RandomAccessIterator last);
|
||
|
||
template<class RandomAccessIterator, class Compare>
|
||
constexpr void push_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
|
||
template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Comp = ranges::less,
|
||
class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<I, Comp, Proj>
|
||
constexpr I
|
||
ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") R, class Comp = ranges::less, class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<iterator_t<R>, Comp, Proj>
|
||
constexpr borrowed_iterator_t<R>
|
||
ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[1](#push.heap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10924)
|
||
|
||
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names[.](#push.heap-1.sentence-1)
|
||
|
||
[2](#push.heap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10929)
|
||
|
||
*Preconditions*: The range [first, last - 1)
|
||
is a valid heap with respect to comp and proj[.](#push.heap-2.sentence-1)
|
||
|
||
For the overloads in namespace std,RandomAccessIterator meets
|
||
the [*Cpp17ValueSwappable*](swappable.requirements#:Cpp17ValueSwappable "16.4.4.3 Swappable requirements [swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
|
||
the type of *first meets
|
||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements (Table [31](utility.arg.requirements#tab:cpp17.moveconstructible "Table 31: Cpp17MoveConstructible requirements")) and
|
||
the [*Cpp17MoveAssignable*](utility.arg.requirements#:Cpp17MoveAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements"))[.](#push.heap-2.sentence-2)
|
||
|
||
[3](#push.heap-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10940)
|
||
|
||
*Effects*: Places the value in the location last - 1 into the resulting heap [first, last)[.](#push.heap-3.sentence-1)
|
||
|
||
[4](#push.heap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10945)
|
||
|
||
*Returns*: last for the overloads in namespace ranges[.](#push.heap-4.sentence-1)
|
||
|
||
[5](#push.heap-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10949)
|
||
|
||
*Complexity*: At most log(last - first) comparisons and twice as many projections[.](#push.heap-5.sentence-1)
|
||
|
||
#### [26.8.8.3](#pop.heap) pop_heap [[pop.heap]](pop.heap)
|
||
|
||
[ð](#lib:pop_heap)
|
||
|
||
`template<class RandomAccessIterator>
|
||
constexpr void pop_heap(RandomAccessIterator first, RandomAccessIterator last);
|
||
|
||
template<class RandomAccessIterator, class Compare>
|
||
constexpr void pop_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
|
||
template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Comp = ranges::less,
|
||
class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<I, Comp, Proj>
|
||
constexpr I
|
||
ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") R, class Comp = ranges::less, class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<iterator_t<R>, Comp, Proj>
|
||
constexpr borrowed_iterator_t<R>
|
||
ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[1](#pop.heap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10977)
|
||
|
||
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names[.](#pop.heap-1.sentence-1)
|
||
|
||
[2](#pop.heap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10982)
|
||
|
||
*Preconditions*: The range [first, last)
|
||
is a valid non-empty heap with respect to comp and proj[.](#pop.heap-2.sentence-1)
|
||
|
||
For the overloads in namespace std,RandomAccessIterator meets
|
||
the [*Cpp17ValueSwappable*](swappable.requirements#:Cpp17ValueSwappable "16.4.4.3 Swappable requirements [swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
|
||
the type of *first meets
|
||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template 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.2 Template argument requirements [utility.arg.requirements]") (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements")) requirements[.](#pop.heap-2.sentence-2)
|
||
|
||
[3](#pop.heap-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L10993)
|
||
|
||
*Effects*: Swaps the value in the location first with the value in the locationlast - 1 and makes
|
||
[first, last - 1)
|
||
into a heap with respect to comp and proj[.](#pop.heap-3.sentence-1)
|
||
|
||
[4](#pop.heap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11002)
|
||
|
||
*Returns*: last for the overloads in namespace ranges[.](#pop.heap-4.sentence-1)
|
||
|
||
[5](#pop.heap-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11006)
|
||
|
||
*Complexity*: At most 2log(last - first) comparisons and
|
||
twice as many projections[.](#pop.heap-5.sentence-1)
|
||
|
||
#### [26.8.8.4](#make.heap) make_heap [[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.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Comp = ranges::less,
|
||
class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept 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.6 Other range refinements [range.refinements]") R, class Comp = ranges::less, class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<iterator_t<R>, Comp, Proj>
|
||
constexpr borrowed_iterator_t<R>
|
||
ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[1](#make.heap-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[.](#make.heap-1.sentence-1)
|
||
|
||
[2](#make.heap-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.3 Swappable requirements [swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
|
||
the type of *first meets
|
||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template 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.2 Template argument requirements [utility.arg.requirements]") (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements")) requirements[.](#make.heap-2.sentence-1)
|
||
|
||
[3](#make.heap-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)[.](#make.heap-3.sentence-1)
|
||
|
||
[4](#make.heap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11054)
|
||
|
||
*Returns*: last for the overloads in namespace ranges[.](#make.heap-4.sentence-1)
|
||
|
||
[5](#make.heap-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11058)
|
||
|
||
*Complexity*: At most 3(last - first) comparisons and twice as many projections[.](#make.heap-5.sentence-1)
|
||
|
||
#### [26.8.8.5](#sort.heap) sort_heap [[sort.heap]](sort.heap)
|
||
|
||
[ð](#lib:sort_heap)
|
||
|
||
`template<class RandomAccessIterator>
|
||
constexpr void sort_heap(RandomAccessIterator first, RandomAccessIterator last);
|
||
|
||
template<class RandomAccessIterator, class Compare>
|
||
constexpr void sort_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
|
||
template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Comp = ranges::less,
|
||
class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<I, Comp, Proj>
|
||
constexpr I
|
||
ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") R, class Comp = ranges::less, class Proj = identity>
|
||
requires [sortable](alg.req.sortable#concept:sortable "24.3.7.8 Concept sortable [alg.req.sortable]")<iterator_t<R>, Comp, Proj>
|
||
constexpr borrowed_iterator_t<R>
|
||
ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[1](#sort.heap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11086)
|
||
|
||
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names[.](#sort.heap-1.sentence-1)
|
||
|
||
[2](#sort.heap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11091)
|
||
|
||
*Preconditions*: The range [first, last) is
|
||
a valid heap with respect to comp and proj[.](#sort.heap-2.sentence-1)
|
||
|
||
For the overloads in namespace std,RandomAccessIterator meets
|
||
the [*Cpp17ValueSwappable*](swappable.requirements#:Cpp17ValueSwappable "16.4.4.3 Swappable requirements [swappable.requirements]") requirements ([[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")) and
|
||
the type of *first meets
|
||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template 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.2 Template argument requirements [utility.arg.requirements]") (Table [33](utility.arg.requirements#tab:cpp17.moveassignable "Table 33: Cpp17MoveAssignable requirements")) requirements[.](#sort.heap-2.sentence-2)
|
||
|
||
[3](#sort.heap-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11102)
|
||
|
||
*Effects*: Sorts elements in the heap [first, last)
|
||
with respect to comp and proj[.](#sort.heap-3.sentence-1)
|
||
|
||
[4](#sort.heap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11107)
|
||
|
||
*Returns*: last for the overloads in namespace ranges[.](#sort.heap-4.sentence-1)
|
||
|
||
[5](#sort.heap-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11111)
|
||
|
||
*Complexity*: At most 2NlogN comparisons, where N=last - first, and
|
||
twice as many projections[.](#sort.heap-5.sentence-1)
|
||
|
||
#### [26.8.8.6](#is.heap) is_heap [[is.heap]](is.heap)
|
||
|
||
[ð](#lib:is_heap)
|
||
|
||
`template<class RandomAccessIterator>
|
||
constexpr bool is_heap(RandomAccessIterator first, RandomAccessIterator last);
|
||
`
|
||
|
||
[1](#is.heap-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11126)
|
||
|
||
*Effects*: Equivalent to: return is_heap_until(first, last) == last;
|
||
|
||
[ð](#lib:is_heap_)
|
||
|
||
`template<class ExecutionPolicy, class RandomAccessIterator>
|
||
bool is_heap(ExecutionPolicy&& exec,
|
||
RandomAccessIterator first, RandomAccessIterator last);
|
||
`
|
||
|
||
[2](#is.heap-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11139)
|
||
|
||
*Effects*: Equivalent to:return is_heap_until(std::forward<ExecutionPolicy>(exec), first, last) == last;
|
||
|
||
[ð](#lib:is_heap__)
|
||
|
||
`template<class RandomAccessIterator, class Compare>
|
||
constexpr bool is_heap(RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
`
|
||
|
||
[3](#is.heap-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11155)
|
||
|
||
*Effects*: Equivalent to: return is_heap_until(first, last, comp) == last;
|
||
|
||
[ð](#lib:is_heap___)
|
||
|
||
`template<class ExecutionPolicy, class RandomAccessIterator, class Compare>
|
||
bool is_heap(ExecutionPolicy&& exec,
|
||
RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
`
|
||
|
||
[4](#is.heap-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11169)
|
||
|
||
*Effects*: Equivalent to:return is_heap_until(std::forward<ExecutionPolicy>(exec), first, last, comp) == last;
|
||
|
||
[ð](#lib:is_heap____)
|
||
|
||
`template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<I, Proj>> Comp = ranges::less>
|
||
constexpr bool ranges::is_heap(I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") R, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<iterator_t<R>, Proj>> Comp = ranges::less>
|
||
constexpr bool ranges::is_heap(R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[5](#is.heap-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11188)
|
||
|
||
*Effects*: Equivalent to:return ranges::is_heap_until(first, last, comp, proj) == last;
|
||
|
||
[ð](#is.heap-itemdecl:6)
|
||
|
||
`template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I> S,
|
||
class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<I, Proj>> Comp = ranges::less>
|
||
bool ranges::is_heap(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<iterator_t<R>, Proj>> Comp = ranges::less>
|
||
bool ranges::is_heap(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[6](#is.heap-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11205)
|
||
|
||
*Effects*: Equivalent to:return ranges::is_heap_until(std::forward<Ep>(exec), first, last, comp, proj) == last;
|
||
|
||
[ð](#lib:is_heap_until)
|
||
|
||
`template<class RandomAccessIterator>
|
||
constexpr RandomAccessIterator
|
||
is_heap_until(RandomAccessIterator first, RandomAccessIterator last);
|
||
template<class ExecutionPolicy, class RandomAccessIterator>
|
||
RandomAccessIterator
|
||
is_heap_until(ExecutionPolicy&& exec,
|
||
RandomAccessIterator first, RandomAccessIterator last);
|
||
|
||
template<class RandomAccessIterator, class Compare>
|
||
constexpr RandomAccessIterator
|
||
is_heap_until(RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
template<class ExecutionPolicy, class RandomAccessIterator, class Compare>
|
||
RandomAccessIterator
|
||
is_heap_until(ExecutionPolicy&& exec,
|
||
RandomAccessIterator first, RandomAccessIterator last,
|
||
Compare comp);
|
||
|
||
template<[random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<I> S, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<I, Proj>> Comp = ranges::less>
|
||
constexpr I ranges::is_heap_until(I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[random_access_range](range.refinements#concept:random_access_range "25.4.6 Other range refinements [range.refinements]") R, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<iterator_t<R>, Proj>> Comp = ranges::less>
|
||
constexpr borrowed_iterator_t<R>
|
||
ranges::is_heap_until(R&& r, Comp comp = {}, Proj proj = {});
|
||
|
||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [random_access_iterator](iterator.concept.random.access#concept:random_access_iterator "24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]") I, [sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_sentinel_for [iterator.concept.sizedsentinel]")<I> S,
|
||
class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<I, Proj>> Comp = ranges::less>
|
||
I ranges::is_heap_until(Ep&& exec, I first, S last, Comp comp = {}, Proj proj = {});
|
||
template<[execution-policy](algorithms.parallel.defns#concept:execution-policy "26.3.1 Preamble [algorithms.parallel.defns]") Ep, [sized-random-access-range](range.refinements#concept:sized-random-access-range "25.4.6 Other range refinements [range.refinements]") R, class Proj = identity,
|
||
[indirect_strict_weak_order](indirectcallable.indirectinvocable#concept:indirect_strict_weak_order "24.3.6.3 Indirect callables [indirectcallable.indirectinvocable]")<projected<iterator_t<R>, Proj>> Comp = ranges::less>
|
||
borrowed_iterator_t<R>
|
||
ranges::is_heap_until(Ep&& exec, R&& r, Comp comp = {}, Proj proj = {});
|
||
`
|
||
|
||
[7](#is.heap-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11252)
|
||
|
||
Let comp be less{} and proj be identity{} for the overloads with no parameters by those names[.](#is.heap-7.sentence-1)
|
||
|
||
[8](#is.heap-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11257)
|
||
|
||
*Returns*: The last iterator i in [first, last]
|
||
for which the range [first, i)
|
||
is a heap with respect to comp and proj[.](#is.heap-8.sentence-1)
|
||
|
||
[9](#is.heap-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/algorithms.tex#L11263)
|
||
|
||
*Complexity*: Linear[.](#is.heap-9.sentence-1)
|