C
Crirus
Hello
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a particular
point in my grid have value true of false.
Now I need a way to store the boolean value for each coordinates in my grid.
I found some methods:
1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason
2. Another way is to store only the true values in an array. Each value
y*512+x added to the array tells me that in p(x,y) I have value True
Drawback: Search if there is a value like y*512 +x in my array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?
3. I could use ArrayList with y*-512+x values and Add, Contains, Remove for
adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how much
memory require
Anyway, I need the best compromise memory allocated - search for value - set
a value
Any advices?
I know I could test each one, just hope someone have allready done it
I have 512x512 grid of booleans
At a specific point in my application, I need to find out if a particular
point in my grid have value true of false.
Now I need a way to store the boolean value for each coordinates in my grid.
I found some methods:
1. I could have a 512x512 BitArray Class something like P(x,y) ~
myBitArray(y*512+x) = True
A simple check will tell me what value is in a particular point
Drawback: memory occupied without reason
2. Another way is to store only the true values in an array. Each value
y*512+x added to the array tells me that in p(x,y) I have value True
Drawback: Search if there is a value like y*512 +x in my array can be
long, setting a new value means Redim Preserve the array and is time
consumming, right?
3. I could use ArrayList with y*-512+x values and Add, Contains, Remove for
adding, testing, setting a value.
Drawback: have no iddea if is faster than the other ways or how much
memory require
Anyway, I need the best compromise memory allocated - search for value - set
a value
Any advices?
I know I could test each one, just hope someone have allready done it
