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


C++ QLinkedList::back方法代码示例

本文整理汇总了C++中QLinkedList::back方法的典型用法代码示例。如果您正苦于以下问题:C++ QLinkedList::back方法的具体用法?C++ QLinkedList::back怎么用?C++ QLinkedList::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLinkedList的用法示例。


在下文中一共展示了QLinkedList::back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main ()
{
  QLinkedList<int> myQLinkedList;
  int sum (0);
  myQLinkedList.push_back (100);
  myQLinkedList.push_back (200);
  myQLinkedList.push_back (300);
  assert(myQLinkedList.back() == 300);
  int n = 3;
  while (!myQLinkedList.empty())
  {
    assert(myQLinkedList.back() == n*100);
    sum+=myQLinkedList.back();
    myQLinkedList.pop_back();
    n--;
  }

  cout << "The elements of myQLinkedList summed " << sum << endl;

  return 0;
}
开发者ID:xsery,项目名称:benchmarks-esbmc-qt,代码行数:21,代码来源:main.cpp

示例2: compile

void compile(QString path,QStringList& import,QFile &out){
    QFile fp(path);
    if(fp.open(QFile::ReadOnly)){
        QDir dir(QFileInfo(fp).absoluteDir());
        QString modName = QFileInfo(fp).baseName();
        if(readLine(fp).trimmed()!=FILE_HEAD){
            qDebug("Indicated file is not a algorithm file of Uranus2");
            exit(0);
        }
        int pIndent,cIndent=0,functionIndent=0;
        Function* function=0;
        QRegExp keyWord("(\\s*)(\\w+)\\s",Qt::CaseInsensitive);
        QRegExp argHook("(<.+>)?(.+)?");
        QLinkedList<StackItem*> stack;
        while(!fp.atEnd()){
            QString line=QString::fromUtf8(fp.readLine());
            keyWord.indexIn(line);
            QString key=keyWord.cap(2).toLower();
            line=line.mid(keyWord.cap().length()).trimmed();
            pIndent = cIndent;
            cIndent=keyWord.cap(1).length();
            if(cIndent<functionIndent){
                if(function!=0){
                    function->write(out);
                    function=0;
                }
            }else if(cIndent<=pIndent){
                while(pIndent>=cIndent){
                    pIndent--;
                    if(!stack.isEmpty()){
                        stack.pop_back();
                    }
                }
            }
            StackItem* parent = (stack.isEmpty())?0:stack.back(),
                    *self=new StackItem(key,line,cIndent);
            stack.push_back(self);

            if(key=="import"){
                import.append(dir.absoluteFilePath(line));
            }else if(key=="function"){
                function=new Function(modName,line);
                functionIndent=cIndent+1;
            }else if(key=="hint"){
                if(function!=0){
                    if(parent->key=="function")
                        self->indent++;
                    self->outBegin="#"+line;
                    function->append(self);
                }
            }else if(key=="arg"){
                if(parent->key=="function"&&function){
                    function->args()<<line;
                }
            }else if(key=="assign"){
                self->outBegin=line+"=";
                function->append(self);
            }else if(key=="value"){
                if(parent->key=="assign"){
                    argHook.indexIn(line);
                    if(argHook.cap(1)=="<list>"){
                    }else if(argHook.cap(1)=="<function>"){
                    }else if(argHook.cap(1)=="<variable>"){
                        self->outBegin=argHook.cap(2).trimmed();
                    }else{
                        self->outBegin=line.trimmed();
                    }
                    parent->addChild(self);
                }
            }else if(key=="branch"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="call"){
                QString fname;
                if(line.left(3)=="://"){
                    fname=Function::conv(modName,line.mid(3));
                }else{
                    QStringList f = line.split("/");
                    if(f.count()==2){
                        fname=Function::conv(f.at(0),f.at(1));
                    }
                }
                self->outBegin=fname+"(";
                self->outSep=",";
                self->outEnd=")";
                if(parent->key=="do"){
                    function->append(self);
                }else{
                    parent->addChild(self);
                }
            }else if(key=="conditional"){
                self->outBegin="if True:";
                function->append(self);
            }else if(key=="do"){
            }else if(key=="list"){
                self->outBegin="[";
                self->outSep=",";
                self->outEnd="]";
                parent->addChild(self);
            }else if(key=="item"){
//.........这里部分代码省略.........
开发者ID:davidaq,项目名称:Uranus2,代码行数:101,代码来源:main.cpp


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