本文整理汇总了C++中QVector::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::begin方法的具体用法?C++ QVector::begin怎么用?C++ QVector::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoRelight
void CCropDialog::DoRelight(int nDirection,
itk::ImageLinearConstIteratorWithIndex<ImageType> InputIt,
itk::ImageLinearIteratorWithIndex<ImageType> OutputIt)
{
InputIt.SetDirection(nDirection);
OutputIt.SetDirection(nDirection);
for(InputIt.GoToBegin(), OutputIt.GoToBegin(); !InputIt.IsAtEnd();
InputIt.NextLine(), OutputIt.NextLine())
{
QVector<PixelType> PixelsInLine;
while( !InputIt.IsAtEndOfLine() )
{
PixelsInLine << InputIt.Get(); // it.Set() doesn't exist in the Const Iterator
++InputIt;
}
qSort(PixelsInLine.begin(), PixelsInLine.end());
PixelType Median = PixelsInLine[PixelsInLine.size()/2];
bool bIntensityError = false;
if(Median < nERROR_THRESHOLD)
bIntensityError = true;
for(InputIt.GoToBeginOfLine(); !InputIt.IsAtEndOfLine(); ++InputIt, ++OutputIt)
{
PixelType PixelValue = InputIt.Get();
if(bIntensityError == true)
{
if(PixelValue < Median*nERROR_FACTOR) // (1-0.2)
{
OutputIt.Set(PixelValue); // use the original value
continue;
}
}
double dAdjustPixelValue = (PixelValue/(double)Median) * nILLUMINATION;
PixelValue = (dAdjustPixelValue > (double)nMAX_PIXEL_VALUE)
? (PixelType)nMAX_PIXEL_VALUE : (PixelType)dAdjustPixelValue;
OutputIt.Set(PixelValue);
}
QCoreApplication::processEvents();
}
}
示例2: logic_error
QVector<FoodAmount> FoodAmount::getScaledComponents() const
{
// See getScaledNutrients for logic description
if (getFood() == NULL) {
throw std::logic_error("Attempted to scale the components of an undefined food.");
}
QVector<FoodAmount> components = getFood()->getComponentAmounts();
double scaleFactor = getScaleFactor();
for (QVector<FoodAmount>::iterator i = components.begin(); i != components.end(); ++i)
{
(*i) *= scaleFactor;
}
return components;
}
示例3: initialize
QVector<PasswordEntry> GnomeKeyringPasswordBackend::getEntries(const QUrl &url)
{
initialize();
const QString host = PasswordManager::createHost(url);
QVector<PasswordEntry> list;
foreach (const PasswordEntry &entry, m_allEntries) {
if (entry.host == host) {
list.append(entry);
}
}
// Sort to prefer last updated entries
qSort(list.begin(), list.end());
return list;
}
示例4: insertDeleteChanges
void InsertDeleteChangesCommand::insertDeleteChanges()
{
int numAddedChars = 0;
QVector<KChangeTrackerElement *> elementVector;
KTextDocument(m_document).changeTracker()->deletedChanges(elementVector);
qSort(elementVector.begin(), elementVector.end(), isPositionLessThan);
foreach (KChangeTrackerElement *element, elementVector) {
if (element->isValid() && element->deleteChangeMarker()) {
QTextCursor caret(element->deleteChangeMarker()->document());
caret.setPosition(element->deleteChangeMarker()->position() + numAddedChars + 1);
QTextCharFormat f = caret.charFormat();
f.clearProperty(KCharacterStyle::InlineInstanceId);
caret.setCharFormat(f);
KChangeTracker::insertDeleteFragment(caret, element->deleteChangeMarker());
numAddedChars += KChangeTracker::fragmentLength(element->deleteData());
}
}
}
示例5: CrowdingDistanceAssignement
void NSGA_II::CrowdingDistanceAssignement(QVector<Solution*>&F) {
double max_min;
for (int i = 0; i < F.size(); i++) {
F[i]->zatloczenie = 0;
}
for (unsigned int i_fun = 0; i_fun < problem->funkcje.size(); i_fun++) {
Solution::tmp = 0;
qSort(F.begin(), F.end(), lessThenSolution);
F[0]->zatloczenie = numeric_limits<double>::max();
F[F.size() - 1]->zatloczenie = numeric_limits<double>::max();
max_min = F[F.size() - 1]->przystosowaniePrzeskalowane[i_fun]-F[0]->przystosowaniePrzeskalowane[i_fun];
for (int i_sol = 1; i_sol < F.size() - 1; i_sol++) {
if (F[i_sol]->zatloczenie != numeric_limits<double>::max()) {
F[i_sol]->zatloczenie += (F[i_sol + 1]->przystosowaniePrzeskalowane[i_fun]-F[i_sol - 1]->przystosowaniePrzeskalowane[i_fun]) / max_min;
}
}
}
}
示例6: file
QVector<QString> readDictionary(const QString &filename, int length, bool(*f)(int,int))
{
QVector<QString> dictionar;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::information(NULL, "Information", "Couldn't open the database");
}
QTextStream in(&file);
while (!in.atEnd()) {
QString word = in.readLine();
if (f(word.size(), length))
{
dictionar.push_back(word);
}
}
std::sort(dictionar.begin(), dictionar.end());
return dictionar;
}
示例7: train
void SOM::train( QMap<QString, QVariant> somParameters, QVector<FeaturePtr> features, bool skipInit_debugOnly )
{
if( skipInit_debugOnly == false )
initializeTraining( somParameters, features );
do
{
// Shuffle the list of features to remove bias
std::random_shuffle( features.begin(), features.end() );
// Update the SOM with each feature from the globalFeatures list.
// @todo: consider random sampling for the training if the number of features is high
foreach( FeaturePtr feature, features )
update( feature );
} while( nextEpoch() != false );
}
示例8: STGoThroughCommonStringPool
QString STGoThroughCommonStringPool(const char *s, int *outIndex){
initCommonStringPool();
QVector<CommonCStringPair>::iterator it;
CommonCStringPair pair;
pair.text=s;
pair.index=0;
it=qLowerBound(g_commonsStringsVector.begin(),
g_commonsStringsVector.end(),
pair, cStringComparer);
if(it==g_commonsStringsVector.end() || strcmp(it->text, s)){
if(outIndex)
*outIndex=-1;
return QString(s);
}
int index=it->index;
if(outIndex)
*outIndex=index;
return g_commonStringsQList[index];
}
示例9: _paintShape
void MeshControlPainter::_paintShape(QPainter *painter, MapperGLCanvas* canvas)
{
Mesh* mesh = static_cast<Mesh*>(getShape().data());
Q_ASSERT(mesh);
// Init colors and stroke.
painter->setPen(getRescaledShapeStroke(canvas, true));
// Draw inner quads.
QVector<Quad::ptr> quads = mesh->getQuads();
for (QVector<Quad::ptr>::const_iterator it = quads.begin(); it != quads.end(); ++it)
{
painter->drawPolygon((*it)->toPolygon());
}
// Draw outer quad.
painter->setPen(getRescaledShapeStroke(canvas));
painter->drawPolygon(_shapeItem->mapFromScene(mesh->toPolygon()));
}
示例10: paint
void SubItemDelegate::paint( QPainter * p,
const QStyleOptionViewItem & option,
const QModelIndex & index ) const
{
p->save();
if (option.state & QStyle::State_Selected)
{
p->fillRect(option.rect, option.palette.highlight());
p->setPen( Qt::white );
}
QVariant var = index.model()->data(index, Qt::DisplayRole);
Subtitle *_subtitle = qVariantValue<Subtitle *>(var);
QFontMetrics fm( QApplication::font() );
p->setFont( QApplication::font() );
int begin = option.rect.y() + fm.lineSpacing();
int xbeg = option.rect.x() + 3;
if ( _subtitle->getProblem() )
{
p->setPen( Qt::red );
}
p->drawText( xbeg, begin, _subtitle->getTiming() );
QVector<Subline> v = _subtitle->getSubs();
QVector<Subline>::const_iterator it;
for ( it = v.begin(); it != v.end(); it++ )
{
begin += fm.lineSpacing();
QFont f( QApplication::font() );
if ( it->getFmt() == Subline::Italic )
{
f.setItalic( true );
}
else if ( it->getFmt() == Subline::Bold )
{
f.setBold( true );
}
p->setFont( f );
p->drawText( xbeg, begin, it->getLine() );
p->setFont( QApplication::font() );
}
p->restore();
}
示例11: checkRemoveEntitiesNotInSubset
void checkRemoveEntitiesNotInSubset()
{
// GIVEN
Qt3DRender::QViewport *viewport = new Qt3DRender::QViewport();
Qt3DRender::QClearBuffers *clearBuffer = new Qt3DRender::QClearBuffers(viewport);
Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter(clearBuffer);
Qt3DRender::QLayer *layer = new Qt3DRender::QLayer();
layerFilter->addLayer(layer);
Qt3DRender::TestAspect testAspect(buildEntityFilterTestScene(viewport, layer));
// THEN
Qt3DRender::Render::FrameGraphNode *leafNode = testAspect.nodeManagers()->frameGraphManager()->lookupNode(layerFilter->id());
QVERIFY(leafNode != nullptr);
// WHEN
Qt3DRender::Render::RenderViewBuilder renderViewBuilder(leafNode, 0, testAspect.renderer());
renderViewBuilder.setLayerCacheNeedsToBeRebuilt(true);
renderViewBuilder.prepareJobs();
renderViewBuilder.buildJobHierachy();
renderViewBuilder.renderViewJob()->run();
renderViewBuilder.renderableEntityFilterJob()->run();
renderViewBuilder.syncRenderViewInitializationJob()->run();
renderViewBuilder.filterEntityByLayerJob()->run();
QVector<Qt3DRender::Render::Entity *> renderableEntity = renderViewBuilder.renderableEntityFilterJob()->filteredEntities();
QVector<Qt3DRender::Render::Entity *> filteredEntity = renderViewBuilder.filterEntityByLayerJob()->filteredEntities();
// THEN
QCOMPARE(renderableEntity.size(), 200);
QCOMPARE(filteredEntity.size(), 100);
std::sort(renderableEntity.begin(), renderableEntity.end());
// WHEN
renderableEntity = Qt3DRender::Render::RenderViewBuilder::entitiesInSubset(renderableEntity, filteredEntity);
// THEN
QCOMPARE(renderableEntity.size(), 100);
for (const auto entity : renderableEntity) {
QVERIFY(filteredEntity.contains(entity));
}
}
示例12: confint
QPair<T, T> confint(const QVector<T> &vecin) {
long double avg = 0.0;
long double stddev = 0.0;
QVector<T> vec = vecin;
qSort(vec.begin(), vec.end());
for (int i=0;i<vec.count() / 20;++i) {
vec.pop_front();
vec.pop_back();
}
foreach(T v, vec)
avg += v;
avg /= vec.count();
foreach(T v, vec)
stddev += (v-avg)*(v-avg);
stddev = sqrtl(stddev / vec.count());
return QPair<T,T>(static_cast<T>(avg), static_cast<T>(1.96 * stddev));
}
示例13: setVector
void RealTimeMultiSampleArray::setVector(QVector<double> v)
{
if(v.size() != int(m_uiNumChannels))
qDebug() << "Error Occured in RealTimeMultiSampleArray::setVector: Vector size does not matche the number of channels! ";
for(QVector<double>::iterator it = v.begin(); it != v.end(); ++it)
{
if(*it < m_dMinValue) *it = m_dMinValue;
else if(*it > m_dMaxValue) *it = m_dMaxValue;
}
m_vecValue = v;
m_matSamples.push_back(m_vecValue);
if(m_matSamples.size() >= m_ucMultiArraySize && notifyEnabled)
{
notify();
m_matSamples.clear();
}
}
示例14: UpdateComputedWidths
void SeparateTabBar::UpdateComputedWidths () const
{
const auto cnt = count ();
ComputedWidths_.resize (cnt);
const auto maxTabWidth = width () / 4;
struct TabInfo
{
int Idx_;
int WidthHint_;
};
QVector<TabInfo> infos;
for (int i = 0; i < cnt - 1; ++i)
infos.push_back ({ i, std::min (QTabBar::tabSizeHint (i).width (), maxTabWidth) });
std::sort (infos.begin (), infos.end (),
[] (const TabInfo& l, const TabInfo& r) { return l.WidthHint_ < r.WidthHint_; });
const auto hspace = std::max (style ()->pixelMetric (QStyle::PM_TabBarTabHSpace), 10);
const auto btnWidth = AddTabButton_ ? AddTabButton_->sizeHint ().width () + hspace : 30;
auto remainder = width () - btnWidth;
while (!infos.isEmpty ())
{
auto currentMax = remainder / infos.size ();
if (infos.front ().WidthHint_ > currentMax)
break;
const auto& info = infos.front ();
remainder -= info.WidthHint_;
ComputedWidths_ [info.Idx_] = info.WidthHint_;
infos.pop_front ();
}
if (infos.isEmpty ())
return;
const auto uniform = remainder / infos.size ();
for (const auto& info : infos)
ComputedWidths_ [info.Idx_] = uniform;
}
示例15: exportImage
void MainWindow::exportImage() {
QVector<CPoint> centroids = nGas.getCentroids();
QVector<KPoint> points = nGas.getPoints();
QImage image(imageSize,QImage::Format_RGB32);
QProgressDialog progress(this);
progress.setWindowTitle("Self-organizing maps");
progress.setLabelText("Generating file...");
progress.setModal(true);
progress.show();
int k = 0;
for(int i=0;i<image.width();i++) {
progress.setValue(((double)i / (double)image.width()) * 100);
if(progress.wasCanceled())
return;
for(int j=0;j<image.height();j++) {
for(int d=0;d<centroids.size();d++)
centroids[d].setDistance(Centroids::countDistance(centroids[d],points[k]));
qSort(centroids.begin(),centroids.end(),SortByDistance());
image.setPixel(i,j,qRgb(centroids[0].paramAt(0),centroids[1].paramAt(1),centroids[2].paramAt(2)));
k++;
}
}
progress.setValue(100);
QGraphicsScene* scene = new QGraphicsScene(this);
ui->graphicsView_2->setScene(scene);
scene->addPixmap(QPixmap::fromImage(image.scaled(ui->graphicsView->width()*0.95,ui->graphicsView->height()*0.95)));
ui->graphicsView_2->show();
QImageWriter writer;
writer.setFileName(QFileDialog::getSaveFileName(this,tr("Open image"),"C:\\Users\\GiBSoN\\Desktop",tr("Image files (*.jpg *.png)")));
writer.setFormat("jpg");
writer.setCompression(10);
writer.write(image);
}