Although I have Java in the title, it can be for any OO language. I would like to learn some new ideas to improve the performance of what I'm trying to do.
I have a method that constantly gets an array of Object []. I need to split the objects in this array into multiple arrays (a list or something else), so I have an independent list for each column of all arrays that the method receives.
Example:
List<List<Object>> column-oriented = new ArrayList<ArrayList<Object>>();
public void newObject(Object[] obj) {
for(int i = 0; i < obj.length; i++) {
column-oriented.get(i).add(obj[i]);
}
}
Note. For simplicity, I omitted the initialization of objects and more.
The code shown above is slow of course. I have already tried several other things, but would like to hear some new ideas.
How would you do this, knowing that it is very sensitive to performance?
EDIT:
I checked a few things and found that:
ArrayList ( ) Object [] . , System.copyArray. ( , ) , ArrayList ...