During the creation of a 3-dimensional vector
in C++ I was wondering what to call the third dimension, if the first two were called rows
and columns
.
2D Vector Initialization
To begin, a 2D vector would be initialized like the following:
int rows = 3;
int columns = 5;
int initVal = 0;
// 2 dimensional vector
vector<vector<int>> vec2D(rows, vector<int>(columns, initVal));
All fine and dandy! Let’s look at three dimensions…
3D Vector Initialization
Initializing a 3D vector gets more complicated:
int rows = 3;
int columns = 5;
int dim3 = 2; // what should I name this?!
int initVal = 0;
// 3 dimensional vector
vector<vector<vector<int>>> vec3D(rows, vector<vector<int>>(columns, vector<int>(dim3, initVal)));
Names for the 3rd Dimension Vector
What should we call dim3
?
A few things came to mind:
- layer
- plane
- depth
- time
- aisle (like a grocery store)
- page (pages in book ๐)
- sheet (Excel, similar to page)
- slice (bread ๐)
- stack (stack of books ๐)
- strata (rock layers)
- floor (building ๐ข)
- tier
Aisle sounds fitting the theme of rows and columns.
MATLAB refers to the 3rd dimension as page. I like page because its something I can think of in the physical world, but other applications could use different words!
int rows = 3;
int columns = 5;
int pages = 2;
int initVal = 0;
// 3 dimensional vector
vector<vector<vector<int>>> vec3D(rows, vector<vector<int>>(columns, vector<int>(pages, initVal)));
Good luck! ๐