-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathb_tree.h
More file actions
53 lines (45 loc) · 1.13 KB
/
b_tree.h
File metadata and controls
53 lines (45 loc) · 1.13 KB
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
#ifndef CPP_ALGORITHM_B_TREE_H
#define CPP_ALGORITHM_B_TREE_H
#include <vector>
namespace BTree
{
struct Node
{
std::vector<char> keys;
std::vector<Node*> children;
bool is_leaf;
};
class Tree
{
public:
Node* root;
std::vector<Node*> nodes;
int degree;
/**
* \brief Split the node
* \param node internal node
* \param index index
*/
void SplitChild(Node* node, int index);
/**
* \brief Insert key
* \param node internal node
* \param key key
*/
void InsertNonFull(Node* node, char key);
/**
* \brief Insert the key to the tree
* \param node reference node for insert
* \param key key to insert
*/
void Insert(Node* node, char key);
/**
* \brief Search the key
* \param node reference node for tree search
* \param key key to search for
* \return node and key index pair
*/
auto Search(Node* node, char key) -> std::pair<Node*, const int>;
};
}
#endif