#include #include #include int main() { std::vector v = {3, 5, 1, 2, 9, 0, 6, 15}; //* init std::make_heap(v.begin(), v.end(), std::greater()); //* pop std::cout << "1: " << v.front() << '\n'; std::pop_heap(v.begin(), v.end(), std::greater()); v.pop_back(); //* push v.push_back(666); std::push_heap(v.begin(), v.end(), std::greater()); int i = 2; while (v.size()) { std::cout << i++ << ": " << v.front() << '\n'; std::pop_heap(v.begin(), v.end(), std::greater()); v.pop_back(); } return 0; }