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

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RunArguments.java

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

compact1, compact2, compact3
java.util

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:
    ArrayDequeConcurrentLinkedDequeLinkedBlockingDequeLinkedList

    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". Most Deque implementations 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 null or false, depending on the operation). The latter form of the insert operation is designed specifically for use with capacity-restricted Deque implementations; 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 Queue interface. 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 the Queue interface are precisely equivalent to Deque methods as indicated in the following table:

    Comparison of Queue and Deque methods
    Queue Method Equivalent Deque Method
    add(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 Stack class. When a deque is used as a stack, elements are pushed and popped from the beginning of the deque. Stack methods are precisely equivalent to Deque methods as indicated in the table below:

    Comparison of Stack and Deque methods
    Stack Method Equivalent Deque Method
    push(e) addFirst(e)
    pop() removeFirst()
    peek() peekFirst()

    Note that the peek method 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, removeFirstOccurrence and removeLastOccurrence.

    Unlike the List interface, this interface does not provide support for indexed access to elements.

    While Deque implementations are not strictly required to prohibit the insertion of null elements, they are strongly encouraged to do so. Users of any Deque implementations that do allow null elements are strongly encouraged not to take advantage of the ability to insert nulls. This is so because null is used as a special return value by various methods to indicated that the deque is empty.

    Deque implementations generally do not define element-based versions of the equals and hashCode methods, but instead inherit the identity-based versions from class Object.

    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的更多相关文章

  1. 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 ...

  2. C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法

    每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...

  3. STL队列 之FIFO队列(queue)、优先队列(priority_queue)、双端队列(deque)

    1.FIFO队列   std::queue就是普通意思上的FIFO队列在STL中的模版. 1.1主要的方法有: (1)T front():访问队列的对头元素,并不删除对头元素 (2)T back(): ...

  4. Coursera Algorithms Programming Assignment 2: Deque and Randomized Queue (100分)

    作业原文:http://coursera.cs.princeton.edu/algs4/assignments/queues.html 这次作业与第一周作业相比,稍微简单一些.有三个编程练习:双端队列 ...

  5. C++在stack的deque实现

     本文实现STL在stack大部分功能,同时加入了许多功能. 请注意以下几点: 1.Stack它是一个适配器,在底部vector.list.deque等实现 2.Stack不含有迭代器 在本例中, ...

  6. 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 ...

  7. 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 ...

  8. Which HTTP methods match up to which CRUD methods?

    https://stackoverflow.com/questions/6203231/which-http-methods-match-up-to-which-crud-methods   Crea ...

  9. 【JDK】JDK源码-Queue, Deque

    概述 Queue 和 Deque 都是接口.其中 Queue 接口定义的是一个队列,它包含队列的基本操作:入队(enqueue)和出队(dequeue). Deque 接口继承自 Queue 接口,表 ...

随机推荐

  1. Git Step by Step – (4) 探索.git目录

    前面一篇文章介绍了Git对象模型,接下来我们就进入".git"目录看看到底有什么东西,目录中哪些东西又跟Git对象模型相关.结合这个目录,我们将进一步了解Git的工作原理. .gi ...

  2. js中forEach,for in,for of的区别

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. php查找之二分查找

    二分查找,往往是针对有序的数组进行查找,我们假设一个序列是数组有序,然后给定一个数字,查出它应该在这个数组中的排序位置 百度百科中讲到 二分查找也称折半查找(Binary Search),它是一种效率 ...

  4. Springboot启动后报错【This application has no explicit mapping for /error, so you are seeing this as a fallback····】

    This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Dec 1 ...

  5. python --help查询python相关命令

    C:\Users\lenovo>python --help usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ... O ...

  6. hudson.AbortException: No files found in path D:\testproject\project2\testoutput\ with configured filemask: output.xml

    错误描述: hudson.AbortException: No files found in path D:\testproject\project2\testoutput\ with configu ...

  7. BootStrap Table显示行号,并且分页后依然递增

    bootStrap table 此处使用的是V1.9.0.在网上百度的方法是: { title: '序号', field: '', formatter: function (value, row, i ...

  8. SpringBoot(十二)-- 整合Redis

    1.pom依赖 <!-- 添加redis支持 --> <dependency> <groupId>org.springframework.boot</grou ...

  9. Unity透明Shader

    Shader "Custom/Blocks" { Properties { _Color (,,,) _MainTex ("Albedo (RGB)", 2D) ...

  10. Mybatis输入输出映射

    一.输入映射 1.传递简单类型 <select id="findUserById" parameterType="int" resultType=&quo ...