Dealing with large ArrayLists - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dealing with large ArrayLists

ljkjaerljkjaer Posts: 2Member
I have written methods for pathogen shedding and accumulation in a grid.
I have created 3 different ArrayLists: one to hold the x coord, one the hold the y coord and one to hold the deposit time (the pathogen has a halflife, I need to know deposit time).
I use the following :

public void depositPathogen()


if(RandomHelper.nextDouble() < infectionRate)
xDepositList.add(infectedX); yDepositList.add(infectedY);

public void checkForPathogenPickup()
if(xDepositList.contains(myX) && yDepositList.contains(myY)){
for (int i=0; i<xDepositList.size(); i++){
if (xDepositList.get(i)== myX && yDepositList.get(i)==myY) {
double myDepositTime = timeDepositList.get(i);
myPathogenInfectivity = myPathogeInfectivity + pathogHalfLife(myDepositTime,myTick)

the methods work but since my lists get really large, it seriously increases computing time. Any ideas of how this can be done better?
Sign In or Register to comment.