|
Is there anydifference between to two? Also if there is, which is preferred i.e. is one faster then the other? thanks Alex
(comments are locked)
|
|
int[][] is an array of arrays, where array[0] could be 42 items long, and array[1] could have just 2 as each individual inner array can be created independently int[,] has a predefined width and height (so you don't need to check bounds for each column), and is internally just one array, so is generally going to be slightly faster Both have their uses though, so you may still want to try both to see which fits your use case better
(comments are locked)
|
|
cool thanks, well it's for a procedural sphere terrain set up in the editor. Performance will not be that important here (yet). Hehe the progressbar slows things down when creating 65000 verts For grids the arr[,] would be preferred then. However I always use arr[ y * depth + x ] wich propably is a bit faster too. Not sure there Alex arr[,] should be the same speed as arr[y*depth + x], it just maps arr[x,y] to internal_arr[y*width + x] internally
Nov 26 '10 at 01:43 PM
Mike 3
No, at the CLR level, using a multidimensional array is not at all the same as using a vector (single-dimensional array). The runtime has special optimized IL instructions for creating and handling vectors, whereas for multidimensional arrays, method calls must be used, so all the benefit of locality is lost.
Feb 28 '12 at 08:51 PM
ti89TProgrammer
(comments are locked)
|
