18#ifndef __R_DICTIONARY_H__
19#define __R_DICTIONARY_H__
21#if !defined(__RLIB_H_INCLUDE_GUARD__) && !defined(RLIB_COMPILATION)
22#error "#include <rlib.h> only please."
53#define RDictionary RHashTable
60#define r_dictionary_ref r_ref_ref
62#define r_dictionary_unref r_ref_unref
static RDictionary * r_dictionary_new(void)
Construct an empty string-keyed dictionary (no value notifier).
Definition rdictionary.h:90
static rboolean r_dictionary_contains(RDictionary *dict, const rchar *key)
TRUE iff key is present.
Definition rdictionary.h:125
static rboolean r_dictionary_remove(RDictionary *dict, const rchar *key)
Remove key (value destroy notifier runs).
Definition rdictionary.h:135
static rboolean r_dictionary_lookup_full(RDictionary *dict, const rchar *key, rpointer *value)
Look up key, returning the value via value.
Definition rdictionary.h:120
static rsize r_dictionary_size(RDictionary *dict)
Number of entries currently in the dictionary.
Definition rdictionary.h:100
static RDictionary * r_dictionary_new_full(RDestroyNotify notify)
Construct an empty dictionary with a value destroy notifier.
Definition rdictionary.h:95
static rboolean r_dictionary_steal(RDictionary *dict, const rchar *key, rpointer *value)
Remove key without running the value destroy notifier; return the value via value.
Definition rdictionary.h:130
static rpointer r_dictionary_lookup(RDictionary *dict, const rchar *key)
Return the value associated with key, or NULL.
Definition rdictionary.h:115
static rboolean r_dictionary_insert(RDictionary *dict, const rchar *key, rpointer value)
Insert (key, value).
Definition rdictionary.h:110
#define RDictionary
Alias: RDictionary is just an RHashTable.
Definition rdictionary.h:53
static rboolean r_dictionary_foreach(RDictionary *dict, RStrKeyValueFunc func, rpointer user)
Iterate every entry in the dictionary.
Definition rdictionary.h:140
static rsize r_dictionary_current_alloc_size(RDictionary *dict)
Allocated bucket count.
Definition rdictionary.h:105
rsize r_str_hash(rconstpointer data)
Hash a NUL-terminated C string.
rboolean r_str_equal(rconstpointer a, rconstpointer b)
Equality for NUL-terminated C strings (via strcmp).
RHashTable * r_hash_table_new_full(RHashFunc hash, REqualFunc equal, RDestroyNotify keynotify, RDestroyNotify valuenotify)
Construct a hash table with custom hash / equality and optional per-side destroy notifiers.
RHashTableError r_hash_table_remove(RHashTable *ht, rconstpointer key)
Remove the entry for key; destroy notifiers run.
RHashTableError r_hash_table_steal(RHashTable *ht, rconstpointer key, rpointer *keyout, rpointer *valueout)
Remove the entry for key without running its destroy notifiers, handing ownership of the key / value ...
RHashTableError r_hash_table_foreach(RHashTable *ht, RKeyValueFunc func, rpointer user)
Iterate every (key, value) pair in the table.
rsize r_hash_table_current_alloc_size(RHashTable *ht)
Allocated bucket count; useful for sizing diagnostics.
RHashTableError r_hash_table_insert(RHashTable *ht, rpointer key, rpointer value)
Insert or replace (key, value).
RHashTableError r_hash_table_lookup_full(RHashTable *ht, rconstpointer key, rpointer *keyout, rpointer *valueout)
Look up key, returning both the stored key and value.
rsize r_hash_table_size(RHashTable *ht)
Number of entries currently in the table.
rpointer r_hash_table_lookup(RHashTable *ht, rconstpointer key)
Return the value associated with key, or NULL.
RHashTableError r_hash_table_contains(RHashTable *ht, rconstpointer key)
R_HASH_TABLE_OK iff key is present, R_HASH_TABLE_NOT_FOUND otherwise.
@ R_HASH_TABLE_OK
Definition rhashtable.h:71
#define NULL
Null pointer constant (defined only if absent).
Definition rmacros.h:126
#define R_BEGIN_DECLS
Open an extern "C" block under C++ (no-op in C).
Definition rmacros.h:196
char rchar
Default character type (char).
Definition rtypes.h:137
int rboolean
Boolean type (typedef'd to int).
Definition rtypes.h:59
void(* RDestroyNotify)(rpointer ptr)
Destructor callback: free / release the value at ptr.
Definition rtypes.h:401
void(* RKeyValueFunc)(rpointer key, rpointer value, rpointer user)
Iteration callback over (key, value, user) triples.
Definition rtypes.h:411
void * rpointer
Generic pointer (alias for void *).
Definition rtypes.h:327
unsigned long rsize
Unsigned pointer-sized size type (like size_t).
Definition rtypes.h:290
void(* RStrKeyValueFunc)(const rchar *key, rpointer value, rpointer user)
Iteration callback over (const char *key, value, user).
Definition rtypes.h:415
Refcounted hash-map container.