How to change max element in a heap in C++ standard library?

后端 未结 2 709
一整个雨季
一整个雨季 2020-12-11 17:53

If I have a max heap, and if I need to change the max element, it comes down to a single bubble-down algorithm. Is there any way to do this via the C++ standard library, wit

2条回答
  •  萌比男神i
    2020-12-11 18:25

    The closest you'll get is std::make_heap, which is probably slower than simply pop/push.

    However, boost heap(s?) have "The Fixup Interface" which allows modifications like you desire. http://www.boost.org/doc/libs/1_51_0/doc/html/heap/concepts.html#heap.concepts.mutability

提交回复
热议问题