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

Method setChild

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

Source from the content-addressed store, hash-verified

89}
90
91void Node::setChild(NodeID nid, int alt)
92{
93
94 auto kids = childrenCount();
95
96 if (kids <= 0)
97 {
98 throw no_child();
99 }
100 else if (kids <= 2)
101 {
102 if (alt == 0)
103 {
104 m_childrenOrFirstChild =
105 reinterpret_cast<void *>(static_cast<int>(nid) << 2);
106 setNumberOfChildren(kids);
107 }
108 else
109 {
110 if (alt != 1)
111 {
112 throw std::exception();
113 }
114 m_noOfChildren = -static_cast<int>(nid);
115 }
116 }
117 else
118 {
119 getPtr()[alt] = nid;
120 }
121
122 auto kids2 = childrenCount();
123
124 if (kids != kids2)
125 throw;
126}
127
128NodeID Node::getChild(int alt) const
129{

Callers 2

createChildMethod · 0.80
db_createChildMethod · 0.80

Calls 1

no_childClass · 0.85

Tested by

no test coverage detected