Repository navigation
Expand file tree
/
Copy pathSQTree.h
More file actions
74 lines (65 loc) · 2.47 KB
/
Copy pathSQTree.h
File metadata and controls
74 lines (65 loc) · 2.47 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef SQTREE_H /* just little different to bs tree */
#define SQTREE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ioctl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "SString.h"
#include "inline.h"
#include "debug.h"
#include "null.h"
typedef struct _qNode SQNode;
typedef struct _qNode SQTree; /* Root node */
typedef struct _qIterator SQIterator;
/* creates new tree */
SQTree* sqtr_create();
/* check if one key is equal to another*/
//STATIC_I int sqtr_keyeqval(char*key1, char*key2);
/* check if tree is empty */
int sqtr_empty(SQTree*tree);
/* recursively clone Tree */
SQTree* sqtr_clone(SQTree* tree);
void _sqtr_clonen(SQNode* node1, SQNode* node2);
/* sets value of <key> to <value> */
/* no copy */
/* creates new node if there is no node with <key> */
void sqtr_setNoCopy(SQTree* tree, char* key, char* value);
/* sets value of <key> to <value> */
/* copies values of <key> and <value> into an new buffer */
/* creates new node if there is no node with <key> */
void sqtr_set(SQTree* tree, char* key, char* value);
/* returns element that belongs to <key> */
void* sqtr_get(SQTree* tree, char* key);
#define sqtr_contains(tree, key) sqtr_get(tree, key) == null;
/* completely deletes node out of tree, also cleans up tree structure, very slow, since every subnode has to be reinserted */
void sqtr_delete(SQTree* tree, char* key);
/* marks node with <key> as free returns value of node that belongs to <key> */
void*sqtr_pop(SQTree* tree, char* key);
/* pop leftmost element of tree */
SQNode*sqtr_popl(SQTree* tree);
/* completely deletes whole tree */
void sqtr_free(SQTree *tree);
/* used to insert node at specific point */
//STATIC_I void _sqtr_insertn(SQNode* start, unsigned int startb, SQNode* insert);
/* prints entire tree */
debug void sqtr_print(SQTree*tree);
/* prints node at row|col*/
debug void sqtr_printn(SQTree*tree, SQNode*node, int col, int row);
/* print tree in "binary" format */
debug void sqtr_printbin(SQTree*tree);
debug void sqtr_printnbin(SQTree*tree, SQNode*node, int col, int row, char val);
struct _qNode
{
char* key;
char* value;
struct _qNode* ln; /* left node */
struct _qNode* rn; /* right node */
};
#ifdef __cplusplus
}
#endif
#endif