 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Hendrix Guest
|
Posted: Sun Jun 29, 2003 4:15 am Post subject: How can I increment/decrement a multidemensional array witho |
|
|
Hi, I would like to pick four elements from a multidemensional array
and use the content of those elements. I want to do this without all
the subscript calls required for individual access, just want this for
speed. I know you can increment regular arrays via ++array or array++
etc. etc. but how do you do it with multidemensional arrays? lets say
I have array[x][y] and I need to access array[x+1][y+1] how can I do
this without the subscripts? The x and y count is at 64 by the way.
Thanks for any help.
|
|
| Back to top |
|
 |
Ivan Vecerina Guest
|
Posted: Sun Jun 29, 2003 7:59 am Post subject: Re: How can I increment/decrement a multidemensional array w |
|
|
"Hendrix" <drixerman (AT) yahoo (DOT) com> wrote
| Quote: | Hi, I would like to pick four elements from a multidemensional array
and use the content of those elements. I want to do this without all
the subscript calls required for individual access, just want this for
speed. I know you can increment regular arrays via ++array or array++
etc. etc. but how do you do it with multidemensional arrays? lets say
I have array[x][y] and I need to access array[x+1][y+1] how can I do
this without the subscripts? The x and y count is at 64 by the way.
|
It's as simple as:
itemPtr += (rowLen+1);
Or in the case you mention:
itemPtr += 65;
Assuming that itemPtr points within: Item dataArray[64][64]; and
is in-range.
Note that, when starting to fiddle with item address calculations
in multi-dimensional arrays, I would recommend using a 1-dimensional
array and doing all offset calculations manually. While IIRC the
sub-arrays are supposed to be contiguous, using a consistent
approach should be preferred IMO.
hth,
--
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Soft Dev Manger, XiTact <> http://www.xitact.com
Brainbench MVP for C++ <> http://www.brainbench.com
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|