diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2020-03-16 03:22:23 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2020-03-16 03:22:23 +0100 |
commit | 47334cfaa2315828e6f7b959a1bde180c9c29604 (patch) | |
tree | acf365c3c947664faa97b40e892c63eadb332b35 /src/tree.h | |
parent | 9dc2a544f88ddedea24d16f05170cb90858c3e9a (diff) | |
download | dns-47334cfaa2315828e6f7b959a1bde180c9c29604.tar.gz |
moved tree_* functions to tree.h/.c
Diffstat (limited to 'src/tree.h')
-rw-r--r-- | src/tree.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tree.h b/src/tree.h new file mode 100644 index 0000000..958b5ed --- /dev/null +++ b/src/tree.h @@ -0,0 +1,35 @@ +/* + * tree.h + * (c) 2019 Jonas Gunz + * License: MIT + * */ + +#pragma once + +#include <stdlib.h> +#include <stdint.h> + +struct tree_node { + char* key; + void* data; + struct tree_node* above; + struct tree_node* below; +}; + +int tree_insert ( struct tree_node** _root, char* _key, void* _data ); + +int tree_balance( struct tree_node** _root ); + +void* tree_get ( struct tree_node** _root, char* _query ); + +int tree_destroy( struct tree_node** _root ); + +/** + * ignore-case alphabetical string compare + * returns: + * 0 :: _1 == _2 + * -1 :: _1 < _2 + * +1 :: _1 > _2 + * */ +int string_compare ( char* _1, char* _2 ); + |