I’d go for the first option (the single 1D array) as it will give you a single block of memory to play in rather than potentially thousands of fragmented memory blocks
If accessing the correct element of the array is doing your head in though, I’d write a utility method to convert x, y, z locations into an offset into the 1D array
int offset(int x, int y, int z) {
return (z * xSize * ySize) + (y * xSize) + x;
}
Related Contents:
- Map a 2D array onto a 1D array
- Why do we need to specify the column size when passing a 2D array as a parameter?
- Array to pointer decay and passing multidimensional arrays to functions
- Pointer address in a C multidimensional array
- Manipulate multidimensional array in a function
- Freaky way of allocating two-dimensional array?
- Are a, &a, *a, a[0], &a[0] and &a[0][0] identical pointers?
- How can I malloc a struct array inside a function? Code works otherwise
- Why is 248×248 the maximum bi dimensional array size I can declare?
- How can I work with dynamically-allocated arbitrary-dimensional arrays?
- Copying string into char array
- With arrays, why is it the case that a[5] == 5[a]?
- How do I declare a 2d array in C++ using new?
- How do I determine the size of my array in C?
- Why isn’t the size of an array parameter the same as within main?
- Getting a stack overflow exception when declaring a large array
- C pointer to array/array of pointers disambiguation
- C sizeof a passed array [duplicate]
- casting void** to 2D array of int – C
- C: differences between char pointer and array [duplicate]
- How do I correctly set up, access, and free a multidimensional array in C?
- Finding length of array inside a function [duplicate]
- Is 2d array a double pointer? [duplicate]
- Algorithm: efficient way to remove duplicate integers from an array
- How to pass a multidimensional array to a function in C and C++
- Is using flexible array members in C bad practice?
- How dangerous is it to access an array out of bounds?
- Is there a standard function in C that would return the length of an array?
- Passing a 2D array of structs
- Variably modified array at file scope
- Why array type object is not modifiable?
- C char array initialization
- Measuring Cache Latencies
- Why does “memset(arr, -1, sizeof(arr)/sizeof(int))” not clear an integer array to -1?
- variably modified array at file scope in C
- No compiler error when fixed size char array is initialized without enough room for null terminator
- What do square brackets mean in array initialization in C?
- Performance of 2-dimensional array vs 1-dimensional array
- Pointer vs array in C, non-trivial difference
- Is there any overhead for using variable-length arrays?
- Convert Bytes to Int / uint in C
- Accessing elements of a matrix row-wise versus column-wise
- Why am I being allowed to use a const qualified variable as an array size in C?
- Pointer to 2D arrays in C
- What’s the difference between array and &array?
- Changing array inside function in C
- problems with char array = char array
- How are 3D arrays stored in C?
- Calculate Length of Array in C by Using Function
- Assign multiple values to array in C