void CodeAtlas::FuzzyDependBuilder::buildChildDepend( QMultiHash<QString, ChildPack>& childList , Eigen::SparseMatrix<double>& vtxEdgeMat, Eigen::VectorXd& edgeWeightVec, QList<FuzzyDependAttr::DependPair>& dependPair) { QStringList codeList; QVector<ChildPack*> childPackPtr; for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin(); pChild != childList.end(); ++pChild) { codeList.push_back(pChild.value().m_code); childPackPtr.push_back(&pChild.value()); } std::vector<Triplet> tripletArray; QVector<double> edgeWeightArray; // add dependency edges between child nodes int ithSrc = 0; for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin(); pChild != childList.end(); ++pChild, ++ithSrc) { // for each child, find number of occurrences of this child's name ChildPack& srcChild = pChild.value(); const QString& srcName = pChild.key(); QVector<int> occurence; WordExtractor::findOccurrence(srcName, codeList, occurence); for (int ithTar = 0; ithTar < childPackPtr.size(); ++ithTar) { int nOccur = occurence[ithTar]; if (nOccur == 0 || ithTar == ithSrc) continue; ChildPack& tarChild = *childPackPtr[ithTar]; SymbolEdge::Ptr pEdge = SymbolTree::getOrAddEdge(srcChild.m_pNode, tarChild.m_pNode, SymbolEdge::EDGE_FUZZY_DEPEND); pEdge->clear(); pEdge->strength() = nOccur; int nEdge = tripletArray.size()/2; tripletArray.push_back(Triplet(srcChild.m_index, nEdge ,1.0)); tripletArray.push_back(Triplet(tarChild.m_index, nEdge ,-1.0)); edgeWeightArray.push_back(nOccur); dependPair.push_back(FuzzyDependAttr::DependPair(srcChild.m_pNode, tarChild.m_pNode, nOccur)); } } if (int nEdges = tripletArray.size()/2) { vtxEdgeMat.resize(childList.size(),nEdges); vtxEdgeMat.setFromTriplets(tripletArray.begin(), tripletArray.end()); edgeWeightVec.resize(nEdges); memcpy(edgeWeightVec.data(), edgeWeightArray.data(), sizeof(double)* nEdges); } }
void CDspVmAutoTaskManagerBase::Init() { WRITE_TRACE( DBG_DEBUG, "Initializing %s manager", getManagerName() ); QMultiHash<QString , SmartPtr<CVmConfiguration> > hashAllVms = CDspService::instance()->getVmDirHelper().getAllVmList(); QMultiHash<QString , SmartPtr<CVmConfiguration> >::iterator it; for(it = hashAllVms.begin(); it != hashAllVms.end(); ++it) { SmartPtr<CVmConfiguration> pVmConfig = it.value(); PRL_ASSERT(pVmConfig); if (isEnabled(pVmConfig, true)) { PRL_RESULT res = tryToRegisterVm(pVmConfig, it.key()); if (PRL_FAILED(res)) WRITE_TRACE(DBG_FATAL, "Can't register VM %s in Auto-task Manager during starting dispetcher." "Error: 0x%x, (%s).", QSTR2UTF8(pVmConfig->getVmIdentification()->getVmUuid()), res, PRL_RESULT_TO_STRING(res) ); } } m_bInitialized = true; }
int main() { QSet<QString *> s; qDeleteAll(s); qDeleteAll(s.begin(), s.end()); qDeleteAll(s.values()); // warning QHash<int, QString *> h; qDeleteAll(h); qDeleteAll(h.begin(), h.end()); qDeleteAll(h.values()); // warning QMap<int*, QString *> m; qDeleteAll(m); qDeleteAll(m.begin(), m.end()); qDeleteAll(m.values()); // warning QMultiHash<int, QString *> mh; qDeleteAll(mh); qDeleteAll(mh.begin(), mh.end()); qDeleteAll(mh.values()); // warning QMultiMap<int, QString *> mm; qDeleteAll(mm); qDeleteAll(mm.begin(), mm.end()); qDeleteAll(mm.values()); // warning qDeleteAll(values()); // ok Foo foo; qDeleteAll(foo.values()); // ok qDeleteAll(foo.doSomethingWithValues(h.values())); // ok qDeleteAll(m.keys()); // warning qDeleteAll(keys()); // ok qDeleteAll(h.values(1)); // warning }