rlib
Convenience library for useful things
Loading...
Searching...
No Matches
rhashset.h File Reference

Refcounted hash-set container. More...

#include <rlib/rtypes.h>
#include <rlib/rref.h>
#include <rlib/data/rhashfuncs.h>

Go to the source code of this file.

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

RHashSetr_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.
 

Detailed Description

Refcounted hash-set container.