bool removeFromSet(ScMemoryContext & ctx, ScAddr const & setAddr, ScAddr const & elAddr) { ScIterator3Ptr it = ctx.iterator3(setAddr, sc_type_arc_pos_const_perm, elAddr); bool result = false; while (it->next()) ctx.eraseElement(it->value(1)); return result; }
bool ScStruct::remove(ScAddr const & elAddr) { check_expr(mContext); bool found = false; ScIterator3Ptr iter = mContext->iterator3(mAddr, SC_TYPE(sc_type_arc_pos_const_perm), elAddr); while (iter->next()) { mContext->eraseElement(iter->value(1)); found = true; } return found; }
void iteration(size_t orderIndex, ScTemplateSearchResult & result) { size_t const constrIndex = mTemplate.mSearchCachedOrder[orderIndex]; check_expr(constrIndex < mTemplate.mConstructions.size()); size_t const finishIdx = mTemplate.mConstructions.size() - 1; size_t resultIdx = constrIndex * 3; /// TODO: prevent recursive search and make test for that case ScTemplateConstr3 const & constr = mTemplate.mConstructions[constrIndex]; ScTemplateItemValue const * values = constr.getValues(); ScIterator3Ptr const it3 = createIterator(constr); while (it3->next()) { /// check if search in structure if (mScStruct.isValid()) { if (!checkInStruct(it3->value(0)) || !checkInStruct(it3->value(1)) || !checkInStruct(it3->value(2))) { continue; } } // do not make cycle for optimization issues (remove comparsion expresion) mResultAddrs[resultIdx] = it3->value(0); mResultAddrs[resultIdx + 1] = it3->value(1); mResultAddrs[resultIdx + 2] = it3->value(2); refReplacement(values[0], it3->value(0)); refReplacement(values[1], it3->value(1)); refReplacement(values[2], it3->value(2)); if (orderIndex == finishIdx) { result.mResults.push_back(mResultAddrs); } else { iteration(orderIndex + 1, result); } unrefReplacement(values[0]); unrefReplacement(values[1]); unrefReplacement(values[2]); } }