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

Method setNumberOfChildren

cp-profiler/src/cpprofiler/tree/node.cpp:55–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55void Node::setNumberOfChildren(int n)
56{
57
58 const auto old_n = childrenCount();
59
60 /// Nothing to do
61 if (old_n == n)
62 return;
63
64 /// This method works for "open" nodes only
65 if (old_n != 0)
66 throw std::exception();
67
68 if (n == 1)
69 {
70 setTag(Tag::ONE_CHILD);
71 }
72 else if (n == 2)
73 {
74 setTag(Tag::TWO_CHILDREN);
75 }
76 else if (n > 2)
77 {
78 m_noOfChildren = n;
79 setPtr(static_cast<NodeID *>(malloc(sizeof(NodeID) * n)));
80 setTag(Tag::MORE_CHILDREN);
81 }
82}
83
84Node::Node(NodeID parent_nid, int kids) : m_parent(parent_nid)
85{

Callers 1

addChildrenMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected