java.util.Stack 合适的数据结构?

标签 java data-structures

嗯。我注意到 Stack 是 Vector 的一个子类,我认为 Vector 和 Hashtable 被认为是“旧”数据结构,因为它们具有内置同步功能,即使您不需要它也是如此。 (与不为您提供的列表、 map 等相比)

那是一个类,而不是一个接口(interface)。

是否有更现代的推荐替代方案?

最佳答案

java.util.Deque

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.

关于java.util.Stack 合适的数据结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1320217/

相关文章:

java - Java 游戏中的边界, "professionals"是怎么做到的?

c++ - 如何打印 Trie 中的所有单词?

scala - 表示区间映射的数据结构

data-structures - 如何在不需要分配给新变量的情况下为链表实现前置?

data-structures - 一组中 "find, remove and return an element"的术语?

java - org.apache.http.HttpRequest 如何添加正文

java - 输出什么也没给出

java - 如何使用默认值设置 GridView 中的第一个项目并根据 JSON 结果填充其余项目

java - 什么更快? System.currentTimeMillis() 或 Date().getTime()?

sql - 使用 row_number() 通过分区生成计算列