-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBTree.h
62 lines (54 loc) · 1.23 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
// Andrew Howard, Andre Lipiec
// Project 3, B-Tree
// COSC320, Dr Anderson
#ifndef BTREE_H
#define BTREE_H
#include <iostream>
#include <chrono>
#include <cstdlib>
// Defines the BTree Node Class
class BTreeNode {
private:
int* keys; // Array of keys in the node
int degree; // Range for number of keys
BTreeNode** children; // Array of pointers to children nodes
int numKeys; // Number of keys currently in the node
bool leaf; // Self Explanitory
public:
BTreeNode(int,bool);
~BTreeNode();
void insertNonFull(int);
void splitChild(int,BTreeNode*);
void deleteTree();
void print();
BTreeNode* search(int);
void initKeys();
int* getKeys();
int getKey(int);
int getNumKeys();
void traverse();
int findKey(int);
void remove(int);
void removeFromLeaf(int);
void removeFromNonLeaf(int);
int predeccesor(int);
int successor(int);
void fill(int);
void borrowFromPrev(int);
void borrowFromNext(int);
void merge(int);
friend class BTree;
};
class BTree {
private:
BTreeNode* root;
int degree;
public:
BTree(int);
~BTree();
void print();
BTreeNode* search(int);
void insert(int);
void remove(int);
};
#endif