| 120 | } |
| 121 | |
| 122 | std::vector<NodeID> pre_order(const NodeTree &tree) |
| 123 | { |
| 124 | std::stack<NodeID> stk; |
| 125 | std::vector<NodeID> result; |
| 126 | |
| 127 | NodeID root = NodeID{0}; |
| 128 | |
| 129 | stk.push(root); |
| 130 | |
| 131 | while (stk.size() > 0) |
| 132 | { |
| 133 | auto nid = stk.top(); |
| 134 | stk.pop(); |
| 135 | result.push_back(nid); |
| 136 | |
| 137 | for (auto i = tree.childrenCount(nid) - 1; i >= 0; --i) |
| 138 | { |
| 139 | auto child = tree.getChild(nid, i); |
| 140 | stk.push(child); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | return result; |
| 145 | } |
| 146 | |
| 147 | std::vector<NodeID> any_order(const NodeTree &tree) |
| 148 | { |
no test coverage detected