473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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:




Expand|Select|Wrap|Line Numbers
  1. private ArrayList<privStat> MyList = new ArrayList<privStat>();
  2. public class privStat {
  3.    long Stat1;
  4.    long Stat2;
  5.    float Stat3;
  6.    BigDecimal Stat4;
  7. }
  8.  
  9. NewStat = new privStat(//new message)
  10. if (MyList.size() - 1 < 10) {
  11.    MyList.add(NewStat);
  12. } else {
  13.     Mylist.remove(0);
  14.     Mylist.add(NewStat);
  15. }
  16.  
Mar 6 '12 #1
1 1688
Any help on this Linked list??




Expand|Select|Wrap|Line Numbers
  1. private LinkedList<privStat> MyList = new LinkedList<privStat>();
  2. public class privStat {
  3.    long Stat1;
  4.    long Stat2;
  5.    float Stat3;
  6.    BigDecimal Stat4;
  7. }
  8.  
  9. NewStat = new privStat(//new message)
  10. if (MyList.size() - 1 < 10) {
  11.    MyList.add(NewStat);
  12. } else {
  13.     Mylist.remove(0);
  14.     Mylist.add(NewStat);
  15. }
  16.  
Mar 6 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: kazio | last post by:
Hello, So, I need to have double linked, circular list (last element point to the first one and first one points to the last one). I thought maybe I could use list container from STL, but...
4
by: Vince | last post by:
Hi, I am not used to template and I cannot find what's wrong with this code : Compiler(MSVS 7) complains at line : class iterator : public std::iterator<... Here is the source code
4
by: spike | last post by:
I've googled like crazy and can't seem to find an answer to why this isn't working. I want to create a custom list class that acts as a circular list. ie: my_list = (0, 1, 2) how I want it...
3
by: dave | last post by:
I created a circular linked list whats the best way to search function for a name in the list and retrun that node address class PhoneBook { friend PhoneBookUserInterface; public:...
5
by: John N. | last post by:
Hi All, Here I have a linked list each containing a char and is double linked. Then I have a pointer to an item in that list which is the current insertion point. In this funtion, the user...
1
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
16
by: Shwetabh | last post by:
Hi, This is a question asked to me in an interview. I haven't been able to figure out an answer for it. Please try to see what can be done about the following problem. /* I have been given two...
3
by: Franco Perilli | last post by:
I've compiled this code and no problems, but when I run the program, it prints only the last entry i've inserted. Looks like a problem in the sorted insertion algorithm. Can u help me plz? ...
2
by: morris11 | last post by:
I am trying to create a circular list that includes insert() , find() and remove() methodes. also a step() method that moves current along to the next link. I still need to display the list by...
0
by: Joseph Guildino | last post by:
Good afternoon all! I have this program in Python that is really starting to make my head go crazy. It utilizes linked lists (circularly linked list). Now, correct me if I am wrong, but a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.