I have a private arraylist with classes that include two longs, a float and a BigDecimal. As new data comes in I currently am removing the oldest element, shifiting all other elements over, and then adding the newest element. I think this is taking up a lot of memory uncessearly. So is there anyway to make this a circle, so I don't need to shift over elements in the array?
I'll include the relevenat parts of my code below:
private ArrayList<privStat> MyList = new ArrayList<privStat>();
public class privStat {
long Stat1;
long Stat2;
float Stat3;
BigDecimal Stat4;
}
NewStat = new privStat(//new message)
if (MyList.size() - 1 < 10) {
MyList.add(NewStat);
} else {
Mylist.remove(0);
Mylist.add(NewStat);
}