forked from yaosj2k/dnsforwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bst.h
executable file
·44 lines (26 loc) · 992 Bytes
/
bst.h
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
#ifndef BST_H_INCLUDED
#define BST_H_INCLUDED
#include "array.h"
typedef struct _Bst_NodeHead{
int32_t Parent;
int32_t Left;
int32_t Right;
} Bst_NodeHead;
typedef struct _Bst {
Array *Nodes;
int32_t Root;
int32_t FreeList;
int (*Compare)(const void *, const void *);
} Bst;
int Bst_Init(Bst *t, Array *Nodes, int ElementLength, int (*Compare)(const void *, const void *));
int Bst_NodesInit(Array *Nodes, int ElementLength);
int Bst_Add(Bst *t, const void *Data);
#define Bst_IsEmpty(t_ptr) ((t_ptr) -> Root == -1)
int32_t Bst_Search(Bst *t, const void *Data, const void *Start);
void *Bst_Enum(Bst *t, int32_t *Start);
#define Bst_GetDataByNumber(t_ptr, number) (void *)(((Bst_NodeHead *)Array_GetBySubscript((t_ptr) -> Nodes, (number))) + 1)
int32_t Bst_Minimum_ByNumber(Bst *t, int32_t SubTree);
int32_t Bst_Successor_ByNumber(Bst *t, int32_t NodeNumber);
int32_t Bst_Delete_ByNumber(Bst *t, int32_t NodeNumber);
void Bst_Reset(Bst *t);
#endif // BST_H_INCLUDED