#include <iostream>
#include <deque> using namespace std; int main()
{
// 插入
deque<int> de;
for(int i=;i<;++i)
{
de.push_back(i);
} for(int i=;i<=;++i)
{
de.push_front(i*);
} for(deque<int>::iterator it=de.begin();it!=de.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; // 删除
de.pop_back();
de.pop_front();
for(deque<int>::iterator it=de.begin();it!=de.end();++it)
{
cout<<*it<<" ";
}
cout<<endl; // 求当前迭代器位置
for(deque<int>::iterator it=de.begin();it!=de.end();++it)
{
cout<<distance(de.begin(),it)<<" ";
}
cout<<endl; }

#include <iostream>#include <deque>
using namespace std;
int main(){    // 插入    deque<int> de;    for(int i=0;i<5;++i)    {        de.push_back(i);    }
    for(int i=1;i<=5;++i)    {        de.push_front(i*10);    }
    for(deque<int>::iterator it=de.begin();it!=de.end();++it)    {        cout<<*it<<" ";    }    cout<<endl;
    // 删除    de.pop_back();    de.pop_front();    for(deque<int>::iterator it=de.begin();it!=de.end();++it)    {        cout<<*it<<" ";    }    cout<<endl;
    // 求当前迭代器位置    for(deque<int>::iterator it=de.begin();it!=de.end();++it)    {        cout<<distance(de.begin(),it)<<" ";    }    cout<<endl;
}

STL-deque 双端数组简析的更多相关文章

  1. C++STL学习笔记_(1)deque双端数组知识

    #include<iostream> using namespace std; #include "deque" #include "algorithm&qu ...

  2. C++STL学习笔记_(2)deque双端数组知识

    #include<iostream> using namespace std; #include "deque" #include "algorithm&qu ...

  3. [STL] deque 双端队列

  4. C++STL之双端队列容器

    C++STL之双端队列容器 deque双端队列容器与vector很类似,采用线性表顺序存储结构.但与vector区别,deque采用分块的线性存储结构来存储数据,每块的大小一般为512B,将之称为de ...

  5. deque双端队列容器

    //deque双端队列容器 //deque双端队列容器与vector一样,采用线性表顺序存储结构,但与vector不同的是, //deque采用的分块线性存储结构来存储数据,每块的大小一般为512字节 ...

  6. deque双端队列笔记

    clear()clear()clear():清空队列 pushpushpush_back()back()back():从尾部插入一个元素. pushpushpush_front()front()fro ...

  7. stl之deque双端队列容器

    deque与vector很相似,不仅能够在尾部插入和删除元素,还能够在头部插入和删除. 只是当考虑到容器元素的内存分配策略和操作性能时.deque相对vector较为有优势. 头文件 #include ...

  8. STL容器:deque双端队列学习

    所谓deque,是"double-ended queue"的缩写; 它是一种动态数组形式,可以向两端发展,在尾部和头部插入元素非常迅速; 在中间插入元素比较费时,因为需要移动其它元 ...

  9. Java 集合深入理解(10):Deque 双端队列

    点击查看 Java 集合框架深入理解 系列, - ( ゜- ゜)つロ 乾杯~ 什么是 Deque Deque 是 Double ended queue (双端队列) 的缩写,读音和 deck 一样,蛋 ...

随机推荐

  1. winform应用如何发布(不用打包)、并提醒用户自动更新

    环境:VS2019 community  C#  winform 应用程序 设计应用程序界面 编写对应代码 使用PS设计程序标识ICON F4打开属性: 设置ICON 设置背景 打开项目属性 打开“发 ...

  2. js - 构造函数-静态属性/方法-原型对象 - 前端第八课

    先来个普通对象 var duixiang={ a:"111", b:function (s) { return s+"886"; } }; console.lo ...

  3. BZOJ1257 [CQOI2007]余数之和 (数论分块)

    题意: 给定n, k,求$\displaystyle \sum_{i=1}^nk\;mod\;i$ n,k<=1e9 思路: 先转化为$\displaystyle \sum_{i=1}^n(k- ...

  4. github三步走(init;add . ;commit -m "提交说明")

    掌握以下几点就基本能满足你平时使用了.按这个顺序来1.git安装,已经好了,略 -到这里本地代码推送到远程已经结束了 2.git本地命令操作-shift+右键-git init:初始化git环境-新建 ...

  5. mIoU混淆矩阵生成函数代码详解

    代码参考博客原文: https://blog.csdn.net/jiongnima/article/details/84750819 在原文和原文的引用里,找到了关于mIoU详尽的解释.这里重点解析  ...

  6. pytorch之 batch_train

    import torch import torch.utils.data as Data torch.manual_seed(1) # reproducible BATCH_SIZE = 5 # BA ...

  7. zabbix 自定义监控项报警给单独的人

    需求就是某个交换机的流量达到某个值后需要报警,但报警的内容不是发给所有的人,而是只发给特定的一个人,而其他的报警信息不能让他收到,他只能收到这一个报警项的报警 1:创建好用户定义好手机号 2:新增加一 ...

  8. light oj 1014 - Ifter Party分解因子

    1014 - Ifter Party   I have an Ifter party at the 5th day of Ramadan for the contestants. For this r ...

  9. 利用VS Code在Azure上构建部署静态页面

    0x00 前言 前一段时间,我找到了Jendrik Illner的个人网站.除了那里的精彩文章,网站的主题也吸引了我的注意力,而且我发现该网站的主题采用了Hugo的Academic主题. 然后,我认为 ...

  10. Swift 枚举-从汇编角度看枚举内存结构

    一.基本使用 先看枚举的几种使用(暂不要问,看看是否都能看懂,待会会逐一讲解) 1.操作一 简单使用 //第一种方式 enum Direction { case east case west case ...