-
Notifications
You must be signed in to change notification settings - Fork 0
/
btree.h
36 lines (29 loc) · 881 Bytes
/
btree.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
//
// Created by Freedom Coder on 19.10.2021.
//
#ifndef LAB6_BTREE_H
#define LAB6_BTREE_H
typedef void* TBINode;
struct BTNode
{
TBINode data;
struct BTNode* parent;
struct BTNode* left;
struct BTNode* right;
};
struct BTree {
struct BTNode* root;
int (*comparator)(TBINode a, TBINode b);
};
#define BT_STRATEGY_INFIXED 0
#define BT_STRATEGY_PREFIXED 1
#define BT_STRATEGY_POSTFIXED 2
#define BT_STRATEGY_INVERSE 3
void BT_construct(struct BTree* tree, int (*comparator)(TBINode a, TBINode b));
void BT_insert(struct BTree* tree, TBINode element);
void BT_remove(struct BTree* tree, TBINode element);
int BT_contains(struct BTree* tree, TBINode element);
void BT_consume(struct BTree* tree, void (*consumer)(TBINode element), int bt_strategy);
struct BTNode* BT_next(struct BTNode* curr);
void BT_destruct(struct BTree* tree);
#endif //LAB6_BTREE_H