Simple array init question
Daniel Keep
daniel.keep.lists at gmail.com
Sat Apr 7 20:11:40 PDT 2007
Graham wrote:
> A floating point texture buffer - 3 floats per pixel, and (say) 640x480
> pixels.
>
> Manfred Nowak wrote:
>> Graham wrote
>>
>>> several thousand elements large.
>>
>> In what domains do one need to represent dense multidimensional
>> structures with O(1) time for accesses of elements?
>>
>> -manfred
Perhaps you shouldn't be using jagged arrays, then. int[][] is *NOT* a
multidimensional array. It's basically equivalent to this:
struct int_array
{
int* ptr;
size_t length;
}
struct int_array_array
{
int_array* ptr;
size_t length;
}
int_array_array buffer;
Notice those nested pointers; that means that your texture is not
necessarily contiguous in memory, which would make, for example, loading
the texture into GL a pain in the behind. Not sure if the cache would
have problems...
I think there's a few multidimensional array templates floating
around... or if not, you can always write your own :)
-- Daniel
--
int getRandomNumber()
{
return 4; // chosen by fair dice roll.
// guaranteed to be random.
}
http://xkcd.com/
v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
More information about the Digitalmars-d
mailing list