I have a 3 dimensioned boost::multi_array representing layers of 2d tilemaps. I would like to be able to clear a layer - aka iterate through all tiles on one layer and set its value to 0, but I can't figure out how to do this - I believe I have to use views but the documentation doesn't make much sense to me. For example, when looking at this example code:
// myarray = 2 x 3 x 4
//
// array_view dims: [base,bound) (dimension striding default = 1)
// dim 0: [0,2)
// dim 1: [1,3)
// dim 2: [0,4) (strided by 2),
//
typedef boost::multi_array_types::index_range range;
// OR typedef array_type::index_range range;
array_type::array_view<3>::type myview = myarray[ boost::indices[range(0,2)][range(1,3)][range(0,4,2)] ];
for (array_type::index i = 0; i != 2; ++i)
for (array_type::index j = 0; j != 2; ++j)
for (array_type::index k = 0; k != 2; ++k)
assert(myview[i][j][k] == myarray[i][j+1][k*2]);
How does boost::indices work? what do those ranges even represent? Sorry if this is obvious to some, I just can't get the hang of it.
Thanks in advance, ell.