(There are some questions about time-efficient sparse arrays but I am looking for memory efficiency.)
I need the equivalent of a List
or
I would look at Android's SparseArray implementation for inspiration. You can view the source by downloading AOSP's source code here http://source.android.com/source/downloading.html
I will suggest you to use OpenIntObjectHashMap from Colt library. Link
I would try with trove collections, there is TIntObjectMap which can work for your intents.
Late to this question, but there is IntMap in libgdx which uses cuckoo hashing. If anything it would be interesting to compare with the others.
I have saved my test case as jglick/inthashmap. The results:
HashMap size: 1017504
TIntObjectMap size: 853216
IntHashMap size: 846984
OpenIntObjectHashMap size: 760472