array of structures, or structure of arrays?

后端 未结 11 521
甜味超标
甜味超标 2021-01-01 01:32

Hmmm. I have a table which is an array of structures I need to store in Java. The naive don\'t-worry-about-memory approach says do this:

public class Record          


        
11条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 02:02

    I would go for the ArrayList version too, so I don't need to worry about growing it. Do you need to have a column like access to values? What is your scenario behind your question?

    Edit You could also use a common long[][] matrix. I don't know how you pass the columns to Matlab, but I guess you don't gain much speed with a column based storage, more likely you loose speed in the java computation.

提交回复
热议问题