postgresql/src/include/lib
Masahiko Sawada b840508644 Add functions to binaryheap for efficient key removal and update.
Previously, binaryheap didn't support updating a key and removing a
node in an efficient way. For example, in order to remove a node from
the binaryheap, the caller had to pass the node's position within the
array that the binaryheap internally has. Removing a node from the
binaryheap is done in O(log n) but searching for the key's position is
done in O(n).

This commit adds a hash table to binaryheap in order to track the
position of each nodes in the binaryheap. That way, by using newly
added functions such as binaryheap_update_up() etc., both updating a
key and removing a node can be done in O(1) on an average and O(log n)
in worst case. This is known as the indexed binary heap. The caller
can specify to use the indexed binaryheap by passing indexed = true.

The current code does not use the new indexing logic, but it will be
used by an upcoming patch.

Reviewed-by: Vignesh C, Peter Smith, Hayato Kuroda, Ajin Cherian,
Tomas Vondra, Shubham Khanna
Discussion: https://postgr.es/m/CAD21AoDffo37RC-eUuyHJKVEr017V2YYDLyn1xF_00ofptWbkg%40mail.gmail.com
2024-04-03 10:44:21 +09:00
..
binaryheap.h Add functions to binaryheap for efficient key removal and update. 2024-04-03 10:44:21 +09:00
bipartite_match.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
bloomfilter.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
dshash.h Fix comments for the dshash_parameters struct. 2024-02-27 09:44:59 -06:00
hyperloglog.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
ilist.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
integerset.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
knapsack.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pairingheap.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
qunique.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
radixtree.h Remove superfluous trailing semicolons 2024-03-29 23:51:43 +01:00
rbtree.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
simplehash.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
sort_template.h Introduce overflow-safe integer comparison functions. 2024-02-16 13:37:02 -06:00
stringinfo.h Add destroyStringInfo function for cleaning up StringInfos 2024-03-16 23:18:28 +01:00