aboutsummaryrefslogtreecommitdiff
path: root/src/tree.h
blob: 958b5edd298cd93482e1c2ada505c41e490e24d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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 );