Deque objects support the following methods:

append(x)

Add x to the right side of the deque.

appendleft(x)

Add x to the left side of the deque.

clear()

Remove all elements from the deque leaving it with length 0.

copy()

Create a shallow copy of the deque.

New in version 3.5.

count(x)

Count the number of deque elements equal to x.

New in version 3.2.

extend(iterable)

Extend the right side of the deque by appending elements from the iterable argument.

extendleft(iterable)

Extend the left side of the deque by appending elements from iterable. Note, the series of left appends results in reversing the order of elements in the iterable argument.

index(x[, start[, stop]])

Return the position of x in the deque (at or after index start and before index stop). Returns the first match or raises ValueError if not found.

New in version 3.5.

insert(ix)

Insert x into the deque at position i.

If the insertion would cause a bounded deque to grow beyond maxlen, an IndexError is raised.

New in version 3.5.

pop()

Remove and return an element from the right side of the deque. If no elements are present, raises an IndexError.

popleft()

Remove and return an element from the left side of the deque. If no elements are present, raises an IndexError.

remove(value)

Remove the first occurrence of value. If not found, raises a ValueError.

reverse()

Reverse the elements of the deque in-place and then return None.

New in version 3.2.

rotate(n=1)

Rotate the deque n steps to the right. If n is negative, rotate to the left.

When the deque is not empty, rotating one step to the right is equivalent to d.appendleft(d.pop()), and rotating one step to the left is equivalent to d.append(d.popleft()).

Deque objects also provide one read-only attribute:

maxlen

Maximum size of a deque or None if unbounded.

python deque的更多相关文章

  1. python deque的内在实现 本质上就是双向链表所以用于stack、队列非常方便

    How collections.deque works? Cosven     前言:在 Python 生态中,我们经常使用 collections.deque 来实现栈.队列这些只需要进行头尾操作的 ...

  2. Python Deque 模块使用详解,python中yield的用法详解

    Deque模块是Python标准库collections中的一项. 它提供了两端都可以操作的序列, 这意味着, 你可以在序列前后都执行添加或删除. https://blog.csdn.net/qq_3 ...

  3. 利用python deque的extend特性实现列表元素查重

    from collections import deque mydquene = deque() mylist = [0,1,1,2,2,3,3,3,3,4,5,6,7,7,8,8,9,10,10,1 ...

  4. Python Tornado框架(ioloop对象分析)

    网上都说nginx和lighthttpd是高性能web服务器,而tornado也是著名的高抗负载应用,它们间有什么相似处呢?上节提到的ioloop对象是如何循环的呢?往下看. 首先关于TCP服务器的开 ...

  5. Python之带有外部状态的生成器函数

    带有外部状态的生成器函数,也就是你的生成器暴露外部状态给用户解决: 定义一个类,然后把生成器函数放到 __iter__() 方法中过去 定义一个类,然后把生成器函数放到 __iter__() 方法中过 ...

  6. 来自Java程序员的Python新手入门小结

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  7. 利用python的双向队列(Deque)数据结构实现回文检测的算法

    #!/usr/bin/env python # -*- coding: utf-8 -*- # learn <<Problem Solving with Algorithms and Da ...

  8. python - list, cllections模块的deque对象

    list.count() list.pop()/list.pop(i) list.insert(i,element) list.sort()和sorted(list) list.reverse()和r ...

  9. 『Python CoolBook:Collections』数据结构和算法_collections.deque队列&yield应用

    一.collections.deque队列 deque(maxlen=N)构造函数会新建一个固定大小的队列.当新的元素加入并且这个队列已满的时候,最老的元素会自动被移除掉. 如果你不设置最大队列大小, ...

随机推荐

  1. [skill] vim 操作多个window

    前言: 分辨率越来越高,屏幕越来越大,行最长80不变,屏幕利用空白越来越大. 开多个window吧! 开window的命令: 平行开一个window:split <//path/file> ...

  2. xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at[转载]

    今天在添加友盟统计的podfile pod install报错了: bogon:Children songximing$ pod install /Library/Ruby/Gems//gems/co ...

  3. idhttp与cookie

    用关键词“idhttp cookie”在各大搜索引擎得到的结果,大多千篇一律,如果你搜索到这一篇,恭喜你,你有福了. 以下内容测试环境:delphi2007,  winxp sp3, indy10. ...

  4. 转:Java properties | FileNotFoundException: properties (系统找不到指定的文件。)

    原文地址:https://blog.csdn.net/cor_twi/article/details/44514871 web项目 (dynamic web project ) 读取propertie ...

  5. adg的数据传输应用三大模式转换

    1.最大可用性模式(Maximum Availability) 1)该模式提供了仅次于"最大保护模式"的数据保护能力: 2)要求至少一个物理备库收到重做日志后,主库的事务才能够提交 ...

  6. SearchContextMissingException[No search context found for id [1545782]]

    这个原因是scroll的时间设置不够久,设久一些就可以了.

  7. 预备作业2 :学习基础和C语言基础调查

    剑网三毒经pk心得: 看完标题的你真的没有进错,这里是博客园. 想到写这篇文章的原因一部分是自己的确没啥技能比超过90%以上的人还好,还有一部分是受到了作业提示的指引...... 如果你有类似的技能获 ...

  8. Entity Framework中IQueryable, IEnumerable, IList的区别(转载)

    原文:http://www.cnblogs.com/hiteddy/archive/2011/10/01/Difference_among_IQueryable_IEnumeralb_IList_in ...

  9. jszip 前端生成zip文件下载

    [文档地址] export const ZipFileCreate = () => { Promise.all([ // 下面是引入依赖包 require('jszip'), import('f ...

  10. 【Linux】常用指令、ps查看进程、kill杀进程、启动停止tomcat命令、查看日志、查看端口、find查找文件

    1.说出 10 个 linux 常用的指令 1) ls 查看目录中的文件 2)cd /home 进入 '/ home' 目录:cd .. 返回上一级目录:cd ../.. 返回上两级目录 3)mkdi ...