本文整理汇总了C++中QVector::removeLast方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::removeLast方法的具体用法?C++ QVector::removeLast怎么用?C++ QVector::removeLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::removeLast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Modular_exponentiation
LongInt Algorithm::Modular_exponentiation(LongInt a,LongInt m, LongInt r)
{
//qDebug()<<"algorithm.cpp: Modular_exponentiation"<<a<<m<<r;
if(r==0)
{
//qDebug()<<"algorithm.cpp: Modular_exponentiation :( 1 )";
return LongInt(1);
}
QVector<LongInt> part;
part<<1;
LongInt a_k(1),k(1);
while(1)
{
//qDebug()<<a_k<<a<<m;
a_k=((a_k*a)%m);
part<<a_k;
if(part.last()==1)
{
part.removeLast();
//qDebug()<<"algorithm.cpp: Modular_exponentiation :"<<part.value( ((r % LongInt(part.length()))).toInt());
return part.value( ((r % LongInt(part.length()))).toInt());
}
k+=1;
if(k>r)
{
//qDebug()<<"algorithm.cpp: Modular_exponentiation :"<<part.value( ((r % LongInt(part.length()))).toInt());
return part.value( ((r % LongInt(part.length()))).toInt());
return a_k;
}
}
}
示例2: updateCompletion
void CompletionModel::updateCompletion(const QString &text, FindFlags f)
{
if (text.isEmpty())
return;
beginResetModel();
Utils::erase(m_entries, Utils::equal(&CompletionEntry::text, text));
m_entries.prepend({text, f});
while (m_entries.size() > MAX_COMPLETIONS)
m_entries.removeLast();
endResetModel();
}
示例3: qSqrt
QVector<QPoint>
CurveGroup::subsample(QVector<QPoint> cp, float delta, bool closed)
{
// find total path length
int xcount = cp.count();
double plen = 0;
for (int i=1; i<xcount; i++)
{
QPoint v = cp[i]-cp[i-1];
plen += qSqrt(QPoint::dotProduct(v,v));
}
if (closed) // for closed curve
{
QPoint v = cp[0]-cp[xcount-1];
plen += qSqrt(QPoint::dotProduct(v,v));
}
int npcount = plen/delta;
delta = plen/npcount;
QVector<QPoint> c;
c << cp[0];
double clen = 0;
double pclen = 0;
int j = c.count();
int iend = xcount;
if (closed) iend = xcount+1;
for (int i=1; i<iend; i++)
{
QPoint a, b;
if (i < xcount)
{
b = cp[i];
a = cp[i-1];
}
else
{
b = cp[0];
a = cp[xcount-1];
}
QPoint dv = b-a;
clen += qSqrt(QPoint::dotProduct(dv, dv));
while (j*delta <= clen)
{
double frc = (j*delta - pclen)/(clen-pclen);
c << (a + frc*dv);
j = c.count();
}
pclen = clen;
}
if (!closed)
{
if ((c[c.count()-1]-cp[xcount-1]).manhattanLength() < delta)
c.removeLast();
c << cp[xcount-1];
}
return c;
}
示例4: parse
// LATER make read and write timeout parameters
bool PfParser::parse(QIODevice *source, PfOptions options) {
bool lazyBinaryFragments = options.shouldLazyLoadBinaryFragments();
if (!_handler) {
qWarning() << "PfParser::parse called before setting a handler";
return false;
}
_handler->setErrorString(tr("unknown handler error"));
int line = 1, column = 0, arrayColumn = 0;
quint8 c, quote = 0, escapeshift = 0;
quint16 escaped = 0;
qint8 digit;
State state = TopLevel; // current state
State quotedState = TopLevel; // saved state for quotes and comments
State escapedState = TopLevel; // saved state for escapes
QByteArray content, comment, surface;
QVector<Node> nodes;
bool firstNode = true;
PfArray array;
if (!source->isOpen() && !source->open(QIODevice::ReadOnly)) {
_handler->setErrorString(tr("cannot open document : %1")
.arg(source->errorString()));
goto error;
}
if (!_handler->startDocument(options)) {
_handler->setErrorString(tr("cannot handle start of document"));
goto error;
}
while (source->bytesAvailable()
|| source->waitForReadyRead(options.readTimeout()),
source->getChar((char*)&c)) {
++column;
switch(state) {
case TopLevel:
if (c == '(') {
state = Name;
} else if (c == '\n') {
++line;
column = 0;
} else if (pfisspace(c)) {
} else if (c == '#') {
state = Comment;
quotedState = TopLevel;
} else {
_handler->setErrorString(tr("unexpected character '%1' "
"(in TopLevel state)")
.arg(pfquotechar(c)));
goto error;
}
break;
case Name:
if (pfisendofname(c) && content.isEmpty()) {
_handler->setErrorString(tr("anonymous node"));
goto error;
} else if (c == '(') {
nodes.append(QString::fromUtf8(content));
content.clear();
if (!_handler->startNode(names(nodes))) {
_handler->setErrorString(tr("cannot handle start of node"));
goto error;
}
} else if (c == ')') {
nodes.append(QString::fromUtf8(content));
content.clear();
QVector<QString> names = ::names(nodes);
if (!_handler->startNode(names) || !_handler->endNode(names)) {
_handler->setErrorString(tr("cannot handle end of node"));
goto error;
}
nodes.removeLast();
state = nodes.size() ? Content : TopLevel;
if (nodes.isEmpty()) {
switch (options.rootNodesParsingPolicy()) {
case StopAfterFirstRootNode:
if (firstNode)
goto stop_parsing;
break;
case FailAtSecondRootNode:
if (!firstNode) {
_handler->setErrorString(tr("only one root node is allowed "
"(by option)"));
goto error;
}
break;
case ParseEveryRootNode:
;
}
}
} else if (pfisspace(c)) {
if (c == '\n') {
++line;
column = 0;
}
nodes.append(QString::fromUtf8(content));
content.clear();
if (!_handler->startNode(names(nodes))) {
_handler->setErrorString(tr("cannot handle start of node"));
goto error;
}
state = Content;
//.........这里部分代码省略.........