deque_queue_list
#include <iostream>
#include <deque>//front push pop back push pop [] at()
#include <queue>
#include <stack>
#include <list> //remove
using namespace std; void listTest()
{
int iArray[]={,,,,,,,,,,};
list<int> listInt(iArray,iArray+); list<int>::iterator it_list=listInt.begin();
for (;it_list!=listInt.end();++it_list)
{
cout<<*it_list<<" ";
}
cout<<endl;
cout<<"=============================="<<endl;
int i;
for(i=;i<;i++)// (i-=1;i>=0;--i)
{
listInt.push_front(iArray[i]);
}
/////////////////////////////////////// for(i=;i<;i++)//
{
listInt.pop_front();
}
//-----------------------------------
cout<<"pop front:"<<endl;
it_list=listInt.begin();
for (;it_list!=listInt.end();++it_list)
{
cout<<*it_list<<" ";
}
cout<<endl;
cout<<"=============================="<<endl;
//////////////////////////////////////////////// for(i-=;i>=;--i)
{
listInt.push_front(iArray[i]);
} cout<<"push front:"<<endl;
it_list=listInt.begin();
for (;it_list!=listInt.end();++it_list)
{
cout<<*it_list<<" ";
}
cout<<endl;
cout<<"=============================="<<endl; for(i=;i<;i++)//
{
listInt.pop_back();
} cout<<"pop back:"<<endl;
it_list=listInt.begin();
for (;it_list!=listInt.end();++it_list)
{
cout<<*it_list<<" ";
}
cout<<endl;
cout<<"=============================="<<endl; listInt.remove();
cout<<"remove 3:"<<endl;
it_list=listInt.begin();
for (;it_list!=listInt.end();++it_list)
{
cout<<*it_list<<" ";
}
cout<<endl;
/*
1 2 3 4 5 3 3 3 3 3 6
==============================
pop front:
1 2 3 4 5 3 3 3 3 3 6
==============================
push front:
1 2 3 4 5 3 3 3 3 3 6 1 2 3 4 5 3 3 3 3 3 6
==============================
pop back:
1 2 3 4 5 3 3 3 3 3 6
==============================
remove 3:
1 2 4 5 6
Press any key to continue
*/
} void stackTest()
{
int iArray[]={,,,,,,,,,,};
//stack<int> stackInt(iArray,iArray+11);
stack<int> stackInt;
for (int i=;i<sizeof(iArray)/sizeof(int);i++)
{
stackInt.push(iArray[i]);
} cout<<"pop~:"<<endl;
int len=stackInt.size();
for (i=;i<len;i++)
{
cout<<stackInt.top()<<" ";
stackInt.pop();
}
cout<<endl;
/*
pop~:
6 3 3 3 3 3 5 4 3 2 1
Press any key to continue
*/
} void queueTest()
{
int iArray[]={,,,,,,,,,,};
//queue<int> queueInt(iArray,iArray+11);
queue<int> queueInt;
for (int i=;i<;i++)
{
queueInt.push(iArray[i]);
}
//queue<int>::iterator it_queue=queueInt.begin();
//cout<<queueInt.end()<<endl;
////////////////////////////////
cout<<"pop~:"<<endl;
int len=queueInt.size();
for (i=;i<len;i++)
{
cout<<queueInt.front()<<" ";
queueInt.pop();
}
cout<<endl;
/*
pop~:
1 2 3 4 5 3 3 3 3 3 6
Press any key to continue
*/
} void main()
{
listTest();return;
//stackTest();return;
//queueTest();return;
int iArray[]={,,,,,,,,,,};
//deque<int> deInt(iArray,iArray+11);
deque<int> deInt;
for (int i=;i<;i++)
{
deInt.push_back(iArray[i]);
} deque<int>::iterator itorDeque=deInt.begin();
for (;itorDeque!=deInt.end();++itorDeque)
{
cout<<*itorDeque<<" ";
}
cout<<endl;
cout<<"=============================="<<endl;
for(i=;i<;i++)// (i-=1;i>=0;--i)
{
deInt.push_front(iArray[i]);
}
for(i=;i<;i++)//
{
deInt.pop_front();
}
itorDeque=deInt.begin();
for (;itorDeque!=deInt.end();++itorDeque)
{
cout<<*itorDeque<<" ";
}
cout<<endl; for(i-=;i>=;--i)
{
deInt.push_front(iArray[i]);
} cout<<"push front:"<<endl;
itorDeque=deInt.begin();
for (;itorDeque!=deInt.end();++itorDeque)
{
cout<<*itorDeque<<" ";
}
cout<<endl; for(i=;i<;i++)//
{
deInt.pop_back();
} cout<<"pop back:"<<endl;
itorDeque=deInt.begin();
for (;itorDeque!=deInt.end();++itorDeque)
{
cout<<*itorDeque<<" ";
}
cout<<endl; deInt.push_front();
cout<<"at:"<<endl;
for (i=;i<deInt.size();i++)
{
cout<<deInt.at(i)<<" ";
}
cout<<endl;
/*
1 2 3 4 5 3 3 3 3 3 6
==============================
1 2 3 4 5 3 3 3 3 3 6
push front:
1 2 3 4 5 3 3 3 3 3 6 1 2 3 4 5 3 3 3 3 3 6
pop back:
1 2 3 4 5 3 3 3 3 3 6
at:
0 1 2 3 4 5 3 3 3 3 3 6
Press any key to continue
*/ }
deque_queue_list的更多相关文章
随机推荐
- IO流—其他流
			
