comparison testtern.c @ 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 140af5509ce7
comparison
equal deleted inserted replaced
428:006008a3f370 429:f6fdde540791
1 #include "tern.h"
2 #include <stdio.h>
3 #include <stddef.h>
4
5 int main(int argc, char ** argv)
6 {
7 tern_node * tree = tern_insert_ptr(NULL, "foo", "bar");
8 tree = tern_insert_ptr(tree, "foobar", "baz");
9 tree = tern_insert_ptr(tree, "goobar", "qux");
10 tree = tern_insert_int(tree, "foobarbaz", 42);
11 tree = tern_insert_int(tree, "goobarbaz", 21);
12 printf("foo: %s\n", (char *)tern_find_ptr(tree, "foo"));
13 printf("foobar: %s\n", (char *)tern_find_ptr(tree, "foobar"));
14 printf("goobar: %s\n", (char *)tern_find_ptr(tree, "goobar"));
15 printf("foob: %s\n", (char *)tern_find_ptr(tree, "foob"));
16 printf("foobarbaz: %d\n", (int)tern_find_int(tree, "foobarbaz", 0));
17 printf("goobarbaz: %d\n", (int)tern_find_int(tree, "goobarbaz", 0));
18 printf("foobarb: %d\n", (int)tern_find_int(tree, "foobarb", 0));
19 return 0;
20 }
21