#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的更多相关文章

随机推荐

  1. 由浅入深了解NB-IoT | 我的物联网成长记

    [摘要] 什么是NB-IoT?NB-IoT有什么优势?NB-IoT能做什么?本文将会从NB-IoT技术的发展历程,技术特点,通信协议,应用场景等方面为您全方面解读NB-IoT技术,了解NB-IoT的独 ...

  2. 【转】用 async/await 来处理异步

    原文地址:https://www.cnblogs.com/SamWeb/p/8417940.html 昨天看了一篇vue的教程,作者用async/ await来发送异步请求,从服务端获取数据,代码很简 ...

  3. 2、word插入目录、图/表

    一.word插入目录 依次对每个标题在“段落”中进行大纲级别选择. 光标定位于目录生成的页面,再“引用”->“目录”->选择“自动目录1/2”,则可自动生成目录.若目录有所更改,则可选择“ ...

  4. c++ 数值计算库Eigen

    http://eigen.tuxfamily.org/index.php?title=Main_Page

  5. JavaSE 面试题: 类初始化和实例初始化等

    JavaSE 面试题 类初始化和实例初始化等 class Father { private int i = test(); private static int j = method(); stati ...

  6. NetCore2.2开发环境搭建和2008R2部署环境搭建

    开发环境: 开发工具:VS2017 系统:Win10 64位 Skd下载地址: https://dotnet.microsoft.com/download 3个都下载下载,安装dotnet-sdk-2 ...

  7. 2019 中钢网java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.中钢网等公司offer,岗位是Java后端开发,因为发展原因最终选择去了中钢网,入职一年时间了,也成为了面试官 ...

  8. Python基础8

    jupyter notebook 安装目录插件, 步骤

  9. 【JVM学习笔记一】Java内存区域

    1. 运行时数据区域 1) 程序计数器 | 线程私有,存储线程运行时所执行字节码的行号,实现分支.循环.跳转.异常处理.线程恢复等基础功能 | Java方法,记录正在执行的虚拟机字节码指令的行号:Na ...

  10. Shell 选择排序

    举例 #!/bin/bash echo "please input a number list:" read -a arrs for((i=0;i<${#arrs[@]};i ...