本文整理汇总了C++中QVector::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::remove方法的具体用法?C++ QVector::remove怎么用?C++ QVector::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performProcessing
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;
}
}
示例2: Delete
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;
}
示例3: clear_pro
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;
}
}
}
}
示例4: QScriptValue
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();
}
示例5: setDNA
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();
}
示例6: pixmap
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;
}
示例7: peerRemoveChan
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;
}
示例8: closeEvent
void MemoryEditor::closeEvent(QCloseEvent*) {
int32_t index = memoryEditors.indexOf(this);
if (index >= 0) {
memoryEditors.remove(index);
}
}
示例9: removeFromArray
//! 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 );
}
}
示例10: removeFromVector
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;
}
}
}
示例11: unique
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;
}
}
}
示例12:
void Nuria::Debug::uninstallOutputHandler (const Callback &callback) {
// Remove.
int idx = g_handlers.indexOf (callback);
if (idx != -1) {
g_handlers.remove (idx);
}
}
示例13: remove_cred_modifier
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) ;
}
}
示例14: getDiff
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;
}
示例15: removeRows
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;
}