20 std::vector<SNode> _st;
23 using iterator_category = std::bidirectional_iterator_tag;
24 using difference_type = std::ptrdiff_t;
28 this->idx = UINT64_MAX;
33 this->_st.push_back(
SNode(NodePointer::build_leaf_pointer(leaf, -1), 0,
false));
41 BPPostorderIterator::initialize_stack(this->_st, *_root);
46 this->idx = UINT64_MAX;
58 assert(this->_st.size() != 0);
59 SNode top = this->_st[this->_st.size() - 1];
65 return this->idx == UINT64_MAX;
71 SNode top = this->_st[this->_st.size() - 1];
72 std::cout <<
"[" << (uint64_t)top.pointer.get_node() <<
"/" << top.position <<
"]" << std::endl;
78 for (
auto &it : this->_st)
80 item._st.push_back(it.copy());
92 assert(this->_st.size() != 0);
93 SNode top = this->_st[this->_st.size() - 1];
97 static void initialize_stack(std::vector<SNode> &st,
Node &_root)
99 st.push_back(
SNode(NodePointer::build_internal_node_pointer(&_root, -1), 0,
false));
100 while (st.size() > 0)
102 SNode top = st[st.size() - 1];
104 st.push_back(
SNode(top.pointer, top.position,
true));
113 Node *node = np.get_node();
114 if (node->is_parent_of_leaves())
116 NodePointer child = NodePointer::build_leaf_pointer((uint64_t)node->get_child(0), 0);
117 st.push_back(
SNode(child, 0,
false));
121 NodePointer child = NodePointer::build_internal_node_pointer(node->get_child(0), 0);
122 st.push_back(
SNode(child, 0,
false));
127 static bool proceed(std::vector<SNode> &st)
132 while (st.size() > 0)
134 SNode top = st[st.size() - 1];
143 Node *node = np.get_node();
146 if (top.position + 1 == node->children_count())
153 st.push_back(
SNode(np, top.position + 1,
false));
159 st.push_back(
SNode(np, top.position,
true));
160 if (node->is_parent_of_leaves())
162 NodePointer child = NodePointer::build_leaf_pointer((uint64_t)node->get_child(top.position), top.position);
163 st.push_back(
SNode(child, 0,
false));
167 NodePointer child = NodePointer::build_internal_node_pointer(node->get_child(top.position), top.position);
168 st.push_back(
SNode(child, 0,
false));
190 assert(this->_st.size() > 0);
191 bool b = proceed(this->_st);
198 this->idx = UINT64_MAX;