Inhaltsverzeichnis

push_heap()

#include <algorithm>

void push_heap (Ran first, Ran last) 
void push_heap (Ran first, Ran last, Binary comp) 
 
Ran ranges::push_heap (Range r, Binary comp = {}, proj = {}) 
Ran ranges::push_heap (Ran first, Ran last, Binary comp = {}, proj = {}) 

Fügt das letzte Element des Bereiches [first,last) in den davor liegenden, als Heap geordneten Bereich ein.

Parameter

first Anfang des Bereiches
last Ende des Bereiches
comp Vergleichskriterium (Vorgabe = less)
proj einstelliger Funktor (Vorgabe = std::identity)
pol parallele Ausführungsart

Ergebnis

Rückgabewert: Keiner bzw. last.

Siehe auch

is_heap(), make_heap(), push_heap(), pop_heap(), sort_heap().

Beispiel

push_heap.cpp
#include <algorithm>
#include <iostream>
#include <vector>
 
int main()
{
  std::vector<int> v = { 7, 3, 2, 0, 1, 9, 4, 6, 5, 8 };
 
  auto i = std::is_heap_until(begin(v), end(v));
 
  std::vector<int> heap(begin(v), i);
  for(auto e : v) std::cout << e << " "; std::cout << '\n';
  for(auto e : heap) std::cout << e << " "; std::cout << '\n';
 
  if (i != end(v))
  {
    std::push_heap(begin(v), i+1);
    for(auto e : v) std::cout << e << " "; std::cout << '\n';
 
    std::pop_heap(begin(v), i+1);
    for(auto e : v) std::cout << e << " "; std::cout << '\n';
  }
}