libstdc++: Heap

libstdc++

Heap
Algorithms » Sorting
Collaboration diagram for Heap:

## Functions
template<typename _RandomAccessIterator>
constexpr bool | std::is_heap (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr bool | std::is_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
template<typename _RandomAccessIterator>
constexpr _RandomAccessIterator | std::is_heap_until (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr _RandomAccessIterator | std::is_heap_until (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
template<typename _RandomAccessIterator>
constexpr void | std::make_heap (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr void | std::make_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
template<typename _RandomAccessIterator>
constexpr void | std::pop_heap (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr void | std::pop_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
template<typename _RandomAccessIterator>
constexpr void | std::push_heap (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr void | std::push_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
template<typename _RandomAccessIterator>
constexpr void | std::sort_heap (_RandomAccessIterator __first, _RandomAccessIterator __last)
template<typename _RandomAccessIterator, typename _Compare>
constexpr void | std::sort_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)

## Detailed Description

## Function Documentation

## ◆ is_heap() [1/2]

template<typename _RandomAccessIterator>

bool std::is_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlinenodiscardconstexpr

Determines whether a range is a heap.

Parameters

  __first | Start of range.
  __last | End of range.

Returns
  True if range is a heap, false otherwise.

Definition at line 547 of file stl_heap.h.

## ◆ is_heap() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

bool std::is_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlinenodiscardconstexpr

Determines whether a range is a heap using comparison functor.

Parameters

  __first | Start of range.
  __last | End of range.
  __comp | Comparison functor to use.

Returns
  True if range is a heap, false otherwise.

Definition at line 561 of file stl_heap.h.

References distance().

## ◆ is_heap_until() [1/2]

template<typename _RandomAccessIterator>

_RandomAccessIterator std::is_heap_until | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlinenodiscardconstexpr

Search the end of a heap.

Parameters

  __first | Start of range.
  __last | End of range.

Returns
  An iterator pointing to the first element not in the heap.

This operation returns the last iterator i in [__first, __last) for which the range [__first, i) is a heap.

Definition at line 494 of file stl_heap.h.

References distance().

## ◆ is_heap_until() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

_RandomAccessIterator std::is_heap_until | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlinenodiscardconstexpr

Search the end of a heap using comparison functor.

Parameters

  __first | Start of range.
  __last | End of range.
  __comp | Comparison functor to use.

Returns
  An iterator pointing to the first element not in the heap.

This operation returns the last iterator i in [__first, __last) for which the range [__first, i) is a heap. Comparisons are made using __comp.

Definition at line 523 of file stl_heap.h.

References distance().

## ◆ make_heap() [1/2]

template<typename _RandomAccessIterator>

void std::make_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlineconstexpr

Construct a heap over a range.

Parameters

  __first | Start of heap.
  __last | End of heap.

This operation makes the elements in [__first,__last) into a heap.

Definition at line 376 of file stl_heap.h.

## ◆ make_heap() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

void std::make_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlineconstexpr

Construct a heap over a range using comparison functor.

Parameters

  __first | Start of heap.
  __last | End of heap.
  __comp | Comparison functor to use.

This operation makes the elements in [__first,__last) into a heap. Comparisons are made using __comp.

Definition at line 403 of file stl_heap.h.

## ◆ pop_heap() [1/2]

template<typename _RandomAccessIterator>

void std::pop_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlineconstexpr

Pop an element off a heap.

Parameters

  __first | Start of heap.
  __last | End of heap.

Precondition
  [__first, __last) is a valid, non-empty range.

This operation pops the top of the heap. The elements __first and __last-1 are swapped and [__first,__last-1) is made into a heap.

Definition at line 286 of file stl_heap.h.

## ◆ pop_heap() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

void std::pop_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlineconstexpr

Pop an element off a heap using comparison functor.

Parameters

  __first | Start of heap.
  __last | End of heap.
  __comp | Comparison functor to use.

This operation pops the top of the heap. The elements __first and __last-1 are swapped and [__first,__last-1) is made into a heap. Comparisons are made using comp.

Definition at line 320 of file stl_heap.h.

## ◆ push_heap() [1/2]

template<typename _RandomAccessIterator>

void std::push_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlineconstexpr

Push an element onto a heap.

Parameters

  __first | Start of heap.
  __last | End of heap + element.

This operation pushes the element at last-1 onto the valid heap over the range [__first,__last-1). After completion, [__first,__last) is a valid heap.

Definition at line 169 of file stl_heap.h.

## ◆ push_heap() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

void std::push_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlineconstexpr

Push an element onto a heap using comparison functor.

Parameters

  __first | Start of heap.
  __last | End of heap + element.
  __comp | Comparison functor.

This operation pushes the element at __last-1 onto the valid heap over the range [__first,__last-1). After completion, [__first,__last) is a valid heap. Compare operations are performed using comp.

Definition at line 205 of file stl_heap.h.

## ◆ sort_heap() [1/2]

template<typename _RandomAccessIterator>

void std::sort_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last )
| inlineconstexpr

Sort a heap.

Parameters

  __first | Start of heap.
  __last | End of heap.

This operation sorts the valid heap in the range [__first,__last).

Definition at line 439 of file stl_heap.h.

## ◆ sort_heap() [2/2]

template<typename _RandomAccessIterator, typename _Compare>

void std::sort_heap | ( | _RandomAccessIterator | __first,
|  | _RandomAccessIterator | __last,
|  | _Compare | __comp )
| inlineconstexpr

Sort a heap using comparison functor.

Parameters

  __first | Start of heap.
  __last | End of heap.
  __comp | Comparison functor to use.

This operation sorts the valid heap in the range [__first,__last). Comparisons are made using __comp.

Definition at line 467 of file stl_heap.h.