How can I have a list in java with larger than integer space

前端 未结 2 398
失恋的感觉
失恋的感觉 2021-01-24 18:51

I am using java.util.List in java for storing a results of my calculation

How can I store values for indexes bigger than maximum integer? (eg large)

相关标签:
2条回答
  • 2021-01-24 19:12

    The short answer is, you will not be using the java.util.List interface. You will have to implement something else.

    If it was my program, and if it was not tailored for some specific supercomputing environment, then I would seriously consider using a database instead of trying to store more than two billion objects in RAM.

    0 讨论(0)
  • 2021-01-24 19:13

    The FastUtil library, which specializes in huge data structures, has a BigList class whose implementation actually uses arrays of arrays. Getters and setters take long parameters for indices.

    With fastutil 6, a new set of classes makes it possible to handle very large collections: in particular, collections whose size exceeds 2^31. Big arrays are arrays-of-arrays handled by a wealth of static methods that act on them as if they were monodimensional arrays with 64-bit indices, and big lists provide 64-bit list access.

    0 讨论(0)
提交回复
热议问题