circular list?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ronparker
    New Member
    • Aug 2010
    • 27

    circular list?

    Hello!
    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? Thank you in advance for any help on this!
    I'll include the relevenat parts of my code below:




    Code:
    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);
    }
  • ronparker
    New Member
    • Aug 2010
    • 27

    #2
    Any help on this Linked list??




    Code:
    private LinkedList<privStat> MyList = new LinkedList<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);
    }

    Comment

    Working...