DOKK / manpages / debian 12 / libcritnib-dev / critnib.3.en
libcritnib(3) critnib libcritnib(3)

libcritnib - an ordered map data structure with lock-free reads

#include <critnib.h>

Link with -lcritnib.

Creates a new empty critnib structure.
Destroys and frees the memory. Note that removed items are reused but won't have their memory freed until this function is called.
Adds a key:value pair to the critnib structure. If update is non-zero, an already existing key has its value updated, otherwise the function returns EEXIST. It may return ENOMEM if we're out of memory, or 0 if all went okay.
Removes a given key from the structure. Its associated value is returned, or 0 (NULL) if there was no such key.
Obtains a value for a given key, or 0 (NULL) if not present.
Searches for the largest key not exceeding the argument, and returns its value.
Searches for a key that's smaller (FIND_L), smaller-or-equal (FIND_LE), equal (FIND_EQ), greater-or-equal (FIND_GE), or greater (FIND_G) than the argument. If found, the key and value are assigned to *rkey and *rvalue (which may be null to skip assignment), and 1 is returned.
Walks the structure, visiting all entries whose keys are at least min but no larger than max (give -1 for no max), calling func for every entry found. If the func returns a non-zero value, the walk is aborted.

The prototype for func should be: int (*func)(uintptr_t key, void *value, void *privdata); where privdata is an optional value passed to the iterator.

NB. This version of the library implements the iterator in a crude blocking way, stalling any concurrent writers and iterators. This limitation will be lifted in the future.

2022-09-19 perl v5.34.0