|
| #define | BEGIN_DECL |
| |
| #define | END_DECL |
| |
| #define | DICT_VERSION_MAJOR 0 |
| |
| #define | DICT_VERSION_MINOR 3 |
| |
| #define | DICT_VERSION_PATCH 0 |
| |
| #define | dict_private(dct) |
| |
| #define | dict_insert(dct, key) |
| |
| #define | dict_search(dct, key) |
| | Return the address of the datum stored for |key|, or NULL if |key| is not present.
|
| |
| #define | dict_is_sorted(dct) |
| |
| #define | dict_search_le(dct, key) |
| | Near searches on sorted containers: return the address of the datum of the greatest key less than or equal to (le) or less than (lt) |key|, or of the least key greater than or equal to (ge) or greater than (gt) |key|; NULL if there is no such key.
|
| |
| #define | dict_search_lt(dct, key) |
| |
| #define | dict_search_ge(dct, key) |
| |
| #define | dict_search_gt(dct, key) |
| |
| #define | dict_remove(dct, key) |
| |
| #define | dict_clear(dct, func) |
| |
| #define | dict_traverse(dct, func, ud) |
| |
| #define | dict_select(dct, n, key, d) |
| | Retrieve the |n|th element in key order (0-based), storing its key in |key| and its datum in |d|, and evaluating to true.
|
| |
| #define | dict_count(dct) |
| |
| #define | dict_verify(dct) |
| | Check the container's internal invariants and evaluate to true if they hold.
|
| |
| #define | dict_itor_new(dct) |
| |
| #define | dict_itor_private(i) |
| |
| #define | dict_itor_valid(i) |
| |
| #define | dict_itor_invalidate(i) |
| |
| #define | dict_itor_next(i) |
| |
| #define | dict_itor_prev(i) |
| |
| #define | dict_itor_nextn(i, n) |
| |
| #define | dict_itor_prevn(i, n) |
| |
| #define | dict_itor_first(i) |
| |
| #define | dict_itor_last(i) |
| |
| #define | dict_itor_search(i, k) |
| | Position the iterator on |k| (exact match) and evaluate to true, or leave it unpositioned and evaluate to false if |k| is not present.
|
| |
| #define | dict_itor_search_le(i, k) |
| |
| #define | dict_itor_search_lt(i, k) |
| |
| #define | dict_itor_search_ge(i, k) |
| |
| #define | dict_itor_search_gt(i, k) |
| |
| #define | dict_itor_key(i) |
| |
| #define | dict_itor_datum(i) |
| |
| #define | dict_itor_compare(i1, i2) |
| | Compare the positions of two iterators over the same dictionary.
|
| |
| #define | dict_itor_remove(i) |
| |
|
| typedef int(* | dict_compare_func) (const void *, const void *) |
| | A pointer to a function that compares two keys.
|
| |
| typedef void(* | dict_delete_func) (void *, void *) |
| | A pointer to a function that is called when a key-value pair gets removed from a dictionary.
|
| |
| typedef bool(* | dict_visit_func) (const void *, void *, void *) |
| | A pointer to a function used for iterating over dictionary contents.
|
| |
| typedef unsigned(* | dict_hash_func) (const void *) |
| | A pointer to a function that returns the hash value of a key.
|
| |
| typedef unsigned(* | dict_prio_func) (const void *) |
| | A pointer to a function that returns the priority of a key, used by tr_tree (a treap).
|
| |
| typedef struct dict_itor | dict_itor |
| | Forward declaration of dict_itor, whose definition appears below.
|
| |
| typedef dict_itor *(* | dict_inew_func) (void *obj) |
| |
| typedef size_t(* | dict_dfree_func) (void *obj, dict_delete_func delete_func) |
| |
| typedef dict_insert_result(* | dict_insert_func) (void *obj, void *key) |
| |
| typedef void **(* | dict_search_func) (void *obj, const void *key) |
| |
| typedef dict_remove_result(* | dict_remove_func) (void *obj, const void *key) |
| |
| typedef size_t(* | dict_clear_func) (void *obj, dict_delete_func delete_func) |
| |
| typedef size_t(* | dict_traverse_func) (void *obj, dict_visit_func visit, void *user_data) |
| |
| typedef bool(* | dict_select_func) (void *obj, size_t n, const void **key, void **datum) |
| |
| typedef size_t(* | dict_count_func) (const void *obj) |
| |
| typedef bool(* | dict_verify_func) (const void *obj) |
| |
| typedef void(* | dict_ifree_func) (void *itor) |
| |
| typedef bool(* | dict_valid_func) (const void *itor) |
| |
| typedef void(* | dict_invalidate_func) (void *itor) |
| |
| typedef bool(* | dict_next_func) (void *itor) |
| |
| typedef bool(* | dict_prev_func) (void *itor) |
| |
| typedef bool(* | dict_nextn_func) (void *itor, size_t count) |
| |
| typedef bool(* | dict_prevn_func) (void *itor, size_t count) |
| |
| typedef bool(* | dict_first_func) (void *itor) |
| |
| typedef bool(* | dict_last_func) (void *itor) |
| |
| typedef void *(* | dict_key_func) (void *itor) |
| |
| typedef void **(* | dict_datum_func) (void *itor) |
| |
| typedef bool(* | dict_isearch_func) (void *itor, const void *key) |
| |
| typedef bool(* | dict_iremove_func) (void *itor) |
| |
| typedef int(* | dict_icompare_func) (void *itor1, void *itor2) |
| |
|
| size_t | dict_free (dict *dct, dict_delete_func delete_func) |
| |
| void | dict_itor_free (dict_itor *itor) |
| |
| int | dict_int_cmp (const void *k1, const void *k2) |
| | Comparison functions for common key types, for use as dict_compare_func.
|
| |
| int | dict_uint_cmp (const void *k1, const void *k2) |
| |
| int | dict_long_cmp (const void *k1, const void *k2) |
| |
| int | dict_ulong_cmp (const void *k1, const void *k2) |
| |
| int | dict_ptr_cmp (const void *k1, const void *k2) |
| |
| int | dict_str_cmp (const void *k1, const void *k2) |
| |
| unsigned | dict_str_hash (const void *str) |
| | FNV-1a hash of a NUL-terminated string, over its bytes in order, so a key hashes to the same value on every platform.
|
| |
| #define dict_itor_compare |
( |
| i1, |
|
|
| i2 ) |
Value:((i1)->_vtable->compare ? (i1)->_vtable->compare((i1)->_itor, (i2)->_itor) : 0)
Compare the positions of two iterators over the same dictionary.
Returns a negative value, zero or a positive value as |i1| precedes, is at, or follows |i2|. Evaluates to 0 if the container supplies no comparison.
Definition at line 263 of file dict.h.
| #define dict_itor_search |
( |
| i, |
|
|
| k ) |
Value:((i)->_vtable->search((i)->_itor, (k)))
Position the iterator on |k| (exact match) and evaluate to true, or leave it unpositioned and evaluate to false if |k| is not present.
The le, _lt, _ge and _gt variants position it on the same key the corresponding dict_search* finds; on the hash tables they evaluate to false and leave the iterator unchanged.
Definition at line 253 of file dict.h.
| #define dict_search_le |
( |
| dct, |
|
|
| key ) |
Value:((dct)->_vtable->search_le ? (dct)->_vtable->search_le((dct)->_object, (key)) : NULL)
Near searches on sorted containers: return the address of the datum of the greatest key less than or equal to (le) or less than (lt) |key|, or of the least key greater than or equal to (ge) or greater than (gt) |key|; NULL if there is no such key.
They evaluate to NULL on the hash tables, which are not sorted.
Definition at line 180 of file dict.h.
| #define dict_select |
( |
| dct, |
|
|
| n, |
|
|
| key, |
|
|
| d ) |
Value:((dct)->_vtable->select && (dct)->_vtable->select((dct)->_object, (n), (key), (d)))
Retrieve the |n|th element in key order (0-based), storing its key in |key| and its datum in |d|, and evaluating to true.
Either out-parameter may be NULL. If |n| is out of range, evaluates to false and stores NULL through any non-NULL out-parameter. Containers that do not support selection (the hash tables and the skip list) evaluate to false and store nothing.
Definition at line 192 of file dict.h.
| typedef int(* dict_compare_func) (const void *, const void *) |
A pointer to a function that compares two keys.
It needs to return a negative value if k1<k2, a positive value if k1>k2, and zero if the keys are equal. The comparison must be a total order, i.e. reflexive (cmp(k,k)==0), antisymmetric (k1>k2 implies k2<k1) and transitive (k1>k2 and k2>k3 implies k1>k3). Keys must compare identically for as long as they are in the dictionary.
Definition at line 59 of file dict.h.
| int dict_int_cmp |
( |
const void * | k1, |
|
|
const void * | k2 ) |
Comparison functions for common key types, for use as dict_compare_func.
The keys are pointers to values of the type, except for dict_ptr_cmp, which orders the key pointers themselves (by address, as uintptr_t), and dict_str_cmp, which takes NUL-terminated strings. dict_str_cmp orders bytes as unsigned char, exactly as strcmp() does, so string keys sort the same on every platform.
Definition at line 41 of file dict.c.