MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / post_order

Function post_order

cp-profiler/src/cpprofiler/utils/tree_utils.cpp:162–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162std::vector<NodeID> post_order(const NodeTree &tree)
163{
164 std::stack<NodeID> stk_1;
165 std::vector<NodeID> result;
166
167 result.reserve(tree.nodeCount());
168
169 auto root = tree.getRoot();
170
171 stk_1.push(root);
172
173 while (!stk_1.empty())
174 {
175 auto nid = stk_1.top();
176 stk_1.pop();
177
178 result.push_back(nid);
179
180 for (auto i = 0; i < tree.childrenCount(nid); ++i)
181 {
182 auto child = tree.getChild(nid, i);
183 stk_1.push(child);
184 }
185 }
186
187 std::reverse(result.begin(), result.end());
188
189 return result;
190}
191
192std::vector<int> calc_subtree_sizes(const tree::NodeTree &nt)
193{

Callers 1

computeLayoutFunction · 0.85

Calls 7

topMethod · 0.80
nodeCountMethod · 0.45
getRootMethod · 0.45
childrenCountMethod · 0.45
getChildMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected