I have a 3D vector for my tile map. (layer)(width)(height) In my tile map editor I want the ability to add rows and columns to the map by copying the row or column on the outside. I've successfully done this for the second dimension of the vector but I can't get it to work with the final dimension. My two functions are as follows (using C++):
void add(bool f) { if(f)//add Column this works { for(int i = 0; i < map.size(); i ++) {map.at(i).push_back(map.at(i).back());} } else//add Row this doesn't { for(int i = 0; i < map.size(); i ++) { for(int j = 0; j <map.at(i).size(); j ++) { map.at(i).back().push_back(map.at(i).back().back()); } } } } void subtract(bool f) { if((f) && (map.at(0).size() != 1))//sub Column this works { for(int i = 0; i < map.size(); i ++) {map.at(i).pop_back();} } else if((!f) &&(map.at(0).at(0).size() != 1))//sub Row this doesn't { for(int i = 0; i < map.size(); i ++) { for(int j = 0; j < map.at(i).size(); j--) { map.at(i).back().pop_back(); } } } }
What am I doing wrong? Is the code correct and code else where is the reason it's not working?