---
name: "qbmap.h"
section: "3"
platform: "linux"
package: "libqb"
version: "2.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/qbmap.h"
---

# qbmap.h(3)

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

## NAME

qbmap.h - This provides a map interface to a Patricia trie, hashtable or skiplist.

## SYNOPSIS

```
#include <qb/qbmap.h>
```

## DESCRIPTION

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).

## SEE ALSO

[*qb\_trie\_dump*(3)](/qb_trie_dump/3.md), [*qb\_map\_iter\_create*(3)](/qb_map_iter_create/3.md), [*qb\_skiplist\_create*(3)](/qb_skiplist_create/3.md), [*qb\_map\_notify\_del*(3)](/qb_map_notify_del/3.md), [*qb\_map\_put*(3)](/qb_map_put/3.md), [*qb\_map\_count\_get*(3)](/qb_map_count_get/3.md), [*qb\_map\_foreach*(3)](/qb_map_foreach/3.md), [*qb\_map\_pref\_iter\_create*(3)](/qb_map_pref_iter_create/3.md), [*qb\_map\_iter\_next*(3)](/qb_map_iter_next/3.md), [*qb\_map\_get*(3)](/qb_map_get/3.md), [*qb\_map\_destroy*(3)](/qb_map_destroy/3.md), [*qb\_hashtable\_create*(3)](/qb_hashtable_create/3.md), [*qb\_map\_iter\_free*(3)](/qb_map_iter_free/3.md), [*qb\_map\_notify\_add*(3)](/qb_map_notify_add/3.md), [*qb\_trie\_create*(3)](/qb_trie_create/3.md), [*qb\_map\_notify\_del\_2*(3)](/qb_map_notify_del_2/3.md), [*qb\_map\_rm*(3)](/qb_map_rm/3.md)

## COPYRIGHT

Copyright (C) 2010-2020 Red Hat, Inc.
