• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

array vs vector in real time environment

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I want to know which one is better in real time environment the arrays or the vectors.
I have to process large amount of data ,but before that i have to find out that all are arranged serially & then put it in oracle DB & give the acknowledgement to the module from where i am getting this data.
please suggest any link or any information on this matter is welcome.
thanks in advance,
trupti
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't matter. Given that the information has to go into a database, any performance difference between an array and a list structure is going to pale in comparison to the database access overhead.
A List probably makes development a bit easier. But don't use a Vector, by all means use an ArrayList (see this thread to find out why). And always work with it through the List interface, so you can substitute a LinkedList if you find out that it is a better match for the operations you perform.
- Peter
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
how is the behaviour of array in run time environment?
thanks,
trupti
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you be more specific? I'm not sure I understand the question. Or rather, it looks so broad that the only reasonable answer would be "read the JLS".
- Peter
[This message has been edited by Peter den Haan (edited November 09, 2001).]
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi peter,
what i meant by use of array in real time environment is..
as i said in my previous question that i am going to get real time data from one of the module,& i need to store it some place before putting in Db & file.( i want to reduce the time for DB queries..as the amount of data is huge)
so i was reading lot of stuff regarding the same to make a decision what is the best fit for us, i.e. array,vector or array list. i am thinking about the array but still not convinced whether it is the best fit.
if the size of the elements that will be stored in array is fixed then i think i can go for array.
thanks,
trupti
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Run-of-the-mill J2SE Java is not best suited to real-time programming, but you probably know that already. If you do want to use it have a look at the -Xgcinc switch. You may also be interested in the Real Time Java Specification.
Back to your question. An array is fastest, full stop. Question is, do you need it? I don't know what form your data takes and how stringent your real-time requirements are.
Assuming it's basically a large amount of simple numerical data - say, from a bunch of A/D converters - then an array has a huge advantage over any collection type: it can store primitive types (int,...). If you'd want store integers in a Vector, you'd need to instantiate Integer wrapper objects for all of them. Ouch.
If on the other hand you have a moderate flow of complicated or large chunks of data then modeling them as objects could be a good idea. If so, an ArrayList could be considered as an alternative to an array.
Whatever you do you'll have to take care of presizing - resizing a list is a costly operation that you might not be able to afford.
- Peter
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic