triState numColorsBaseModes::performProcessing(QImage* image, int numColors, int numImageColors) { colorTransformerPtr transformer = colorTransformer::createColorTransformer(flossMode()); QVector<triC> newColors = ::chooseColors(*image, numColors, clickedColorList(), numImageColors, transformer); if (!newColors.empty()) { // remove the seed colors from newColors to create generatedColors const QVector<triC>& seedColors = clickedColorList(); QVector<triC> generatedColors = newColors; for (int i = 0, size = seedColors.size(); i < size; ++i) { generatedColors.remove(generatedColors.indexOf(seedColors[i])); } setGeneratedColorList(generatedColors); } else { return triNoop; } if (!::segment(image, newColors, numImageColors).empty()) { //return triState(colorList().size() != savedColorsSize); return triTrue; } else { return triNoop; } }
bool tManagerPrivate::Delete(tBridge bridge) { // Oh FFS, this would be a one liner in C++11 QVector<tBridge> toSave = AllBridges(); const int size = toSave.size(); bool found = false; for (int i = 0; i < size; ++i) { if (IsIdEqual(toSave[i], bridge)) { toSave.remove(i); found = true; break; } } if (!found) { return false; } SaveToSharedStorage(toSave); return true; }
void CreateProcess::clear_pro(void) { while(1) { for (int i = 0; i < integerVector.size(); ++i) { if(integerVector.at(i)->waitForFinished()) { integerVector.at(i)->close(); integerVector.remove(i); } if(integerVector.isEmpty()) { qDebug() << "耗时:" << Timer.elapsed() << "ms"; qDebug()<< "总文件个数:"<<filenum; qDebug()<< "总文件写数据大小:"<<sum<<"kB"; qDebug()<< "总文件写速度:"<<sum/(Timer.elapsed()/1000.00) <<"kBps"; qDebug()<< "每个进程写文件速度:"<<sum/(Timer.elapsed()/1000.00)/processNum <<"kBps"; qDebug()<< "每秒写文件个数:"<< filenum/(Timer.elapsed()/1000.0) <<"个/s"; qDebug()<< "每个进程写文件个数:"<< filenum/(Timer.elapsed()/1000.0)/processNum <<"个/s"; break; } } } }
static QScriptValue scriptVGE2RemoveEdge(QScriptContext *context, QScriptEngine *) { if(context->argumentCount() != 1 || !context->argument(0).isObject()) { context->throwError("removeEdge - invalid parameters"); return QScriptValue(); } grEdge edge; fromScriptValue_grEdge(context->argument(0), edge); if((edge.iFrom < 0 || edge.iFrom >= qvGraphVertices.size()) || (edge.iTo < 0 || edge.iTo >= qvGraphVertices.size()) || (edge.iFrom == edge.iTo)) { context->throwError("removeEdge - invalid parameters"); return QScriptValue(); } for(int i = 0; i < qvGraphEdges.size(); i++) { if(qvGraphEdges[i].iFrom == edge.iFrom && qvGraphEdges[i].iTo == edge.iTo) { qvGraphEdges.remove(i, 1); globalStackIsModified++; needToRebuildRD = true; return QScriptValue(); } } context->throwError("removeEdge - invalid parameters"); return QScriptValue(); }
void Vehicle::setDNA(QVector<double> &dna) { // Пересчитывается количество колёс, чтобы не привысить максимальное. QVector <int> vehWheels; vectors.resize(pointsNum); // Восстановление машин из ДНК for(int i = 0; i < pointsNum; ++i) { vectors[i].angle = dna[i * 8]; vectors[i].length = dna[i * 8 + 1]; vectors[i].r = dna[i * 8 + 2]; vectors[i].g = dna[i * 8 + 3]; vectors[i].b = dna[i * 8 + 4]; vectors[i].wheel = dna[i * 8 + 5]; vectors[i].radius = dna[i * 8 + 6]; vectors[i].motorSpeed = dna[i * 8 + 7]; // Подсчёт количетсва колёс у каждого автомобиля if(vectors[i].wheel) { vehWheels.push_back(i); } } // Удаление лишних колёс while((vehWheels.size() > maxWheelsNum) && (vehWheels.size() > 0)) { int currentRemoved = rand() % vehWheels.size(); vectors[vehWheels[currentRemoved]].wheel = false; vehWheels.remove(currentRemoved, 1); } wheelsNum = vehWheels.size(); }
QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) { QPixmap pm; QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false); if (pe) pm = pe->pixmap; if (pm.isNull()) { int idx = pixmaps.count(); while (--idx >= 0) { if (pe == &pixmaps[idx]) { pixmaps.remove(idx); break; } } if (pixmaps.isEmpty()) return pm; else return pixmap(size, mode, state); } QSize actualSize = pm.size(); if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height())) actualSize.scale(size, Qt::KeepAspectRatio); QString key = QLatin1String("$qt_icon_") + QString::number(pm.cacheKey()) + QString::number(pe->mode) + QString::number(actualSize.width()) + QLatin1Char('_') + QString::number(actualSize.height()) + QLatin1Char('_'); if (mode == QIcon::Active) { if (QPixmapCache::find(key + QString::number(mode), pm)) return pm; // horray if (QPixmapCache::find(key + QString::number(QIcon::Normal), pm)) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt); if (pm.cacheKey() == active.cacheKey()) return pm; } } if (!QPixmapCache::find(key + QString::number(mode), pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); if (!generated.isNull()) pm = generated; } QPixmapCache::insert(key + QString::number(mode), pm); } return pm; }
int ToxTunBase::peerRemoveChan(ENetPeer *enpeer, ToxTunChannel *chan) { ToxTunChannel *tchan0 = (ToxTunChannel*)enpeer->ENET_PEER_TOXCHAN; assert(tchan0 == chan); enpeer->ENET_PEER_TOXCHAN = NULL; return 0; // QVector<ToxTunChannel*>* chans = (QVector<ToxTunChannel*>*)enpeer->ENET_PEER_TOXCHAN; int idx = -1; ToxTunChannel *tchan = NULL; for (int i = 0; i < chans->count(); i++) { tchan = chans->at(i); if (tchan == chan) { idx = i; break; } } if (idx == -1) { qDebug()<<"chan not found:"<<chan<<chan->m_conid; return idx; } chans->remove(idx); return idx; }
void MemoryEditor::closeEvent(QCloseEvent*) { int32_t index = memoryEditors.indexOf(this); if (index >= 0) { memoryEditors.remove(index); } }
//! Removes elements of the specified type from an array template <typename T> static void removeFromArray( QVector<T> & array, QMap<quint16, bool> map ) { for ( int x = array.count() - 1; x >= 0; x-- ) { if ( ! map.contains( x ) ) array.remove( x ); } }
void removeFromVector(QVector<T>& vec, const T& t) { for(int a =0; a < vec.size(); ++a) { if(vec[a] == t) { vec.remove(a); removeFromVector(vec, t); return; } } }
void OsmDatabase::unique( QVector<OsmPlacemark> &placemarks ) const { for ( int i=1; i<placemarks.size(); ++i ) { if ( placemarks[i-1] == placemarks[i] ) { placemarks.remove( i ); --i; } } }
void Nuria::Debug::uninstallOutputHandler (const Callback &callback) { // Remove. int idx = g_handlers.indexOf (callback); if (idx != -1) { g_handlers.remove (idx); } }
static void remove_cred_modifier(QVector<Maemo::Timed::cred_modifier_io_t> &x, const QString &token, bool accrue) { Maemo::Timed::cred_modifier_io_t lookFor ; lookFor.token = token ; lookFor.accrue = accrue ; for(int i = x.indexOf(lookFor); i != -1; i = x.indexOf(lookFor)) { x.remove(i) ; } }
QVector<int> getDiff(QVector<int> V1, QVector<int> V2) { QVector<int> result = V1; int pos; for(int i=0; i<V2.count(); i++) { pos = result.indexOf(V2.at(i)); if(pos != -1) result.remove(pos, 1); } return result; }
bool QtTestModel::removeRows( int row, int count, const QModelIndex & parent) { QAbstractItemModel::beginRemoveRows(parent, row, row + count - 1); for (int r = row+count-1; r >= row; --r) table.remove(r); rCount = table.count(); QAbstractItemModel::endRemoveRows(); return true; }
void remove_ticked() { for (int i = 0; i < word_vec.size(); ++i) { for (int k = 0; k < tick_vec.size(); ++k) { if (word_vec[i]->name == tick_vec[k]->name) { delete word_vec[i]; word_vec.remove(i); tick_vec.remove(k); --i; break; } } } iCurrIndex = 0; iTickIndex = 0; bTickMode = false; }
void SCmdPathRemovePoint::redo() { QVector<SEditPoint*>* editPoints = _manager->getEditPoints(); SEditPoint* editPoint = editPoints->at(_numPoint); _scene->removeItem(editPoint); delete editPoint; editPoints->remove(_numPoint); _graphicsItem->path()->removePoint(_numPoint); _graphicsItem->recomputeGeometry(); }
void MenuEquipmentScreen::equippedItemSelected() { // Reset updated stats and equipment list _updatedStatsItem->setText(QString()); for (int i = 0; i < _updatedStatsItems.size(); i++) delete _updatedStatsItems.at(i); _updatedStatsItems.clear(); _equipmentList.clear(); _equipmentStringList.clear(); _currentSelectedEquipmentString = 0; _currentEquipmentListItem = 0; _equipmentListItem->setText(QString()); for (int i = 0; i < _activeEquipmentListItems.size(); i++) delete _activeEquipmentListItems.at(i); _activeEquipmentListItems.clear(); // Build the equipmentlist QVector<QPair<EquipmentPiece*, int>> equipment = _inventory->getEquipment(); for (int i = 0; i < equipment.size();) { if (!equipmentFilter(equipment.at(i).first)) equipment.remove(i); else { _equipmentList.append(equipment.at(i).first); i++; } } // Set the equipment list QFont font ("Times", 12, QFont::Bold); QBrush brush(Qt::white); QPointF position(_equipmentListItem->pos().x(), _equipmentListItem->pos().y() + 20); _currentSelectedEquipmentString = 0; _equipmentStringList.append(QString("Clear equipment slot")); for (int i = 0; i < _equipmentList.size(); i++) _equipmentStringList.append(_equipmentList.at(i)->getName()); _equipmentListItem->setText("Select equipment:"); for (int i = 0; i < qMin<int>(_equipmentStringList.size(), 8); i++) { QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(_equipmentListPanel); item->setBrush(brush); item->setFont(font); item->setText(_equipmentStringList.at(i)); item->setPos(position); position.setY(position.y() + 20); _activeEquipmentListItems.append(item); } setCurrentEquipmentItem(_activeEquipmentListItems.first(), 0); _state = MenuEquipmentScreen::EQUIPMENT_SELECTION; }
static QScriptValue scriptVGE2DeleteVertex(QScriptContext *context, QScriptEngine *) { if(context->argumentCount() != 1 || !context->argument(0).isNumber()) { context->throwError("deleteVertex - invalid parameters"); return QScriptValue(); } int vertexIndex = context->argument(0).toInt32(); if(vertexIndex >= qvGraphVertices.size() || vertexIndex < 0) { context->throwError("deleteVertex - invalid parameters"); return QScriptValue(); } qvGraphVertices.remove(vertexIndex, 1); for(int i = 0; i < qvGraphEdges.size(); i++) { if(qvGraphEdges[i].iFrom == vertexIndex || qvGraphEdges[i].iTo == vertexIndex) { qvGraphEdges.remove(i, 1); i--; } } for(int i = 0; i < qvGraphEdges.size(); i++) { if(qvGraphEdges[i].iFrom >= vertexIndex) qvGraphEdges[i].iFrom--; if(qvGraphEdges[i].iTo >= vertexIndex) qvGraphEdges[i].iTo--; } needToRebuildRD = true; globalStackIsModified++; return QScriptValue(); }
void MidiParser::mergeMidiEventLists(QVector<MidiEventList> &trackList) { int totalEventCount = 0; // Remove empty tracks & allocate memory exactly needed for (int i = trackList.count() - 1; i >=0; i--) { int eventCount = trackList.at(i).count(); if (eventCount == 0) { trackList.remove(i); } else { totalEventCount += eventCount; } } midiEventList.reserve(totalEventCount); qDebug() << "MidiParser: Expected" << totalEventCount << "events"; // Append events from all the tracks to the output list in sequence QVarLengthArray<int> currentIx(trackList.count()); // The index of the event to be added next QVarLengthArray<SynthTimestamp> currentTime(trackList.count()); // The time in MIDI ticks of the event to be added next for (int i = 0; i < trackList.count(); i++) { currentIx[i] = 0; currentTime[i] = trackList.at(i).at(0).getTimestamp(); } SynthTimestamp lastEventTime = 0; // Timestamp of the last added event forever { int trackIx = -1; SynthTimestamp nextEventTime = 0x10000000; // Find lowest track index with earliest event for (int i = 0; i < trackList.count(); i++) { if (trackList.at(i).count() <= currentIx[i]) continue; if (currentTime[i] < nextEventTime) { nextEventTime = currentTime[i]; trackIx = i; } } if (trackIx == -1) break; const MidiEvent *e = &trackList.at(trackIx).at(currentIx[trackIx]); forever { midiEventList.append(*e); midiEventList.last().setTimestamp(nextEventTime - lastEventTime); lastEventTime = nextEventTime; if (trackList.at(trackIx).count() <= ++currentIx[trackIx]) break; e = &trackList.at(trackIx).at(currentIx[trackIx]); SynthTimestamp nextDeltaTime = e->getTimestamp(); if (nextDeltaTime != 0) { currentTime[trackIx] += nextDeltaTime; break; } } } qDebug() << "MidiParser: Actually" << midiEventList.count() << "events"; }
QVector3D AMBeamConfiguration::findCenter(QVector<QVector3D> shape) const { QVector3D sum(0,0,0); int count = 0; while(!shape.isEmpty()) { sum += shape.first(); shape.remove(0); count++; } return sum/count; }
void Particionador::particionarDatos() { int cantidad_entrenamiento = floor(_cantidad_datos * _porcentaje_entrenamiento ); int cantidad_validacion = floor( cantidad_entrenamiento * _porcentaje_validacion ); int cantidad_prueba = _cantidad_datos - cantidad_entrenamiento; cantidad_entrenamiento-=cantidad_validacion; for( int p=0; p<_cant_particiones; p++ ) { Particionador::particion part; QVector<int> temporal; for( int i=0; i<_cantidad_datos; i++ ) { temporal.append( i ); } for( int j=0; j<cantidad_entrenamiento; j++ ) { int pos = valor_random( 0, temporal.size() ); part.entrenamiento.append( temporal.at( pos ) ); temporal.remove( pos ); } for( int j=0; j<cantidad_validacion; j++ ) { int pos = valor_random( 0, temporal.size() ); part.validacion.append( temporal.at( pos ) ); temporal.remove( pos ); } for( int j=0; j<cantidad_prueba; j++ ) { int pos = valor_random( 0, temporal.size() ); part.prueba.append( temporal.at( pos ) ); temporal.remove( pos ); } _particiones.append( part ); } }
int tsanalitics::getMVL(){ QVector<int> vec; int max=0; for(int i=0;i<ts_row_data->size();i++){ if ( abs(ts_row_data->at(i))>5 ){ vec.push_back(i); }else{ if(vec.size()>15){ max+=ts_row_data->at(vec.last()); } vec.remove(0,vec.size()); vec.clear(); } } return max; }
void UBGeometryUtils::crashPointList(QVector<QPointF> &points) { // QVector<QPointF> result(points); int position = 1; while(position < points.size()) { if (points.at(position) == points.at(position - 1)) { points.remove(position); } else { ++position; } } }
QVector<Fluo> FluoDBase::removeTooNears( QVector<Fluo> list, double dE ) // list はソート済みと仮定する { double val0; int no0; for ( int i = 0; i < list.count(); i++ ) { val0 = list[i].val; no0 = list[i].aNumber; for ( int j = i+1; j < list.count() && (( list[j].val - val0 ) < dE ); j++ ) { if ( list[j].aNumber == no0 ) list.remove( j ); } } return list; }
void Settings::deleteServer(int const& index) { QSettings settings("Zakynes Soft", "Web Administrator"); QVector<ServerInfo> serverList = listServer(); QVariant serverCount = 0; serverList.remove(index); settings.beginGroup("general"); serverCount = (settings.value("server_count", 1).toInt()); settings.endGroup(); settings.beginGroup("server_list"); for(int i=0 ; i<serverList.size() ; i++) { ServerInfo server = serverList.at(i); QVariant index = i + 1; QString strIndex = index.toString(); server.index = index.toInt(); settings.setValue("name" + strIndex, server.name); settings.setValue("host" + strIndex, server.host); settings.setValue("index" + strIndex, server.index); settings.setValue("dbName" + strIndex, server.dbName); settings.setValue("user" + strIndex, server.user); settings.setValue("password" + strIndex, server.password); } QString strIndex = serverCount.toString(); settings.remove("name" + strIndex); settings.remove("host" + strIndex); settings.remove("index" + strIndex); settings.remove("dbName" + strIndex); settings.remove("user" + strIndex); settings.remove("password" + strIndex); settings.endGroup(); settings.beginGroup("general"); settings.setValue("server_count", serverList.size()); settings.endGroup(); settings.sync(); }
void ModelContact::editContact(const QVector<QString>& param) { if (param.size() < 4) throw new Exception("Error: missing parameters to edit contact"); const QString& name = param[0]; const QString& key = param[1]; const QString& ip = param[2]; const QString& old = param[3]; QVector<QString> v; v.append(old); this->delContact(v); v.remove(0); v.append(name); v.append(key); v.append(ip); //this->addContact(v); }
void t100Helper_fillDeviceList(QVector<t100*> &deviceList) { int rval; int loopCount; int errorCount = 0; loopCount = deviceList.size(); for(int i=0;i<loopCount;i++) { t100* tmp = deviceList.at(0); tmp->disconnect(); deviceList.remove(0); } /* Fill the device count in a global array for later disconnect and all. */ deviceCount = t100_coordinator.searchDevices(); for(int i=0;i<deviceCount;i++) { t100* tmp = createT100(); tmp->init(); rval = tmp->connectBySerial(t100_coordinator.getSerialNumber(i)); if(rval < 0) { delete tmp; errorCount++; } else { /* Default is K thermocouple ... */ tmp->setThermocoupleType(KType); tmp->setPgaGain(8); deviceList.append(tmp); } } deviceCount -= errorCount; }
void PhoneService::editPhones(int contractor, QVector<Phone> phones) { QVector<Phone> oldPhones = model->getPhones(contractor); QVector<Phone> newPhones = phones; if(oldPhones != newPhones) // telefony były edytowane { for(int i = 0; i < newPhones.size(); i++) { // jeśli nie zawierają dokładnie takiego tela, to być może była edytowana tylko nazwa lub numer if(!oldPhones.contains(newPhones[i])) { int posAtOld = searchPhone(newPhones[i].getId(), oldPhones); if(posAtOld != -1) // znaleziono telefon liscie, ale z innymi danymi, należy edytować { model->editPhone(contractor, newPhones[i]); oldPhones[posAtOld] = newPhones[i]; } else { model->addPhone(contractor, newPhones[i]); oldPhones.append(newPhones[i]); } } } } /* * jeśli dodano lub edytowano telefony to oldPhones i newPhones powinny być teraz takie same * jeśli nie są tzn., że w nowym kontraktorze usunięto pozycje ze starej faktury */ if(oldPhones != newPhones) { for(int i = 0; i < oldPhones.size(); i++) { if(!newPhones.contains(oldPhones[i])) { model->removePhone(oldPhones[i].getId()); oldPhones.remove(i); } } } }
void simplifyTestFailure(QVector<QPointF> failure, bool winding) { int i = 1; while (i < failure.size() - 1) { QVector<QPointF> t = failure; t.remove(i); if (test(t.data(), t.size(), winding)) { ++i; continue; } failure = t; i = 1; } for (int x = 0; x < failure.size(); ++x) { fprintf(stderr, "%lf,%lf, ", failure[x].x(), failure[x].y()); } fprintf(stderr, "\n\n"); }