2014-04-24 06:34:32 +04:00
|
|
|
/* include/f/nash.h
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
|
2014-05-07 22:34:36 +04:00
|
|
|
/** Hash-table design:
|
|
|
|
***
|
|
|
|
*** u2_nash is a non-noun hash-table, meant for ephemeral usage such as
|
|
|
|
*** in jam and cue.
|
|
|
|
***
|
|
|
|
*** It uses a Patricia trie keyed on the mug of the actual key, and then
|
|
|
|
*** a vector of key-value pairs to resolve collisions.
|
|
|
|
**/
|
|
|
|
|
|
|
|
/* Opaque structure holding hash table.
|
|
|
|
*/
|
|
|
|
struct u2_nash;
|
|
|
|
|
|
|
|
/* Functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* u2_na_make(): create a new nash.
|
|
|
|
*/
|
|
|
|
struct u2_nash*
|
|
|
|
u2_na_make();
|
|
|
|
|
|
|
|
/* u2_na_put(): put an entry in the hash table.
|
|
|
|
*/
|
|
|
|
void
|
2014-05-12 21:44:15 +04:00
|
|
|
u2_na_put(struct u2_nash* nash, u2_noun key, void* val);
|
2014-05-07 22:34:36 +04:00
|
|
|
|
|
|
|
/* u2_na_get(): retrieve an entry from the hash table, or u2_none.
|
|
|
|
*/
|
|
|
|
u2_weak
|
|
|
|
u2_na_get(struct u2_nash* nash, u2_noun key);
|
|
|
|
|
2014-05-12 21:44:15 +04:00
|
|
|
/* u2_na_get_ptr(): retrieve a pointer entry from the hash table, or u2_none.
|
|
|
|
*/
|
|
|
|
void*
|
|
|
|
u2_na_get_ptr(struct u2_nash* nash, u2_noun key, c3_b* fon);
|
|
|
|
|
2014-05-07 22:34:36 +04:00
|
|
|
/* u2_na_take(): destroy a nash.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
u2_na_take(struct u2_nash* nash);
|
2014-04-24 06:34:32 +04:00
|
|
|
|