C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I increment/decrement a multidemensional array witho

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Hendrix
Guest





PostPosted: Sun Jun 29, 2003 4:15 am    Post subject: How can I increment/decrement a multidemensional array witho Reply with 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.

Thanks for any help.
Back to top
Ivan Vecerina
Guest





PostPosted: Sun Jun 29, 2003 7:59 am    Post subject: Re: How can I increment/decrement a multidemensional array w Reply with quote



"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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.