qbmap.h(3)

qbmap.h3

This provides a map interface to a patricia trie, hashtable or skiplist.

Usage

#include <qb/qbmap.h>

Overview

Ordering

The hashtable is NOT ordered, but ptrie and skiplist are.

Iterating

Below is a simple example of how to iterate over a map.

const char *p;
void *data;
qb_map_iter_t *it = qb_map_iter_create(m);
for (p = qb_map_iter_next(it, &data); p; p = qb_map_iter_next(it, &data)) {
    printf("%s > %s0, p, (char*) data);
}
qb_map_iter_free(it);

Deletion of items within the iterator is supported. But note do not free the item memory in the iterator. If you need to free the data items then register for a notifier and free the memory there. This is required as the items are reference counted.

qb_map_notify_add(m, NULL, my_map_free_handler,
             QB_MAP_NOTIFY_FREE, NULL);

Notifications

These allow you to get callbacks when values are inserted/removed or replaced.

Prefix matching

The ptrie supports prefixes in the iterator:

it = qb_map_pref_iter_create(m, "aa");
while ((p = qb_map_iter_next(it, &data)) != NULL) {
    printf("%s > %s0, p, (char*)data);
}
qb_map_iter_free(it);

The ptrie also supports prefixes in notifications: (remember to pass QB_MAP_NOTIFY_RECURSIVE into the notify_add.

qb_map_notify_add(m, "root", my_map_notification,
            (QB_MAP_NOTIFY_INSERTED|
             QB_MAP_NOTIFY_DELETED|
             QB_MAP_NOTIFY_REPLACED|
             QB_MAP_NOTIFY_RECURSIVE),
            NULL);

Note

hashtable only supports deletion and replacement notificatins. There is also a special global callback for freeing deleted and replaced values (QB_MAP_NOTIFY_FREE).

Releases

8 releases since Debian 7 (Wheezy); the text changed 6 times.

  1. 7–8
  2. 9
  3. 10
  4. 11
  5. 12
  6. 13
  7. Arch

From libqb 2.0.10-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.