blob: 0acdb15e4099e5e95b3b6b85658ed5c1304c2fcf (
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
36
37
38
39
40
41
42
43
|
#include <sys/types.h>
#include <stdbool.h>
#include <unistd.h>
/* Hardcoded BTree order */
#define BT_ORDER 3
/* Btree is an index of this structure */
struct Data {
int id;
char name[20];
};
struct BTree_node {
bool is_leaf; /* Is this a leaf block? */
int num_recs;
int key_idx[BT_ORDER];
/* Points to next level when node or to data when leaf */
void *ptrs[BT_ORDER];
};
struct BTree_head {
struct BTree_node *root; /* root pointer */
unsigned int height; /* How many levels? */
unsigned int order; /* BTree order */
unsigned int num_recs; /* num of entrys in the tree */
};
struct BTree_head * init_head(void);
void destroy_head(struct BTree_head *head);
/*
* BTree Operations:
*
* All operations Return 0 for success, non zero otherwise
*
*/
int btree_add(struct Data* item);
int btree_delete(void);
int btree_search(void);
int btree_dump(void);
void usage(void);
|