Datatype Q.

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,364
This one is for everyone how is good at datatypes of CX.

Right now I'm at the point that I'm gonna need to scale up the data-usage quiet a bit.

Basically I currently use a simple array, which is as simple as it gets of course. It does a fine job when I do random acccess, which is what I need.

Code:
Field worldmap:Int[512*512] ' 12 screens world

' But now I'm gonna need to make it grow quiet a bit, and it might even get non-practical in some scenarios:

Field worldmap:Int[2048*2048] ' 50 screens world

Is it still a good idea to keep it as a simple array or should I use other datatypes?

The usage is currently a plain 1D that simulates to be a 2D array and the access will happen with reads and writes in strides of a few sequential screens at a time, vertically or horisontally. I just use simple multiplication or shifting atm. I'm worried about that garbage collection or caching / loading or other random delays when you jump around. Should I use something different? Any ideas?
 
2048x2048 of course becomes 16MB for 32-bit int, and 32MB for 64-bit int.
and I'm willing to waste more space for speed.

EDIT
I use a naive approach now :

1) PICK ANY STARTINGPOINT
2) LOOPHERE : READ e.g. 128 CONSECUTIVE VALUES
3) ADD STRIDE e.g. 2048 AND LOOP ABOVE, UNTIL HAPPY
4) DONE!

Of course this would never work with "infinite" data.
 
Last edited:
I'm worried about that garbage collection or caching / loading or other random delays when you jump around.
Normal arrays should have no performance issues for basic access. The issues arise when you resize arrays.

2048x2048 of course becomes 16MB for 32-bit int, and 32MB for 64-bit int.
Wrong. The size of an it will be determined by the compiler and in some cases the platform. In general an integer is defined as a signed four byte 32 bit value.
 
In general an integer is defined as a signed four byte 32 bit value.
That was what I meant. I just counted the bits, sorry about the datatype missmatch.

I asked a Autodesk programmer and he said It will work just fine but I have my doubts on some phones. I wish I had more devices to try it on.
 
Thanks for your response, much appreciated. I'm not gonna resize, have a big plan to reuse everything constantly.
 
Back
Top Bottom