Is there any class in Java, which holds an array of elements both in order and optimized for fast searching?
I.e. I need to retrieve elements both by numeric index (like in Vector
) and by hash (like in HashMap
).
LinkedHashMap does not match
I think LinkedHashMap
does not match since it guarantees order, but does not allow fast accessing by index (position number). According to description, it will require to traverse entire chain to find a given position. This is what any Collection
can with iterator.
EDIT 2
I.e. both searching by key and by index should be fast, not only by key.