内存操作流 这个流不关联任何文件,只能在内存中数据,自己在内存中维护着一个缓冲区,我们可以往他维护的缓冲区不断的写入数据,也可以从缓冲区中取出我们写入的数据 ByteArrayOutputStream ...
 - OpenSTF 平台搭建
			
什么是OpenSTF? OpenSTF(Smartphone Test Farm)是一个web端移动设备管理平台,可以从浏览器端远程调试.远程管理设备.其实有点类似于我们现在很火热的云测平台,如:te ...
 - QuantLib 金融计算——收益率曲线之构建曲线(4)
			
[TOC] 如果未做特别说明,文中的程序都是 C++11 代码. QuantLib 金融计算--收益率曲线之构建曲线(4) 本文代码对应的 QuantLib 版本是 1.15.相关源代码可以在 Qua ...
 - linux shell 写swoole重启脚本
			
linux shell 写swoole重启脚本 代码如下<pre>#!/bin/shkill `lsof -t -i:9501`sleep 2php /data/web/mircoweb/ ...
 - 类的练习3——python编程从入门到实践
			
9-13 使用OrderedDict: 在练习6-4中,使用一个标准字典来表示词汇表.使用OrderedDict类来重写这个程序,并确认输出的顺序与在字典中添加的键值对的顺序一致. from coll ...
 - 怎么看系统是UEFI还是Legacy BIOS启动模式?
			
在命令行 cmd 中输入 msinfo32 ,找到右侧[BIOS模式],看到这里显示的是[uefi],那么说明是[uefi]方式启动的,反之显示为[BIOS],那么就是传统[BIOS]启动模式.如下 ...
 - HTML+CSS+JS综合练习(动态验证版)
			
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
 - C# vb .NET读取识别条形码线性条码code39
			
code39是比较常见的条形码编码规则类型的一种.如何在C#,vb等.NET平台语言里实现快速准确读取该类型条形码呢?答案是使用SharpBarcode! SharpBarcode是C#快速高效.准确 ...
 - AppTheme属性设置集合
			
现在新建一个项目基本都会在 style.xml 设置基础的 AppTheme,但是系统的给提供的设置属性又比较多. 所以在此收集记录,以便之后查找方便. <style name="Ap ...
 - Java操作JSON数据(4,end)--Jackson操作JSON数据
			
Jackson是SpringBoot默认使用的JSON处理库,它可以轻松的将Java对象转换成JSON对象,同样也可以将JSON转换成Java对象.本文介绍下Jackson的基本使用方法,包括序列化和 ...