| 228 | } |
| 229 | |
| 230 | void |
| 231 | SpaceNode::closeChild(const NodeAllocator& na, |
| 232 | bool hadFailures, bool hadSolutions) { |
| 233 | setHasFailedChildren(hasFailedChildren() || hadFailures); |
| 234 | setHasSolvedChildren(hasSolvedChildren() || hadSolutions); |
| 235 | |
| 236 | bool allClosed = true; |
| 237 | for (int i=getNumberOfChildren(); i--;) { |
| 238 | if (getChild(na,i)->isOpen()) { |
| 239 | allClosed = false; |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | if (allClosed) { |
| 245 | setHasOpenChildren(false); |
| 246 | for (unsigned int i=0; i<getNumberOfChildren(); i++) |
| 247 | setHasSolvedChildren(hasSolvedChildren() || |
| 248 | getChild(na,i)->hasSolvedChildren()); |
| 249 | SpaceNode* p = getParent(na); |
| 250 | if (p != nullptr) { |
| 251 | delete static_cast<Space*>(Support::funmark(copy)); |
| 252 | copy = nullptr; |
| 253 | p->closeChild(na, hasFailedChildren(), hasSolvedChildren()); |
| 254 | } |
| 255 | } else { |
| 256 | |
| 257 | if (hadSolutions) { |
| 258 | setHasSolvedChildren(true); |
| 259 | SpaceNode* p = getParent(na); |
| 260 | while (p != nullptr && !p->hasSolvedChildren()) { |
| 261 | p->setHasSolvedChildren(true); |
| 262 | p = p->getParent(na); |
| 263 | } |
| 264 | } |
| 265 | if (hadFailures) { |
| 266 | SpaceNode* p = getParent(na); |
| 267 | while (p != nullptr && !p->hasFailedChildren()) { |
| 268 | p->setHasFailedChildren(true); |
| 269 | p = p->getParent(na); |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | } |
| 275 | |
| 276 | SpaceNode::SpaceNode(Space* root) |
| 277 | : Node(-1, root==nullptr), |
no test coverage detected