The Artima Developer Community
Sponsored Link

Java Answers Forum
dealing with large ArrayLists

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Lene Kjaer

Posts: 2
Nickname: ljkjaer
Registered: Jan, 2010

dealing with large ArrayLists Posted: Feb 17, 2010 5:54 PM
Reply to this message Reply
Advertisement
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(this.infected==true)

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


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?
Thanks,

Topic: please help me with my project in turbo c or java. Previous Topic   Next Topic Topic: geting data from a web site to my stand-alone application

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use