Add function for removing arbitrary nodes in binaryheap.
authorNathan Bossart <nathan@postgresql.org>
Mon, 18 Sep 2023 21:06:08 +0000 (14:06 -0700)
committerNathan Bossart <nathan@postgresql.org>
Mon, 18 Sep 2023 21:06:08 +0000 (14:06 -0700)
commitc103d073819a2189d849c0a93d51c726be524c48
treec590a7adbbc8de211687517da7fca32dfcffe2d9
parent83223f5f714482dd44883c68ecac2ae8c2d838e8
Add function for removing arbitrary nodes in binaryheap.

This commit introduces binaryheap_remove_node(), which can be used
to remove any node from a binary heap.  The implementation is
straightforward.  The target node is replaced with the last node in
the heap, and then we sift as needed to preserve the heap property.
This new function is intended for use in a follow-up commit that
will improve the performance of pg_restore.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/3612876.1689443232%40sss.pgh.pa.us
src/common/binaryheap.c
src/include/lib/binaryheap.h