-
Notifications
You must be signed in to change notification settings - Fork 0
/
BPTNode.hpp
83 lines (75 loc) · 2.03 KB
/
BPTNode.hpp
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
//
// BPTnode.hpp
// BPTreeNode_Declaration
#ifndef BPTNode_hpp
#define BPTNode_hpp
#include<stdio.h>
#include<cstddef>
#include<iostream>
using namespace std;
class BPTnode
{
protected:
int order;
int *keys;
int keyNum;
bool isLeaf;
BPTnode *parent;
BPTnode *prev;
BPTnode *next;
public:
BPTnode(int n);
~BPTnode();
bool IsLeaf();
int *GetKeys();
int GetKeyNum();
void decKeyNum();
int GetKeyIndex(int key);
BPTnode *GetParent();
BPTnode *GetNext();
BPTnode *GetPrev();
void SetParent(BPTnode *node);
void SetNext(BPTnode *node);
void SetPrev(BPTnode *node);
//virtual functions for run time polymorphism
virtual void insert(int key, float value) {}
virtual void insert(int key, BPTnode* rtChild) {}
virtual void insert(int key, BPTnode* lftChild, BPTnode* rtChild) {}
virtual void Delete(int key) {}
virtual void merge(BPTnode* rtNode) {}
virtual void search(int key) {}
virtual void search(int key1, int key2) {}
virtual BPTnode *split(int &key) { return NULL; }
virtual BPTnode **getChildren() { return NULL; }
virtual float *getValues() { return NULL; }
};
// internal node
class InNode:public BPTnode
{
private:
BPTnode **children;
public:
InNode(int n);
~InNode();
void insert(int key, BPTnode* rtChild);
void insert(int key, BPTnode* lftChild, BPTnode* rtChild);
void Delete(int key);
void merge(BPTnode* rtNode);
BPTnode *split(int &key);
BPTnode **getChildren();
};
// leaf node
class LNode:public BPTnode
{
private:
float *values;
public:
LNode(int n);
~LNode();
void insert(int key, float value);
void Delete(int key);
void merge(BPTnode* rtNode);
BPTnode *split(int &key);
float *getValues();
};
#endif /* BPTreeNode_hpp */