19 std::vector<SNode> _st;
22 using iterator_category = std::bidirectional_iterator_tag;
23 using difference_type = std::ptrdiff_t;
27 this->idx = UINT64_MAX;
32 this->_st.push_back(
SNode(NodePointer::build_leaf_pointer(leaf, -1), 0,
false));
40 BPPostorderIterator::initialize_stack(this->_st, *_root);
45 this->idx = UINT64_MAX;
57 assert(this->_st.size() != 0);
58 SNode top = this->_st[this->_st.size() - 1];
64 return this->idx == UINT64_MAX;
70 SNode top = this->_st[this->_st.size() - 1];
71 std::cout <<
"[" << (uint64_t)top.pointer.get_node() <<
"/" << top.position <<
"]" << std::endl;
77 for (
auto &it : this->_st)
79 item._st.push_back(it.copy());
91 assert(this->_st.size() != 0);
92 SNode top = this->_st[this->_st.size() - 1];
96 static void initialize_stack(std::vector<SNode> &st,
Node &_root)
98 st.push_back(
SNode(NodePointer::build_internal_node_pointer(&_root, -1), 0,
false));
101 SNode top = st[st.size() - 1];
103 st.push_back(
SNode(top.pointer, top.position,
true));
112 Node *node = np.get_node();
113 if (node->is_parent_of_leaves())
115 NodePointer child = NodePointer::build_leaf_pointer((uint64_t)node->get_child(0), 0);
116 st.push_back(
SNode(child, 0,
false));
120 NodePointer child = NodePointer::build_internal_node_pointer(node->get_child(0), 0);
121 st.push_back(
SNode(child, 0,
false));
126 static bool proceed(std::vector<SNode> &st)
131 while (st.size() > 0)
133 SNode top = st[st.size() - 1];
142 Node *node = np.get_node();
145 if (top.position + 1 == node->children_count())
152 st.push_back(
SNode(np, top.position + 1,
false));
158 st.push_back(
SNode(np, top.position,
true));
159 if (node->is_parent_of_leaves())
161 NodePointer child = NodePointer::build_leaf_pointer((uint64_t)node->get_child(top.position), top.position);
162 st.push_back(
SNode(child, 0,
false));
166 NodePointer child = NodePointer::build_internal_node_pointer(node->get_child(top.position), top.position);
167 st.push_back(
SNode(child, 0,
false));
189 assert(this->_st.size() > 0);
190 bool b = proceed(this->_st);
197 this->idx = UINT64_MAX;