.\" Automatically generated man page, do not edit .TH QBMAP.H 3 2023-07-21 "LIBQB" "libqb Programmer's Manual" .SH NAME qbmap.h \- This provides a map interface to a Patricia trie, hashtable or skiplist. .SH SYNOPSIS .nf .B #include .SH DESCRIPTION .PP Ordering .PP The hashtable is NOT ordered, but ptrie and skiplist are. .PP Iterating .PP Below is a simple example of how to iterate over a map. .nf 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 > %s\n", p, (char*) data); } qb_map_iter_free(it); .fi .PP 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. .nf qb_map_notify_add(m, NULL, my_map_free_handler, QB_MAP_NOTIFY_FREE, NULL); .fi .PP Notifications .PP These allow you to get callbacks when values are inserted/removed or replaced. .PP Prefix matching .PP The ptrie supports prefixes in the iterator: .nf it = qb_map_pref_iter_create(m, "aa"); while ((p = qb_map_iter_next(it, &data)) != NULL) { printf("%s > %s\n", p, (char*)data); } qb_map_iter_free(it); .fi .PP The ptrie also supports prefixes in notifications: (remember to pass QB_MAP_NOTIFY_RECURSIVE into the notify_add. .nf 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); .fi .SH NOTE .PP hashtable only supports deletion and replacement notificatins. There is also a special global callback for freeing deleted and replaced values (QB_MAP_NOTIFY_FREE). .SH SEE ALSO .PP .nh .ad l \fIqb_trie_dump\fR(3), \fIqb_map_iter_create\fR(3), \fIqb_skiplist_create\fR(3), \fIqb_map_notify_del\fR(3), \fIqb_map_put\fR(3), \fIqb_map_count_get\fR(3), \fIqb_map_foreach\fR(3), \fIqb_map_pref_iter_create\fR(3), \fIqb_map_iter_next\fR(3), \fIqb_map_get\fR(3), \fIqb_map_destroy\fR(3), \fIqb_hashtable_create\fR(3), \fIqb_map_iter_free\fR(3), \fIqb_map_notify_add\fR(3), \fIqb_trie_create\fR(3), \fIqb_map_notify_del_2\fR(3), \fIqb_map_rm\fR(3) .ad .hy .SH "COPYRIGHT" .PP Copyright (C) 2010-2020 Red Hat, Inc.