Of course, this is not possible in java (currently), but ideally I would like to implement it, since it underlies many iterations. For example, the first time it is called, I do it 650,000+ times when it creates an ArrayList . Unfortunately, the reality is that my actual code does not have set inside the else loop; this way it will pass add commands and then set and waste time.
After that, I have this also in another loop, where it only performs a set, since the data is already created, and it is multi-user in many others, so this is a lengthy process.
ArrayList<Integer> dataColLinker = new java.util.ArrayList<Integer>(); ... ... public void setLinkerAt( int value, int rowIndex) { ... while(rowIndex >= dataColLinker.size()) { dataColLinker.add(value); } else { dataColLinker.set(rowIndex, value); }
Any ideas or theories? I'm not sure about speed in java when it comes to if and ArrayList if , etc.
java performance arraylist theory while-loop
xchiltonx
source share