postgresql/src/backend/lib
David Rowley 7c335b7a20 Add doubly linked count list implementation
We have various requirements when using a dlist_head to keep track of the
number of items in the list.  This, traditionally, has been done by
maintaining a counter variable in the calling code.  Here we tidy this up
by adding "dclist", which is very similar to dlist but also keeps track of
the number of items stored in the list.

Callers may use the new dclist_count() function when they need to know how
many items are stored. Obtaining the count is an O(1) operation.

For simplicity reasons, dclist and dlist both use dlist_node as their node
type and dlist_iter/dlist_mutable_iter as their iterator type. dclists
have all of the same functionality as dlists except there is no function
named dclist_delete().  To remove an item from a list dclist_delete_from()
must be used.  This requires knowing which dclist the given item is stored
in.

Additionally, here we also convert some dlists where additional code
exists to keep track of the number of items stored and to make these use
dclists instead.

Author: David Rowley
Reviewed-by: Bharath Rupireddy, Aleksander Alekseev
Discussion: https://postgr.es/m/CAApHDvrtVxr+FXEX0VbViCFKDGxA3tWDgw9oFewNXCJMmwLjLg@mail.gmail.com
2022-11-02 14:06:05 +13:00
..
Makefile Make StringInfo available to frontend code. 2019-11-05 14:56:40 -08:00
README Add IntegerSet, to hold large sets of 64-bit ints efficiently. 2019-03-22 13:21:45 +02:00
binaryheap.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
bipartite_match.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
bloomfilter.c Harmonize parameter names in storage and AM code. 2022-09-19 19:18:36 -07:00
dshash.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
hyperloglog.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
ilist.c Add doubly linked count list implementation 2022-11-02 14:06:05 +13:00
integerset.c Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
knapsack.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
meson.build meson: Add initial version of meson based build system 2022-09-21 22:37:17 -07:00
pairingheap.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
rbtree.c Add missing inequality searches to rbtree 2022-07-08 22:00:03 +03:00

README

This directory contains a general purpose data structures, for use anywhere
in the backend:

binaryheap.c - a binary heap

bipartite_match.c - Hopcroft-Karp maximum cardinality algorithm for bipartite graphs

bloomfilter.c - probabilistic, space-efficient set membership testing

dshash.c - concurrent hash tables backed by dynamic shared memory areas

hyperloglog.c - a streaming cardinality estimator

ilist.c - single and double-linked lists

integerset.c - a data structure for holding large set of integers

knapsack.c - knapsack problem solver

pairingheap.c - a pairing heap

rbtree.c - a red-black tree

stringinfo.c - an extensible string type


Aside from the inherent characteristics of the data structures, there are a
few practical differences between the binary heap and the pairing heap. The
binary heap is fully allocated at creation, and cannot be expanded beyond the
allocated size. The pairing heap on the other hand has no inherent maximum
size, but the caller needs to allocate each element being stored in the heap,
while the binary heap works with plain Datums or pointers.

The linked-lists in ilist.c can be embedded directly into other structs, as
opposed to the List interface in nodes/pg_list.h.