comparison tern.h @ 429:f6fdde540791

Added ternary tree implementation and a simple test program for it
author Mike Pavone <pavone@retrodev.com>
date Tue, 09 Jul 2013 20:51:42 -0700
parents
children 440efd7d27a9
comparison
equal deleted inserted replaced
428:006008a3f370 429:f6fdde540791
1 #ifndef TERN_H_
2 #define TERN_H_
3
4 #include <stdint.h>
5
6 typedef union {
7 void *ptrval;
8 intptr_t intval;
9 } tern_val;
10
11 typedef struct tern_node {
12 struct tern_node *left;
13 union {
14 struct tern_node *next;
15 tern_val value;
16 } straight;
17 struct tern_node *right;
18 char el;
19 } tern_node;
20
21 tern_node * tern_insert(tern_node * head, char * key, tern_val value);
22 int tern_find(tern_node * head, char * key, tern_val *ret);
23 intptr_t tern_find_int(tern_node * head, char * key, intptr_t def);
24 tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value);
25 void * tern_find_ptr(tern_node * head, char * key);
26 tern_node * tern_insert_ptr(tern_node * head, char * key, void * value);
27
28 #endif //TERN_H_