#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
*/ }

最新文章

  1. 基于面向对象的图片轮播(js原生代码)
  2. KD-tree(2维)
  3. RabbitMQ修改端口号和心跳时间
  4. &lt;&lt;&lt; 数据库基础知识
  5. XPath Checker和Firebug安装与使用
  6. 如何让光标处于EditText的末尾
  7. [转]Unity3D协程介绍 以及 使用
  8. android 上传文件&quot;Content-Type&quot;,为&quot;application/octet-stream&quot; 用php程序在服务端用$GLOBALS[&#39;HTTP_RAW_POST_DATA&#39;]接受(二)
  9. BeanFactory 和 ApplicationContext
  10. Manacher思想 SCOI2013 密码
  11. ZOJ 3607贪心算法
  12. PHP高效获取远程图片尺寸和大小
  13. MySQL Replicationation基础
  14. C语言一维数组复制
  15. superagent和request结果转换区别
  16. windows安装xampp时出现,unable to realloc xxxxxxxx bytes
  17. ActiveMQ入门示例
  18. pdf在线加载&#183;
  19. HDU 2196 Compute --树形dp
  20. linux下安装oh-my-zsh

热门文章

  1. zooKeeper使用记录
  2. 016 Vuetify框架
  3. golang 数据导出excel (github.com/360EntSecGroup-Skylar/excelize)
  4. DDR3(2):初始化
  5. 『7.3 NOIP模拟赛题解』
  6. java中什么是接口
  7. C的温习-开头篇1
  8. 上传文件大小与时间 Web.Config文件 httpRuntime 限制
  9. .Net调用ffmpeg对视频截图
  10. 获取Excel