问题描述
如果有人熟悉 Objective-C,那么有一个名为 NSOrderedSet 充当 Set,其项目可以作为 Array 的项目访问.
If anybody is familiar with Objective-C there is a collection called NSOrderedSet that acts as Set and its items can be accessed as an Array's ones.
Java 中有这样的东西吗?
Is there anything like this in Java?
我听说有一个集合叫做 LinkedHashMap代码>,但我还没有找到类似的集合.
I've heard there is a collection called LinkedHashMap, but I haven't found anything like it for a set.
推荐答案
看看LinkedHashSet 类
来自 Java 文档:
From Java doc:
Set 接口的哈希表和链表实现,具有可预测的迭代顺序.此实现与 HashSet 的不同之处在于它维护一个双向链表,该列表贯穿其所有条目.这个链表定义了迭代顺序,元素被插入到集合中的顺序(insertion-order).请注意,如果将元素重新插入集合中,插入顺序不会受到影响.(如果在调用 s.contains(e) 将在调用之前立即返回 true 时调用 s.add(e),则元素 e 将重新插入到集合 s 中.).
Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). Note that insertion order is not affected if an element is re-inserted into the set. (An element e is reinserted into a set s if s.add(e) is invoked when s.contains(e) would return true immediately prior to the invocation.).
这篇关于Java中有序集的任何实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)