Memory-efficient sparse array in Java

前端 未结 5 569
野趣味
野趣味 2020-11-29 10:17

(There are some questions about time-efficient sparse arrays but I am looking for memory efficiency.)

I need the equivalent of a List or

相关标签:
5条回答
  • 2020-11-29 10:53

    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

    0 讨论(0)
  • 2020-11-29 10:53

    I will suggest you to use OpenIntObjectHashMap from Colt library. Link

    0 讨论(0)
  • 2020-11-29 10:59

    I would try with trove collections, there is TIntObjectMap which can work for your intents.

    0 讨论(0)
  • 2020-11-29 11:15

    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.

    0 讨论(0)
  • 2020-11-29 11:16

    I have saved my test case as jglick/inthashmap. The results:

    HashMap size: 1017504
    TIntObjectMap size: 853216
    IntHashMap size: 846984
    OpenIntObjectHashMap size: 760472
    
    0 讨论(0)
提交回复
热议问题