Dealing with large ArrayLists

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.

Howdy, Stranger!

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