HEAP_ALGORITHMS(3)

πŸ“¦ version 4.4.0, in nixpkgs unstable

🫢 Heap Algorithms(3) 🫢

okay so bestie, welcome to Heap Algorithms(3) from the Library Functions Manual β€” this is the C++ heap algorithm friend group, and yes they're all templates, and yes they ate. πŸ’…

✨ NAME ✨

Heap Algorithms β€” literally the heap ops, no cap. Here's the whole function lineup:

🧸 Functions 🧸

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

🌸 Function Documentation 🌸

πŸ¦‹ std::is_heap β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > bool std::is_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

This one determines whether a range is a heap, using your comparison functor. It's the heap vibe check with _Compare, fr fr.

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 571 of file stl_heap.h.

References: std::is_heap_until().


πŸ¦‹ std::is_heap β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > bool std::is_heap (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

This one determines whether a range is a heap. No custom comparator here β€” just the range, bestie.

Parameters:

  • first β€” Start of range.
  • last β€” End of range.

Returns: True if range is a heap, false otherwise.

Definition at line 558 of file stl_heap.h.

References: std::is_heap_until().


πŸ¦‹ std::is_heap_until β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > _RandomAccessIterator std::is_heap_until (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

Search for the end of a heap, using your comparison functor. It's giving "where does the heap energy stop."

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.

okay so 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 536 of file stl_heap.h.

References: std::distance().

Referenced by: std::is_heap().


πŸ¦‹ std::is_heap_until β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > _RandomAccessIterator std::is_heap_until (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

Search for the end of a heap. No custom comparator, just the range.

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 510 of file stl_heap.h.

References: std::distance().


πŸ¦‹ std::make_heap β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > void std::make_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

Construct a heap over a range, using your comparison functor. This is the glow-up moment where your range becomes a heap.

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 413 of file stl_heap.h.

Referenced by: std::__heap_select(), std::partial_sort_copy(), and std::priority_queue< _Tp, _Sequence, _Compare >::priority_queue().


πŸ¦‹ std::make_heap β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > void std::make_heap (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

Construct a heap over a range. No custom comparator, just pure heap construction energy.

Parameters:

  • first β€” Start of heap.
  • last β€” End of heap.

This operation makes the elements in [first,last) into a heap.

Definition at line 373 of file stl_heap.h.


πŸ¦‹ std::pop_heap β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > void std::pop_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

Pop an element off a heap, using your comparison functor. It's the exit scene for the top of the heap.

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 350 of file stl_heap.h.

Referenced by: std::priority_queue< _Tp, _Sequence, _Compare >::pop().


πŸ¦‹ std::pop_heap β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > void std::pop_heap (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

Pop an element off a heap. No custom comparator, just the heap pop.

Parameters:

  • first β€” Start of heap.
  • last β€” End of heap.

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 276 of file stl_heap.h.


πŸ¦‹ std::push_heap β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > void std::push_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

Push an element onto a heap, using your comparison functor. Main character element enters the heap.

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 203 of file stl_heap.h.

Referenced by: std::priority_queue< _Tp, _Sequence, _Compare >::push().


πŸ¦‹ std::push_heap β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > void std::push_heap (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

Push an element onto a heap. No custom comparator, just the push.

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 154 of file stl_heap.h.


πŸ¦‹ std::sort_heap β€” with _Compare πŸ¦‹

template<typename _RandomAccessIterator , typename _Compare > void std::sort_heap (_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) [inline]

Sort a heap, using your comparison functor. The heap gets its life together and becomes sorted.

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 481 of file stl_heap.h.

Referenced by: std::partial_sort(), and std::partial_sort_copy().


πŸ¦‹ std::sort_heap β€” no _Compare πŸ¦‹

template<typename _RandomAccessIterator > void std::sort_heap (_RandomAccessIterator __first, _RandomAccessIterator __last) [inline]

Sort a heap. No custom comparator, just the sorting.

Parameters:

  • first β€” Start of heap.
  • last β€” End of heap.

This operation sorts the valid heap in the range [first,last).

Definition at line 452 of file stl_heap.h.


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code. Iconic, honestly.

xoxo, your Unix bestie πŸ’… β€” libstdc++, 21 Apr 2009, Heap Algorithms(3) πŸŽ€

πŸ“¦ where this page comes from