Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dealing with large ArrayLists Posted by ljkjaer on 17 Feb 2010 at 7:05 PM
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,



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.