d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > When Are Multi Dimensional Arrays > Really Used
123Next
Add Reply New Topic New Poll
Member
Posts: 36,389
Joined: Jul 18 2008
Gold: 3,192.00
Jan 29 2014 06:55am
It seems like any time you need to use them it would be easier to just make a class. Are they actually used in real programs or are they just taught for the sake of knowledge?
Member
Posts: 2,757
Joined: Nov 26 2007
Gold: 1,214.81
Jan 29 2014 08:13am
I personally never use them. I just use a list of lists. Arrays save on memory, but unless you're very limited on hardware, I don't think they're really necessary because lists are easier to deal with and just as fast as arrays.
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Jan 30 2014 02:51am
Lists are very cache-unfriendly and should be avoided unless you have reason (benchmarks) to use them. Your go-to container should be vector, it's implemented as a contiguous array of elements of your type and has a very nice and flexible interface on top of it.
Member
Posts: 11,610
Joined: Oct 28 2008
Gold: 1,795.00
Jan 30 2014 04:49am
Quote (KrzaQ2 @ Jan 30 2014 02:51am)
Lists are very cache-unfriendly and should be avoided unless you have reason (benchmarks) to use them. Your go-to container should be vector, it's implemented as a contiguous array of elements of your type and has a very nice and flexible interface on top of it.


this
Member
Posts: 36,389
Joined: Jul 18 2008
Gold: 3,192.00
Jan 30 2014 08:18am
Quote (KrzaQ2 @ Jan 30 2014 03:51am)
Lists are very cache-unfriendly and should be avoided unless you have reason (benchmarks) to use them. Your go-to container should be vector, it's implemented as a contiguous array of elements of your type and has a very nice and flexible interface on top of it.


So a vector of classes > milti-dimensional array?
Member
Posts: 25,911
Joined: Dec 2 2007
Gold: 1.00
Jan 30 2014 07:43pm
Quote (Mastersam93 @ Jan 30 2014 08:18am)
So a vector of classes > milti-dimensional array?


unless you know the size of the array beforehand and that it will never change, vectors are better
Member
Posts: 22,502
Joined: Aug 5 2011
Gold: 0.00
Jan 30 2014 08:41pm
Quote (Ayulno @ Jan 30 2014 08:43pm)
unless you know the size of the array beforehand and that it will never change, vectors are better


yeah, was going to just type that vectors are dynamic and arrays are fixed. but a link as to why just seem to be a better fit.
nn to reinvent the wheel when the answer is already present
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Jan 30 2014 10:04pm
im not sure what language you're using. in general you want something backed by an array as opposed to multidimensional arrays. from previous posters, i assume "list" refers to linked list and "vector" is just a convenience wrapper around an array, in which case vectors would be the way to go.
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Jan 31 2014 12:13pm
Yeah, I assumed C++ where vector is a dynamic array and list is a doubly linked list.
Go Back To Programming & Development Topic List
123Next
Add Reply New Topic New Poll