当前位置: 首页>>代码示例>>C++>>正文


C++ QVector::removeLast方法代码示例

本文整理汇总了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;
        }
    }
}
开发者ID:Mynamesparta,项目名称:Factorization_and_Discrete_Logarithm,代码行数:32,代码来源:algorithm.cpp

示例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();
}
开发者ID:choenig,项目名称:qt-creator,代码行数:11,代码来源:findplugin.cpp

示例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;
}
开发者ID:imclab,项目名称:drishti,代码行数:66,代码来源:curvegroup.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的QVector::removeLast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。