2D Arrays
Author Message
2D Arrays

Hi,
I was just wondering how to find out the size of a 2D array when it is
passed as a parameter. How do you find out both the x and y lengths.

Thanks,
Greg

Sat, 25 Jan 2003 03:00:00 GMT
2D Arrays

Quote:

> I was just wondering how to find out the size of a 2D array when it is
> passed as a parameter. How do you find out both the x and y lengths.

You can't.  If you need this, you should probably make an array wrapper
class.

Cheers,
-- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'

Sat, 25 Jan 2003 03:00:00 GMT
2D Arrays

Quote:
> Hi,
> I was just wondering how to find out the size of a 2D array when it is
> passed as a parameter. How do you find out both the x and y lengths.

> Thanks,
> Greg

If, for some reason you can't save the dimensions somewhere when you create
it you can make your own function(findDimensions) that repeatedly passes
indexes to another function(ValidIndex) which return true if the indexs are
in the array or false if out; use Exception to determine this in ValidIndex.
Of course finding an efficient algorithm to narrow in on the end of the
array can be tricky. And of course you probably won't need to do this :)
-laz

Sun, 26 Jan 2003 03:00:00 GMT
2D Arrays
Doing a simple binary repetition might work well enough, kind of the
opposite of a binary search. The hard part would be knowing what middle
value to start with.

Jeff

Quote:

>> Hi,
>> I was just wondering how to find out the size of a 2D array when it is
>> passed as a parameter. How do you find out both the x and y lengths.

>> Thanks,
>> Greg

>If, for some reason you can't save the dimensions somewhere when you create
>it you can make your own function(findDimensions) that repeatedly passes
>indexes to another function(ValidIndex) which return true if the indexs are
>in the array or false if out; use Exception to determine this in
ValidIndex.
>Of course finding an efficient algorithm to narrow in on the end of the
>array can be tricky. And of course you probably won't need to do this :)
>-laz

Sun, 26 Jan 2003 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages

Powered by phpBB® Forum Software