本文整理汇总了C++中LList::reverse方法的典型用法代码示例。如果您正苦于以下问题:C++ LList::reverse方法的具体用法?C++ LList::reverse怎么用?C++ LList::reverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LList
的用法示例。
在下文中一共展示了LList::reverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char** argv)
{
LList* l = new LList();
l->add(1)->p()->add(2)->p()->add(4)->p()->add(10)->p()->add(80)->p();
l->reverse()->p();
l->remove(44)->p()->remove(2)->p()->remove(10)->p()->remove(80)->p()->remove(1)->p()->remove(4)->p()->remove(99)->p();
StackL* s = new StackL();
s->push(1)->p()->push(2)->p()->push(5)->p()->push(3)->p();
s->pop();
s->p();
s->pop();
s->p();
s->pop();
s->p();
s->pop();
s->p();
QueueL* q = new QueueL();
q->enq(1)->p()->enq(2)->p()->enq(5)->p();
q->dq()->p()->dq()->p()->dq()->p();
return 0;
}
示例2: main
int main()
{
LList<int> llist;
LList<int>::iterator it = llist.begin();
LList<int>::iterator it2 = llist.end();
it2 = LList<int>::iterator(it);
#if 1
it = llist.insert(it,1);
it = llist.insert(it,2);
it = llist.insert(it,3);
it = llist.begin();
cout<<"--------insert-------------"<<endl;
for(;it != llist.end();it++)
cout<<*it<<endl;
llist.clear();
llist.push_back(11);
llist.push_back(12);
llist.push_back(13);
llist.erase(llist.begin());
cout<<"--------push_back-------------"<<endl;
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
llist.clear();
cout<<"--------size-------------"<<llist.size()<<endl;
llist.push_back(14);
llist.push_back(15);
llist.push_back(16);
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
cout<<"--------transfer-------------"<<llist.size()<<endl;
LList<int>::iterator first= ++llist.begin();
LList<int>::iterator last= llist.end();
llist.transfer(++llist.begin(),++first,last);
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
cout<<"--------reverse-------------"<<llist.size()<<endl;
llist.reverse();
for(it=llist.begin();it != llist.end();it++)
cout<<*it<<endl;
#endif
return 0;
}
示例3: main
void main() {
//new list
LList myList;
int listCount;
myList.Append(456);
myList.Append(22);
myList.Append(4);
myList.Append(1095);
myList.Append(1888);
//myList.AppendMiddle(499, -1); //test for entering negative position
//myList.AppendMiddle(423, 4);
myList.Print();
cout << "Number of items in list: " << myList.ListLength() << endl << endl;
cout << "Deleting a node... " << endl;
myList.Delete(456);
cout << "\n\n";
myList.Delete(10); //test for deleting a non-existent node
cout << "Number of items in list: " << myList.ListLength();
cout << "\n\n";
myList.Print();
cout << "\nTail: " << myList.Tail()->Data();
//reverse the list
myList.reverse();
cout << "\n\nList reversed: ";
myList.Print();
cout << "Head: " << myList.Head()->Data(); //returns the head of the list
getchar(); //pause console exit to examine output
}