This provides a map interface to a Patricia trie, hashtable or skiplist.
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);
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);
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);
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);