#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. golang学习笔记(一):包,变量,函数

    欢迎访问我的博客和github! go 语言学习笔记第一弹,来自 gotour ,以后要常写笔记,把自己学习笔记记录下来,就算只是笔记也要多写. 好记性不如烂笔头,也要多锻炼自己的写作能力. 说实话, ...

  2. mycat - 数据库中间件 学习记录4

    mycat的配置 cacheservice.properties:路由缓存相关配置文件 index_to_charset.properties:字符集映射关系 rule.xml:分片规则 schema ...

  3. Mutual Information

    Mutal Information, MI, 中文名称:互信息. 用于描述两个概率分布的相似/相关程度. 常用于衡量两个不同聚类算法在同一个数据集的聚类结果的相似性/共享的信息量. 给定两种聚类结果\ ...

  4. ELF文件之六——使用链接脚本-2个函数-data-bss-temp

    main.c int enable; ; int main() { int temp; ; } int add() { ; } elf反汇编结果如下,可以看出main函数中的栈多开了8字节,虽然局部变 ...

  5. 蓝桥杯ALGO-1,区间k大数查询

    #include<stdio.h> int devide(long a[], int low, int high) { long key = a[high]; while (low< ...

  6. bootstrap--网格化布局

    1.响应式网格系统随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列 2.规则 行必须放置在 .container class 内,以便获得适当的对齐(alignment)和内边距 ...

  7. C语言基础五 数组

    数组跟变量的区别? 数组是可以在内存中连续存储多个元素的结构,所有元素必须属于相同类型. 格式:元素类型 数组名[元素个数]: 数组的特点: 只能存放单一元素的数据,里面存放的数据成为元素. 数组的声 ...

  8. while 循环 实例

    /*int i=0; while(i<100){// 循环条件 while先执行后循环 printf("while第%d遍循环体\n",i);//循环体 i++; } */ ...

  9. 全志V3S 编译运行xboot笔记

    目录 全志V3S 编译运行xboot笔记 1.目的 2.环境准备 3.下载 3.1 fel模式进入 3.2 sunxi-fel工具的使用 3.3 烧录 4.串口打印 5.总结 全志V3S 编译运行xb ...

  10. codewars--js--Find The Parity Outlier

    问题描述:(找出奇数数组中唯一的偶数,或是偶数数组中唯一的奇数) You are given an array (which will have a length of at least 3, but ...