Mercurial > repos > blastem
comparison tern.h @ 803:236a184bf6f0
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 26 Jul 2015 16:51:03 -0700 |
parents | 2f48a3c187c6 |
children | 110251ea369e |
comparison
equal
deleted
inserted
replaced
802:6811f601008f | 803:236a184bf6f0 |
---|---|
5 */ | 5 */ |
6 #ifndef TERN_H_ | 6 #ifndef TERN_H_ |
7 #define TERN_H_ | 7 #define TERN_H_ |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | |
11 #define MAX_INT_KEY_SIZE (sizeof(uint32_t) + 2) | |
10 | 12 |
11 typedef union { | 13 typedef union { |
12 void *ptrval; | 14 void *ptrval; |
13 intptr_t intval; | 15 intptr_t intval; |
14 } tern_val; | 16 } tern_val; |
21 } straight; | 23 } straight; |
22 struct tern_node *right; | 24 struct tern_node *right; |
23 char el; | 25 char el; |
24 } tern_node; | 26 } tern_node; |
25 | 27 |
28 typedef void (*iter_fun)(char *key, tern_val val, void *data); | |
29 | |
26 tern_node * tern_insert(tern_node * head, char * key, tern_val value); | 30 tern_node * tern_insert(tern_node * head, char * key, tern_val value); |
27 int tern_find(tern_node * head, char * key, tern_val *ret); | 31 int tern_find(tern_node * head, char * key, tern_val *ret); |
28 tern_node * tern_find_prefix(tern_node * head, char * key); | 32 tern_node * tern_find_prefix(tern_node * head, char * key); |
29 intptr_t tern_find_int(tern_node * head, char * key, intptr_t def); | 33 intptr_t tern_find_int(tern_node * head, char * key, intptr_t def); |
30 tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value); | 34 tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value); |
31 void * tern_find_ptr_default(tern_node * head, char * key, void * def); | 35 void * tern_find_ptr_default(tern_node * head, char * key, void * def); |
32 void * tern_find_ptr(tern_node * head, char * key); | 36 void * tern_find_ptr(tern_node * head, char * key); |
37 tern_val tern_find_path_default(tern_node *head, char *key, tern_val def); | |
38 tern_val tern_find_path(tern_node *head, char *key); | |
33 tern_node * tern_insert_ptr(tern_node * head, char * key, void * value); | 39 tern_node * tern_insert_ptr(tern_node * head, char * key, void * value); |
40 tern_node * tern_insert_node(tern_node *head, char *key, tern_node *value); | |
41 uint32_t tern_count(tern_node *head); | |
42 void tern_foreach(tern_node *head, iter_fun fun, void *data); | |
43 char * tern_int_key(uint32_t key, char * buf); | |
44 tern_node * tern_get_node(tern_val value); | |
34 | 45 |
35 #endif //TERN_H_ | 46 #endif //TERN_H_ |