void calc(Node *t) { if ((t->left->left == NULL) && (t->right->left == NULL)) { if (t->operation == '+') { t->value = t->left->value + t->right->value; delChild(t); } else if (t->operation == '-') { t->value = t->left->value - t->right->value; delChild(t); } else if (t->operation == '*') { t->value = t->left->value * t->right->value; delChild(t); } else if (t->operation == '/') { t->value = t->left->value / t->right->value; delChild(t); } } else { if (t->left->left != NULL) calc(t->left); if (t->right->left != NULL) calc(t->right); calc(t); } }
bool StoreClient::remove(class_id_t class_id, const URI& uri, bool recursive, notif_t* notifs) { Region* r = checkOwner(store, readOnly, region, class_id); // Remove the object itself bool result = r->remove(class_id, uri); if (!result) return result; // remove the parent link try { const std::pair<URI, prop_id_t>& parent = r->getParent(class_id, uri); std::vector<std::pair<URI, prop_id_t> > parents; std::vector<std::pair<URI, prop_id_t> >::iterator pit; class_id_t parent_class = store->prop_map.at(parent.second)->getId(); delChild(parent_class, parent.first, parent.second, class_id, uri); } catch (std::out_of_range e) { // no parent link found } if (!recursive) return result; // Remove all the children if requested removeChildren(class_id, uri, notifs); return result; }
bool StoreClient::remove(class_id_t class_id, const URI& uri, bool recursive, notif_t* notifs) { Region* r = checkOwner(store, readOnly, region, class_id); // Remove the object itself bool result = r->remove(class_id, uri); if (!result) return result; // remove the parent link try { std::pair<URI, prop_id_t> parent(URI::ROOT, 0); if (r->getParent(class_id, uri, parent)) { class_id_t parent_class = store->prop_map.at(parent.second)->getId(); delChild(parent_class, parent.first, parent.second, class_id, uri); } } catch (const std::out_of_range&) { // parent prop info not found } if (!recursive) return result; // Remove all the children if requested removeChildren(class_id, uri, notifs); return result; }
bool ClassIndex::addChild(const URI& parent, prop_id_t parent_prop, const URI& child) { uri_prop_map_t::iterator result = parent_map.find(child); if (result != parent_map.end()) { if (result->second.first == parent && result->second.second == parent_prop && result->first == child) { return false; } else { delChild(result->second.first, result->second.second, child); } } child_map[parent][parent_prop].insert(child); parent_map.insert(std::make_pair(child, std::make_pair(parent,parent_prop))); return true; }
void CMiniMapWnd::onDelUnit (CUnitObject* pu) { #ifdef _GAMEENGINE_3D_ V_MINI_ICON::iterator pi = vMiniIcon.begin () ; while (pi != vMiniIcon.end ()) { if (pi->pUnit == pu) { delChild (&(*pi)) ; vMiniIcon.erase (pi) ; break ; } ++ pi ; } #endif }
void StoreClient::removeChildren(class_id_t class_id, const URI& uri, notif_t* notifs) { const ClassInfo& ci = store->getClassInfo(class_id); const ClassInfo::property_map_t& pmap = ci.getProperties(); ClassInfo::property_map_t::const_iterator it; for (it = pmap.begin(); it != pmap.end(); ++it) { if (it->second.getType() == PropertyInfo::COMPOSITE) { class_id_t prop_class = it->second.getClassId(); prop_id_t prop_id = it->second.getId(); std::vector<URI> children; getChildren(class_id, uri, prop_id, prop_class, children); std::vector<URI>::iterator cit; for (cit = children.begin(); cit != children.end(); ++cit) { // unlink the parent/child delChild(class_id, uri, prop_id, prop_class, *cit); // remove the child object remove(prop_class, *cit, true); if (notifs) (*notifs)[*cit] = prop_class; } } } }