squeegedog
20th March 2014, 07:10
I have created several different 2D vectors which hold data, and using a single pointer, can pass a particular vector to a function that makes necessary modifications. Also see the attached URL for clarification if necessary
http://www.qtcentre.org/threads/58323-Pointer-to-2D-Vector
The problem is, that although all of the 2D vectors are laid out in the exact same manner with the same size specifications, etc., some of them are x*y in size and others are y*x in size, if that makes sense. For instance, I have the function working properly on a 12*5 matrix, but the 5*12 matrix does not properly modify in the function. When originally writing the function, I thought this was an easy work-around, by simply making x=y and y=x, but unfortunately, some of the necessary logic doesn't perform properly since it doesn't actually treat x as y and y as x.
I can fix the problem by simply creating another version of the code that operates upon the matrices that are laid out in the opposite fashion, but it seems redundant to create another 500 lines of code whilst having to go through and modify everything along the way when a simply translation of the way the pointer works would solve everything.
So, before going to that length to solve my issue, I decided to ask and see if someone knows a way to create my vector pointer in a manner like:
(*vector_pointer)[y][x] //where [x][y] is the actual layout of the vector
Sorry if this is a lot of typing, but last time I asked a question I wasn't specific enough and made solving a simple problem much more difficult than need be.
Thanks!
http://www.qtcentre.org/threads/58323-Pointer-to-2D-Vector
The problem is, that although all of the 2D vectors are laid out in the exact same manner with the same size specifications, etc., some of them are x*y in size and others are y*x in size, if that makes sense. For instance, I have the function working properly on a 12*5 matrix, but the 5*12 matrix does not properly modify in the function. When originally writing the function, I thought this was an easy work-around, by simply making x=y and y=x, but unfortunately, some of the necessary logic doesn't perform properly since it doesn't actually treat x as y and y as x.
I can fix the problem by simply creating another version of the code that operates upon the matrices that are laid out in the opposite fashion, but it seems redundant to create another 500 lines of code whilst having to go through and modify everything along the way when a simply translation of the way the pointer works would solve everything.
So, before going to that length to solve my issue, I decided to ask and see if someone knows a way to create my vector pointer in a manner like:
(*vector_pointer)[y][x] //where [x][y] is the actual layout of the vector
Sorry if this is a lot of typing, but last time I asked a question I wasn't specific enough and made solving a simple problem much more difficult than need be.
Thanks!