Reputation:
I need a data structure that does contains(element) quickly(preferably O(1)). also it allow me to iterate it in the order it comes in. HashSet satisfy the former, Vector satisfies the latter. does such thing exist in java.util?
Upvotes: 2
Views: 321
Reputation: 47373
Look at the Linked*
implementations. They preserve the insert order. In your case you need a LinkedHashSet.
Upvotes: 2