Is there a data structure that implements the Map
interface and holds an array of elements with continuous integer keys efficiently in Java?
In my view, to achieve best efficiency, it would be equivalent to wrapping an array or ArrayList
with an index offset value in a Map
interface, or a hash table with the hash function f(key) = key - offset
and a minimum backing array.
I know this is quite simple but I don't want to reinvent the wheels. Is there such a data structure in JDK? Or is there a library that provides an implementation?