2015-06-30 18:48:09 +00:00
|
|
|
#ifndef CRITBIT_H_2809050e_f3c9_4363_8208_673da32e70f9
|
|
|
|
#define CRITBIT_H_2809050e_f3c9_4363_8208_673da32e70f9
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int tt_dict_size(tt_arena_t *a, tt_node_ptr_t t);
|
|
|
|
|
|
|
|
/* Returns TT_NO_PTR when key not present. Does not manipulate references. */
|
2015-06-30 20:10:10 +00:00
|
|
|
extern tt_node_ptr_t tt_dict_get(tt_arena_t *a, tt_node_ptr_t t, tt_atom_t key);
|
2015-06-30 18:48:09 +00:00
|
|
|
|
2015-07-01 18:27:16 +00:00
|
|
|
/* Returns TT_NO_PTR when allocation failed. Otherwise, a length-one dict.
|
|
|
|
Grabs `trie` if required. */
|
|
|
|
extern tt_node_ptr_t tt_dict_singleton(tt_arena_t *a,
|
|
|
|
tt_atom_t key,
|
|
|
|
tt_node_ptr_t trie);
|
|
|
|
|
2015-06-30 18:48:09 +00:00
|
|
|
/* Returns TT_NO_PTR when allocation failed. Otherwise, yields a dict.
|
|
|
|
Grabs `trie` if required. */
|
|
|
|
extern tt_node_ptr_t tt_dict_set(tt_arena_t *a,
|
|
|
|
tt_node_ptr_t t,
|
|
|
|
tt_atom_t key,
|
|
|
|
tt_node_ptr_t trie);
|
|
|
|
|
2015-06-30 20:10:10 +00:00
|
|
|
extern tt_node_ptr_t tt_dict_remove(tt_arena_t *a,
|
|
|
|
tt_node_ptr_t t,
|
|
|
|
tt_atom_t key);
|
|
|
|
|
2015-07-12 21:46:08 +00:00
|
|
|
/* Returns 1 if it examined the whole dict; 0 if it was aborted early */
|
|
|
|
extern int tt_dict_foreach(tt_arena_t *a,
|
|
|
|
tt_node_ptr_t t,
|
|
|
|
void *context,
|
|
|
|
/* Return 1 to continue the loop; 0 to abort it. */
|
|
|
|
int (*f)(void *, tt_atom_t key, tt_node_ptr_t trie));
|
|
|
|
|
|
|
|
/* Dictsets map to TT_EMPTY to indicate a *present* key (and
|
|
|
|
implicitly to TT_NO_PTR to indicate an *absent* key). */
|
|
|
|
/* THESE ALL RETURN grab'd RESULTS */
|
|
|
|
extern tt_node_ptr_t tt_dictset_union(tt_arena_t *a, tt_node_ptr_t s1, tt_node_ptr_t s2);
|
|
|
|
extern tt_node_ptr_t tt_dictset_intersection(tt_arena_t *a, tt_node_ptr_t s1, tt_node_ptr_t s2);
|
|
|
|
extern tt_node_ptr_t tt_dictset_difference(tt_arena_t *a, tt_node_ptr_t s1, tt_node_ptr_t s2);
|
2015-06-30 18:48:09 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|