Results 1 to 12 of 12
Thread: How Useful Are Arrays ?
- 09-03-2010, 11:12 AM #1
How Useful Are Arrays ?
Hi Guys
I was wondering, how actually useful are Arrays ? I mean I can think of 1000s of Apps where one needs collections, but in all cases I find writing and retreaving data from a database more logical than using an Array !!
Where exactly do Arrays come to their own league and are the best logical solution ?
I was thinking of building a Note Apps, but it seems more logical to use a database for storing the notes !!
I'd appreciate some comments and corrections for my opinion of Arrays !
Thank You." It does not matter how slowly you go so long as you do not stop. ".... Confucius
- 09-03-2010, 11:17 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
Arrays can be useful if you have n elements of type T and you have to manipulate them. The value of n has to be fixed before you do the manipulations and the type T also has to be known in advance and the manipulation of the elements can't be done sequentially. To most people new to programming arrays are the one size fits all data structure and they cram and abuse their programs and logic to be able to use arrays. Arrays have their (limited) use.
kind regards,
Jos
- 09-03-2010, 11:29 AM #3
Abuse >> Exactly !!
Can you tell me a project example, of when Array would be better use than a Database ?
Thanks" It does not matter how slowly you go so long as you do not stop. ".... Confucius
-
- 09-03-2010, 11:47 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 09-03-2010, 12:19 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
?
I write Java code that accesses databases...that's my job.
I cannot think of one project I have been on whereby I did not need collections (ie arrays).
What on earth do you expect to do with the result of the following query if not stick it in a collection??
"SELECT * FROM my_table"
- 09-03-2010, 01:16 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
- 09-03-2010, 01:22 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I'm not convinced the OP wa simply talking about arrays...he does mention collections as a general term.
In any case, arrays tend to back most Lists, so the ArrayList I stick most of my results into is simply a convenient front end to an array.
- 09-03-2010, 08:37 PM #9
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
Arrays needed for quicksort
The fastest single processor
sort method is quicksort.
Quick sort implements an array
to perform its sort.
I have a wireframe editor project
that holds its data in a
linked-list. This simplifies the
implementation of the project's
editing functions.
I needed a fast method to
re-order the triangles in
wireframe models according to
their Z coordinates.
So I implemented an array of
linked-list referrences in a
quicksort method. The results
is exceptional.
Moral:
The fastest single processor
data sorting algorithm in
computer history requires an
array to perform.Last edited by paul pasciak; 09-03-2010 at 09:14 PM. Reason: Re-phrased for continuity and clarity
- 09-04-2010, 02:30 AM #10
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
how random of you
- 09-04-2010, 02:03 PM #11
Member
- Join Date
- Aug 2010
- Posts
- 35
- Rep Power
- 0
As others have said, I'm finding them useful for things that don't change their size.
For example, I'm writing an application that has a calendar in it and an object for each month of the year. Now, unless the moon falls into the sea, there will always be twelve months in each year!
Therefore, it's easier for me to use an array than a vector.
- 09-05-2010, 02:58 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
store array of arrays in array of arrays
By joost_m in forum New To JavaReplies: 4Last Post: 04-19-2010, 10:32 AM -
Arrays.sort... why sorting all arrays in class?
By innspiron in forum New To JavaReplies: 6Last Post: 03-23-2010, 01:40 AM -
Arrays
By hypes057 in forum New To JavaReplies: 13Last Post: 09-04-2009, 10:40 AM -
Arrays
By HosHos in forum New To JavaReplies: 3Last Post: 08-14-2009, 04:23 AM -
Need help with Arrays
By dietgal in forum New To JavaReplies: 21Last Post: 10-08-2008, 01:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks