void Map<KeyType, DataType>::clear() { BinaryTreeIterator_InOrder<Tuple<KeyType, DataType *> > mapIter(map); for ( ; ! mapIter.done(); mapIter++) { if (mapIter().data != NULL) delete mapIter().data; } map.clear(); return; }
void ArxDbgAppEditorReactor::verifyClonedReferences(AcDbIdMapping& idMap) { ArxDbgDbEntity* ent; AcDbObject* obj; Acad::ErrorStatus es; int numErrorsFixed; AcDbIdPair idPair; AcDbIdMappingIter mapIter(idMap); for (mapIter.start(); !mapIter.done(); mapIter.next()) { if (mapIter.getMap(idPair)) { es = acdbOpenObject(obj, idPair.value(), AcDb::kForWrite); if (es == Acad::eOk) { ent = ArxDbgDbEntity::cast(obj); if (ent != NULL) { es = ent->verifyReferences(numErrorsFixed, true); if (es != Acad::eOk) { ASSERT(0); ArxDbgUtils::rxErrorMsg(es); obj->erase(); // don't know what else to do but erase screwed up entity } } obj->close(); } else { ASSERT(0); ArxDbgUtils::rxErrorMsg(es); } } else { ASSERT(0); } } }
void DNASequenceGenerator::evaluateBaseContent(const MultipleSequenceAlignment& ma, QMap<char, qreal>& result) { QList< QMap<char, qreal> > rowsContents; foreach(const MultipleSequenceAlignmentRow& row, ma->getMsaRows()) { QMap<char, qreal> rowContent; evaluate(row->getData(), rowContent); rowsContents.append(rowContent); } QListIterator< QMap<char, qreal> > listIter(rowsContents); while (listIter.hasNext()) { const QMap<char, qreal>& cm = listIter.next(); QMapIterator<char, qreal> mapIter(cm); while (mapIter.hasNext()) { mapIter.next(); char ch = mapIter.key(); qreal freq = mapIter.value(); if (!result.keys().contains(ch)) { result.insertMulti(ch, freq); } else { result[ch] += freq; } } } int rowsNum = ma->getNumRows(); QMutableMapIterator<char, qreal> i(result); while (i.hasNext()) { i.next(); i.value() /= rowsNum; } }
bool Account::updateStatus(QList<Status> &statusList, QMap<QString, Status> &retwMap, QList<Status> &sourceList, QMap<QString, Status> &sourceMap) { bool bChanged = false; if (sourceList.size() == 0) return false; QListIterator<Status> listIter(sourceList); QList<Status> tmpList; /* for (int i = 0; i != sourceList.size(); ++i) { Status status = sourceList.at(i); status.updatePlainCreatedTime(); bool fExist = statusList.contains(status); if (fExist) continue; else { statusList.append(status); tmpList.append(status); bChanged = true; } } */ while(listIter.hasNext()) { Status status = listIter.next(); status.updatePlainCreatedTime(); if (statusList.contains(status)) { // qDebug(status.getText().toLocal8Bit()); continue; } else { statusList.append(status); tmpList.append(status); bChanged = true; } } sourceList = tmpList; QMapIterator<QString,Status> mapIter(sourceMap); while(mapIter.hasNext()) { QString statusId = mapIter.next().key(); Status status = mapIter.value(); if (!retwMap.contains(statusId)) retwMap.insert(statusId,status); } return bChanged; }
/** * @brief cwLinePlotLabelView::labels * @param cave * @return * * Generates labels from the cave */ QList<cwLabel3dItem> cwLinePlotLabelView::labels(cwCave *cave) const { cwStationPositionLookup stations = cave->stationPositionLookup(); QList< cwLabel3dItem > uniqueStations; uniqueStations.reserve(stations.positions().count()); QFont font; font.setPointSize(14); //Populate the vector of unique stations, this is so we can thread the transformation QMapIterator<QString, QVector3D> mapIter(stations.positions()); while(mapIter.hasNext()) { mapIter.next(); uniqueStations.append(cwLabel3dItem(mapIter.key(), mapIter.value(), font)); } return uniqueStations; }
bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { if (mDeleted) return false; CSMWorld::IdTable& references = dynamic_cast<CSMWorld::IdTable&> ( *mData.getTableModel (CSMWorld::UniversalId::Type_References)); int idColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Id); int cellColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Cell); int stateColumn = references.findColumnIndex (CSMWorld::Columns::ColumnId_Modification); // list IDs in cell std::map<std::string, bool> ids; // id, deleted state for (int i=topLeft.row(); i<=bottomRight.row(); ++i) { std::string cell = Misc::StringUtils::lowerCase (references.data ( references.index (i, cellColumn)).toString().toUtf8().constData()); if (cell==mId) { std::string id = Misc::StringUtils::lowerCase (references.data ( references.index (i, idColumn)).toString().toUtf8().constData()); int state = references.data (references.index (i, stateColumn)).toInt(); ids.insert (std::make_pair (id, state==CSMWorld::RecordBase::State_Deleted)); } } // perform update and remove where needed bool modified = false; std::map<std::string, Object *>::iterator iter = mObjects.begin(); while (iter!=mObjects.end()) { if (iter->second->referenceDataChanged (topLeft, bottomRight)) modified = true; std::map<std::string, bool>::iterator iter2 = ids.find (iter->first); if (iter2!=ids.end()) { bool deleted = iter2->second; ids.erase (iter2); if (deleted) { iter = removeObject (iter); modified = true; continue; } } ++iter; } // add new objects for (std::map<std::string, bool>::iterator mapIter (ids.begin()); mapIter!=ids.end(); ++mapIter) { if (!mapIter->second) { mObjects.insert (std::make_pair ( mapIter->first, new Object (mData, mCellNode, mapIter->first, false))); modified = true; } } return modified; }
KeyType MapIterator<KeyType, DataType>::key() { return(mapIter().key); }
DataType MapIterator<KeyType, DataType>::data() { return(*(mapIter().data)); }
// look up a symbol by name and return its ID. // if the symbol already exists, this routine must not allocate any memory. SymbolIDT MLSymbolTable::getSymbolID(const char * sym, const int len) { SymbolIDT r = 0; bool found = false; int size = mMap.size(); //debug() << size << " entries, making symbol " << sym << "\n"; if (len == 0) { return 0; } // symbol data stays external for now, no memory is allocated. MLSymbolKey symKey(sym, len); MLSymbolMapT::iterator mapIter(mMap.find(symKey)); if (mapIter != mMap.end()) { found = true; r = mapIter->second; } if (!found) { // make a new entry in the symbol table. if(size < kTableSize) { MLSymbolMapT::iterator beginIter; MLSymbolMapT::iterator newEntryIter; std::pair<MLSymbolMapT::iterator, bool> newEntryRet; // insert key/ID pair into map, with ID=0 for now std::pair<MLSymbolKey, SymbolIDT> newEntry(symKey, 0); newEntryRet = mMap.insert(newEntry); // check insertion if (!newEntryRet.second) { MLError() << "MLSymbolTable::getSymbolID: error, key " << sym << " already in map!\n"; } newEntryIter = newEntryRet.first; beginIter = mMap.begin(); // get index of new entry int newIndex = distance(beginIter, newEntryIter); //debug() << "adding symbol " << sym << ", length " << len << "\n"; //debug() << "new map entry index: " << newIndex << " ID = " << size << "\n"; // make key data local in map MLSymbolKey& newKey = const_cast<MLSymbolKey&>(newEntryIter->first); newKey.makeString(); // set ID of new entry newEntryIter->second = size; // adjust indexes to reflect insertion for(int id=0; id<size; ++id) { if (mIndexesByID[id] >= newIndex) { mIndexesByID[id]++; } } // make new index list entry mIndexesByID[size] = newIndex; // make new string pointer. mStringsByID[size] = newKey.mpString; r = size; } else { debug() << "symbol table size exceeded!\n"; } } return r; }