本文整理汇总了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;
}
示例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"){
//.........这里部分代码省略.........