-
Notifications
You must be signed in to change notification settings - Fork 1
/
btree.h
83 lines (54 loc) · 1.41 KB
/
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
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
75
76
77
78
79
80
81
82
83
/*---------------------------------------------*/
/*--Igor Guilherme Pereira Lorendo - 11275071--*/
/*-------Nata Silva Botelho - 11275105---------*/
/*---------------------------------------------*/
#ifndef _btree_c
#define _btree_c
#define SIZE 16
#define ORDER 171
#define TRUE 1
#define FALSE 0
#define PAGESIZE 4096
#define SUCCESS 1
#define THRASHSIZE PAGESIZE - ((ORDER-1)*sizeof(Index) + ORDER*sizeof(long) + 8)
#include <stdbool.h>
/*Structs*/
typedef struct _register{
int numUSP;
char name[SIZE];
char surname[SIZE];
char course[SIZE];
float grade;
}Register;
typedef struct _index{
long RNN; /* 8 */
int prim_key; /* 8 */
}Index;
typedef struct _node{
int is_leaf; /*4*/
int key_count; /* 4*/
long children[ORDER]; /* 8 */
Index keys[ORDER-1]; /* 12 */
char thrash[THRASHSIZE];
}Node;
/*Functions*/
Node *createNode(bool);
Register *createRegister();
Index *writeRegisterOnFile(Register*);
void addRegister();
long getRootRRN();
Node *getRoot();
int _writePageOnFile(Node *, long);
/*void writePageOnFile(Node*, long);*/
void getRegister(long RRN);
Node *readPageFile(FILE*);
int freeSpaceOnPage();
Node *getPageFromFile(FILE*, long);
int addIndexToTree(Index*);
long insertOnNode(Node *, Index *, long);
void splitNode(Node *, int, Node *, long);
Node* splitRoot(Node*);
long _bTreeSearch(FILE*, Node*, int);
void bTreeSearch();
void menu();
#endif