#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. javascript 忍者秘籍读书笔记(二)

    闭包的私有变量 function Ninja() { let feints = 0; this.getFeints = function () { return feints }; this.fein ...

  2. 关于Java单例模式中双重校验锁的实现目的及原理

    开始复习设计模式,一开始理解单例模式中的双重校验锁卡住了,想通了后就自己做了段思维导图来帮助自己理解. 其实理解下来并不难,但还是记录下来帮助自己回忆和借机试试养成写博客的习惯~ public cla ...

  3. C++贪心算法实现部分背包问题

    问题描述: 在部分背包问题中,可以不必拿走整个一件物品,而是可以拿走该物品的任意部分.以此求得在限定背包总重量,从给定的物品中进行选择的情况下的最佳(总价值最高)的选择方案. 细节须知: 分别输出到同 ...

  4. group by 对多个字段进行分组

    转载自:https://blog.csdn.net/xx_star1204/article/details/72884983 在平时的开发任务中我们经常会用到MYSQL的GROUP BY分组, 用来获 ...

  5. -Git Linux vi/vim 命令 按键 MD

    目录 目录 Linux vi/vim 简介 vi/vim 的使用 命令模式 输入模式 底线命令模式 vi/vim 使用实例 使用 vi/vim 进入一般模式 按下 i 进入输入模式,开始编辑文字 按下 ...

  6. kubenetes之配置pod的QoS

    系列目录 上节提到过,QoS影响pod的调度和驱离,本节讲解如何通过配置pod来使它自动被赋予一个QoS 实际上是pod的配置达到一定标准,则kubernetes会自动为其它添加一个QoS类 QoS类 ...

  7. NetCore 统一处理 webapi 返回null 转为“”

    数据库中部分表字段允许空值,则代码中实体类对应的字段类型为可空类型Nullable<>,如int?,DateTime?,null值字段序列化返回的值都为null,前端对应字段赋值需要做nu ...

  8. Advanced-REST-client 获取及安装

    作为一个java开发人员,大家或多或少的要写或者接触一些http接口.而当我们需要本地调试接口常常会因为没有一款好用的工具而烦恼.今天要给大家介绍一款非常好用.实用且方便的http接口测试工具. 获取 ...

  9. Grafana官方和社区提供的dashboard

    详见:https://grafana.com/grafana/dashboards 可以在左侧配置筛选条件,非常强大. 当然Grafana中所有的Dashboard通过JSON进行共享,下载并且导入这 ...

  10. SQL语句及数据库优化

     1,统一SQL语句的写法 对于以下两句SQL语句,程序员认为是相同的,数据库查询优化器认为是不同的. 所以封装成复用方法,用标准模板来控制. select*from dual  select*Fro ...