|
rlib
Convenience library for useful things
|
Refcounted hash set: the keys-only sibling of Hash table. More...
Files | |
| file | rhashset.h |
| Refcounted hash-set container. | |
Macros | |
| #define | r_hash_set_new(hash, equal) r_hash_set_new_full (hash, equal, NULL) |
| Convenience: construct a hash set with no destroy notifier. | |
| #define | r_hash_set_ref r_ref_ref |
| Increment the set's refcount. | |
| #define | r_hash_set_unref r_ref_unref |
| Decrement the set's refcount; clears all entries when it reaches zero. | |
Typedefs | |
| typedef struct RHashSet | RHashSet |
| Opaque refcounted hash set. | |
Functions | |
| RHashSet * | r_hash_set_new_full (RHashFunc hash, REqualFunc equal, RDestroyNotify notify) |
| Construct a hash set with custom hash / equality and an optional destroy notifier. | |
| rsize | r_hash_set_size (RHashSet *ht) |
| Number of items currently in the set. | |
| rsize | r_hash_set_current_alloc_size (RHashSet *ht) |
| Allocated bucket count. | |
| rsize | r_hash_set_max_probe (RHashSet *ht) |
| Worst-case unsuccessful-probe length; diagnostic for home distribution (small means items are well spread across the buckets). | |
| rboolean | r_hash_set_insert (RHashSet *ht, rpointer item) |
Add item to the set. | |
| rboolean | r_hash_set_contains (RHashSet *ht, rconstpointer item) |
TRUE iff item is present. | |
| rboolean | r_hash_set_contains_full (RHashSet *ht, rconstpointer item, rpointer *out) |
Look up item and return the set-owned pointer. | |
| void | r_hash_set_remove_all (RHashSet *ht) |
| Remove every item; destroy notifier runs. | |
| rboolean | r_hash_set_remove (RHashSet *ht, rconstpointer item) |
Remove item; destroy notifier runs. | |
| rboolean | r_hash_set_steal (RHashSet *ht, rconstpointer item, rpointer *out) |
Remove item without running the destroy notifier; hand the stored pointer back via out. | |
| rboolean | r_hash_set_foreach (RHashSet *ht, RFunc func, rpointer user) |
| Iterate every item in the set. | |
Refcounted hash set: the keys-only sibling of Hash table.
Same shape as RHashTable - caller-supplied hash and equality functions, optional destroy notifier - but each entry is a single rpointer instead of a (key, value) pair.
| rboolean r_hash_set_contains_full | ( | RHashSet * | ht, |
| rconstpointer | item, | ||
| rpointer * | out | ||
| ) |
Look up item and return the set-owned pointer.
Useful when item is a search key that's equal to but not pointer-identical with the stored item.
| ht | The set. |
| item | The search key. |
| out | Out: stored item, or NULL. |
Add item to the set.
TRUE on success (FALSE only when ht is NULL). If an equal item is already present it is replaced and its destroy notifier runs. | RHashSet * r_hash_set_new_full | ( | RHashFunc | hash, |
| REqualFunc | equal, | ||
| RDestroyNotify | notify | ||
| ) |
Construct a hash set with custom hash / equality and an optional destroy notifier.
| hash | Hash function applied to each item. |
| equal | Equality comparator paired with hash. |
| notify | Destroy notifier for items, or NULL. |