java - Collections 层次结构中的 Deque 接口(interface)

标签 java deque java-collections-api

在 Oracle tutorial about Collection interfaces ,接口(interface)层次结构表明 Deque 直接扩展 Collection

enter image description here

但是 Deque 扩展了 Queue(在 Java 版本中这种关系似乎没有变化)。

为什么这没有反射(reflect)在层次结构图中(例如,以 SortedSet 扩展 Set 的方式显示)?

最佳答案

取自 The Deque Interface - The Java™ Tutorials :

The Deque interface is a richer abstract data type than both Stack and Queue because it implements both stacks and queues at the same time.

<小时/>

你是对的,Deque确实扩展了Java中的Queue...
但即使这种实际关系存在,我认为在这张图中省略它的要点是,从概念上讲,Deque 不仅可以被视为 Queue 的特化>.

Deque 为您提供了 Stack后进先出原则 Queue 提供的先进先出,仅表示这些类和接口(interface)的严格实际层次结构可能会产生误导。
例如,LinkedList 实现了 Deque...但是,您可能永远不会将其放在解释不同类型的架构上的 Deque 下。 集合以及它们之间的关系。 :)

关于java - Collections 层次结构中的 Deque 接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26338309/

相关文章:

java - DTO 与 Formbean

java - 如何用 Jetty 修复 "Could not find necessary SLF4j logging jars"?

Java builder 模式——抽象 builder

java - 在java中实现双端队列的问题

java - 使用 Java 8 集合流 API 堆栈

java - 如何将变量和 json 传递给 Web 服务。

c++ - std::deque<char> 上的简单插入-删除-插入给出了奇怪的结果

c++ - "move"两个 vector 在一起

java - JVM 空间复杂度详细信息 : Singly Linked Lists vs Doubly Linked Lists

java - 为什么 jdk 代码风格使用变量赋值并在同一行读取 - 例如。 (i=2) < 最大值