简体   繁体   English

java集合数据结构

[英]java collections data structure

I need a data structure that does contains(element) quickly(preferably O(1)). 我需要一个快速包含(元素)的数据结构(最好是O(1))。 also it allow me to iterate it in the order it comes in. HashSet satisfy the former, Vector satisfies the latter. 它也允许我按照它的顺序迭代它.HashSet满足前者,Vector满足后者。 does such thing exist in java.util? 在java.util中存在这样的事情吗?

Look at the Linked* implementations. 查看Linked*实现。 They preserve the insert order. 它们保留了插入顺序。 In your case you need a LinkedHashSet . 在您的情况下,您需要一个LinkedHashSet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM