deque Comparison of Queue and Deque methods Comparison of Stack and Deque methods
1、
队列queue和双端队列deque的转换
Queue Method Equivalent Deque Method
add(e) addLast(e)
offer(e) offerLast(e)
remove() removeFirst()
poll() pollFirst()
element() getFirst()
peek() peekFirst()
2、
堆stack和deque的转换
Stack Method Equivalent Deque Method
push(e) addFirst(e)
pop() removeFirst()
peek() peekFirst()
https://github.com/spring-projects/spring-boot/search?q=linkedlist&unscoped_q=linkedlist
import java.util.Deque;
import java.util.LinkedList;
import java.util.Objects; import org.codehaus.plexus.util.cli.CommandLineUtils;
private static final String[] NO_ARGS = {}; private final Deque<String> args = new LinkedList<>(); RunArguments(String arguments) {
Deque (Java Platform SE 8 ) https://docs.oracle.com/javase/8/docs/api/java/util/Deque.html
Interface Deque<E>
- Type Parameters:
E- the type of elements held in this collection
- All Superinterfaces:
- Collection<E>, Iterable<E>, Queue<E>
- All Known Subinterfaces:
- BlockingDeque<E>
- All Known Implementing Classes:
- ArrayDeque, ConcurrentLinkedDeque, LinkedBlockingDeque, LinkedList
public interface Deque<E>
extends Queue<E>A linear collection that supports element insertion and removal at both ends. The name deque is short for "double ended queue" and is usually pronounced "deck". MostDequeimplementations place no fixed limits on the number of elements they may contain, but this interface supports capacity-restricted deques as well as those with no fixed size limit.This interface defines methods to access the elements at both ends of the deque. Methods are provided to insert, remove, and examine the element. Each of these methods exists in two forms: one throws an exception if the operation fails, the other returns a special value (either
nullorfalse, depending on the operation). The latter form of the insert operation is designed specifically for use with capacity-restrictedDequeimplementations; in most implementations, insert operations cannot fail.The twelve methods described above are summarized in the following table:
Summary of Deque methods First Element (Head) Last Element (Tail) Throws exception Special value Throws exception Special value Insert addFirst(e)offerFirst(e)addLast(e)offerLast(e)Remove removeFirst()pollFirst()removeLast()pollLast()Examine getFirst()peekFirst()getLast()peekLast()This interface extends the
Queueinterface. When a deque is used as a queue, FIFO (First-In-First-Out) behavior results. Elements are added at the end of the deque and removed from the beginning. The methods inherited from theQueueinterface are precisely equivalent toDequemethods as indicated in the following table:Comparison of Queue and Deque methods QueueMethodEquivalent DequeMethodadd(e)addLast(e)offer(e)offerLast(e)remove()removeFirst()poll()pollFirst()element()getFirst()peek()peekFirst()Deques can also be used as LIFO (Last-In-First-Out) stacks. This interface should be used in preference to the legacy
Stackclass. When a deque is used as a stack, elements are pushed and popped from the beginning of the deque. Stack methods are precisely equivalent toDequemethods as indicated in the table below:Comparison of Stack and Deque methods Stack Method Equivalent DequeMethodpush(e)addFirst(e)pop()removeFirst()peek()peekFirst()Note that the
peekmethod works equally well when a deque is used as a queue or a stack; in either case, elements are drawn from the beginning of the deque.This interface provides two methods to remove interior elements,
removeFirstOccurrenceandremoveLastOccurrence.Unlike the
Listinterface, this interface does not provide support for indexed access to elements.While
Dequeimplementations are not strictly required to prohibit the insertion of null elements, they are strongly encouraged to do so. Users of anyDequeimplementations that do allow null elements are strongly encouraged not to take advantage of the ability to insert nulls. This is so becausenullis used as a special return value by various methods to indicated that the deque is empty.Dequeimplementations generally do not define element-based versions of theequalsandhashCodemethods, but instead inherit the identity-based versions from classObject.This interface is a member of the Java Collections Framework.
- Since:
- 1.6
deque Comparison of Queue and Deque methods Comparison of Stack and Deque methods的更多相关文章
- PMD - Avoid autogenerated methods to access private fields and methods of inner / outer classes
PMD错误 Avoid autogenerated methods to access private fields and methods of inner / outer classes 样例 p ...
- C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法
每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...
- STL队列 之FIFO队列(queue)、优先队列(priority_queue)、双端队列(deque)
1.FIFO队列 std::queue就是普通意思上的FIFO队列在STL中的模版. 1.1主要的方法有: (1)T front():访问队列的对头元素,并不删除对头元素 (2)T back(): ...
- Coursera Algorithms Programming Assignment 2: Deque and Randomized Queue (100分)
作业原文:http://coursera.cs.princeton.edu/algs4/assignments/queues.html 这次作业与第一周作业相比,稍微简单一些.有三个编程练习:双端队列 ...
- C++在stack的deque实现
本文实现STL在stack大部分功能,同时加入了许多功能. 请注意以下几点: 1.Stack它是一个适配器,在底部vector.list.deque等实现 2.Stack不含有迭代器 在本例中, ...
- Why does the C# compiler translate this != comparison as if it were a > comparison?
Question: I have by pure chance discovered that the C# compiler turns this method: static bool IsNot ...
- leetcode 155. Min Stack 、232. Implement Queue using Stacks 、225. Implement Stack using Queues
155. Min Stack class MinStack { public: /** initialize your data structure here. */ MinStack() { } v ...
- Which HTTP methods match up to which CRUD methods?
https://stackoverflow.com/questions/6203231/which-http-methods-match-up-to-which-crud-methods Crea ...
- 【JDK】JDK源码-Queue, Deque
概述 Queue 和 Deque 都是接口.其中 Queue 接口定义的是一个队列,它包含队列的基本操作:入队(enqueue)和出队(dequeue). Deque 接口继承自 Queue 接口,表 ...
随机推荐
- MongoDB文档的增删改操作
上一篇文章中介绍了MongoDB的一些基本知识,同时看到了怎么启动一个MongoDB服务,并且通过MongoDB自带的shell工具连接到了服务器. 这一次,就通过MongoDB shell介绍一下对 ...
- java的代理和动态代理简单测试
什么叫代理与动态代理? 1.以买火车票多的生活实例说明. 因为天天调bug所以我没有时间去火车票,然后就给火车票代理商打电话订票,然后代理商就去火车站给我买票.就这么理解,需要我做的事情,代理商帮我办 ...
- 中间件安全加固之Jboss
JBoss 的安全设置 1) jmx-console A.jmx-console登录的用户名和密码设置 默认情况访问 http://localhost:8080/jmx-console 就可以浏览jb ...
- PHP代码审计笔记--变量覆盖漏洞
变量覆盖指的是用我们自定义的参数值替换程序原有的变量值,一般变量覆盖漏洞需要结合程序的其它功能来实现完整的攻击. 经常导致变量覆盖漏洞场景有:$$,extract()函数,parse_str()函数, ...
- WebService连接postgresql( 失败尝试)
一.先进行postgresql的配置 1. 安装ODBC驱动 下载地址:http://www.postgresql.org/ftp/odbc/versions/msi/ 2. 打开 控制面板 -&g ...
- kaggle 泰坦尼克号问题总结
学习了机器学习这么久,第一次真正用机器学习中的方法解决一个实际问题,一步步探索,虽然最后结果不是很准确,仅仅达到了0.78647,但是真是收获很多,为了防止以后我的记忆虫上脑,我决定还是记录下来好了. ...
- canvas练习 - 圆
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- git 命令自动补全
下载 Git 的源代码 使用如下命令即可下载: git clone https://github.com/git/git 复制 git-completion.bash 源代码下有个 contrib/c ...
- 题目1457:非常可乐(广度优先遍历BFS)
题目链接:http://ac.jobdu.com/problem.php?pid=1457 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- Robotium源码解读-native控件/webview元素的获取和操作
目前比较有名的Uitest框架有Uiautomator/Robotium/Appium,由于一直对webview元素的获取和操作比较好奇,另外Robotium代码量也不是很大,因此打算学习一下. 一. ...