1QBMAP.H(3)                 libqb Programmer's Manual                QBMAP.H(3)
2
3
4

NAME

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

SYNOPSIS

11       #include <qb/qbmap.h>
12

DESCRIPTION

14       Ordering
15
16       The hashtable is NOT ordered, but ptrie and skiplist are.
17
18       Iterating
19
20       Below is a simple example of how to iterate over a map.
21
22       const char *p;
23       void *data;
24       qb_map_iter_t *it = qb_map_iter_create(m);
25       for (p = qb_map_iter_next(it, &data); p; p = qb_map_iter_next(it, &data)) {
26           printf("%s > %s0, p, (char*) data);
27       }
28       qb_map_iter_free(it);
29
30
31       Deletion of items within the iterator is supported.  But  note  do  not
32       free  the  item  memory  in  the iterator. If you need to free the data
33       items then register for a notifier and free the memory there.  This  is
34       required as the items are reference counted.
35
36       qb_map_notify_add(m, NULL, my_map_free_handler,
37                    QB_MAP_NOTIFY_FREE, NULL);
38
39
40       Notifications
41
42       These  allow  you  to get callbacks when values are inserted/removed or
43       replaced.
44
45       Prefix matching
46
47       The ptrie supports prefixes in the iterator:
48
49       it = qb_map_pref_iter_create(m, "aa");
50       while ((p = qb_map_iter_next(it, &data)) != NULL) {
51           printf("%s > %s0, p, (char*)data);
52       }
53       qb_map_iter_free(it);
54
55
56       The ptrie also supports prefixes in notifications:  (remember  to  pass
57       QB_MAP_NOTIFY_RECURSIVE into the notify_add.
58
59       qb_map_notify_add(m, "root", my_map_notification,
60                   (QB_MAP_NOTIFY_INSERTED|
61                    QB_MAP_NOTIFY_DELETED|
62                    QB_MAP_NOTIFY_REPLACED|
63                    QB_MAP_NOTIFY_RECURSIVE),
64                   NULL);
65
66

NOTE

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

SEE ALSO

73       qb_trie_dump(3), qb_map_iter_create(3), qb_skiplist_create(3),
74       qb_map_notify_del(3), qb_map_put(3), qb_map_count_get(3),
75       qb_map_foreach(3), qb_map_pref_iter_create(3), qb_map_iter_next(3),
76       qb_map_get(3), qb_map_destroy(3), qb_hashtable_create(3),
77       qb_map_iter_free(3), qb_map_notify_add(3), qb_trie_create(3),
78       qb_map_notify_del_2(3), qb_map_rm(3)
79
81       Copyright (C) 2010-2020 Red Hat, Inc.
82
83
84
85LIBQB                             2021-03-03                        QBMAP.H(3)
Impressum