b-tree-plus-alpha
Loading...
Searching...
No Matches
bp_node_pointer.hpp
1#pragma once
2#include "./bp_internal_node.hpp"
3
4namespace stool
5{
6 namespace bptree
7 {
13 template <typename LEAF_CONTAINER, typename VALUE, uint64_t MAX_DEGREE>
15 {
17 Node *node_;
18 int16_t parent_edge_index_;
19 bool is_leaf_;
20
21 public:
23 {
24 }
25
26 static BPNodePointer build_internal_node_pointer(Node *_node, int16_t _parent_edge_index)
27 {
29 r.node_ = _node;
30 r.parent_edge_index_ = _parent_edge_index;
31 r.is_leaf_ = false;
32 return r;
33 }
34 static BPNodePointer build_leaf_pointer(uint64_t _leaf_container_index, int16_t _parent_edge_index)
35 {
37 r.node_ = (Node *)_leaf_container_index;
38 r.parent_edge_index_ = _parent_edge_index;
39 r.is_leaf_ = true;
40 return r;
41 }
42
43 uint64_t get_parent_edge_index() const
44 {
45 return this->parent_edge_index_;
46 }
47 Node *get_node() const
48 {
49 return this->node_;
50 }
51
52 bool is_leaf() const
53 {
54 return this->is_leaf_;
55 }
56
57 uint64_t get_leaf_container_index() const
58 {
59 return (uint64_t)this->node_;
60 }
61 uint64_t get_degree(const std::vector<LEAF_CONTAINER> &leaf_container_vec) const
62 {
63 if (this->is_leaf())
64 {
65 return leaf_container_vec[this->get_leaf_container_index()].size();
66 }
67 else
68 {
69 return this->get_node()->get_degree();
70 }
71 }
72 };
73 }
74}
The internal node of BPTree.
Definition bp_internal_node.hpp:16
A pointer to a node of BPTree.
Definition bp_node_pointer.hpp:15