From 5d758f6938dc3c73e2c858255748f781aac17010 Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Tue, 9 Jul 2013 20:51:42 -0700 Subject: Added ternary tree implementation and a simple test program for it --- tern.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tern.h (limited to 'tern.h') diff --git a/tern.h b/tern.h new file mode 100644 index 0000000..0c5935a --- /dev/null +++ b/tern.h @@ -0,0 +1,28 @@ +#ifndef TERN_H_ +#define TERN_H_ + +#include + +typedef union { + void *ptrval; + intptr_t intval; +} tern_val; + +typedef struct tern_node { + struct tern_node *left; + union { + struct tern_node *next; + tern_val value; + } straight; + struct tern_node *right; + char el; +} tern_node; + +tern_node * tern_insert(tern_node * head, char * key, tern_val value); +int tern_find(tern_node * head, char * key, tern_val *ret); +intptr_t tern_find_int(tern_node * head, char * key, intptr_t def); +tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value); +void * tern_find_ptr(tern_node * head, char * key); +tern_node * tern_insert_ptr(tern_node * head, char * key, void * value); + +#endif //TERN_H_ -- cgit v1.2.3 From 122bf9de037f578cc4862b1dc775b6589d56057d Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Wed, 10 Jul 2013 22:48:17 -0700 Subject: Read key bindings from config file --- tern.h | 1 + 1 file changed, 1 insertion(+) (limited to 'tern.h') diff --git a/tern.h b/tern.h index 0c5935a..c731bf6 100644 --- a/tern.h +++ b/tern.h @@ -20,6 +20,7 @@ typedef struct tern_node { tern_node * tern_insert(tern_node * head, char * key, tern_val value); int tern_find(tern_node * head, char * key, tern_val *ret); +tern_node * tern_find_prefix(tern_node * head, char * key); intptr_t tern_find_int(tern_node * head, char * key, intptr_t def); tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value); void * tern_find_ptr(tern_node * head, char * key); -- cgit v1.2.3 From 2c302a78d201d9b594774cec505d14c22e03662c Mon Sep 17 00:00:00 2001 From: Mike Pavone Date: Tue, 10 Sep 2013 23:31:08 -0700 Subject: Added copyright notice to source files and added GPL license text in COPYING --- tern.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tern.h') diff --git a/tern.h b/tern.h index c731bf6..e727599 100644 --- a/tern.h +++ b/tern.h @@ -1,3 +1,8 @@ +/* + Copyright 2013 Michael Pavone + This file is part of BlastEm. + BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. +*/ #ifndef TERN_H_ #define TERN_H_ -- cgit v1.2.3