java - Converting A Static "Level" Array To A Dynamic One And Still Get XYZ Coordinates -


okay, have static world (can't resized). know how can convert arraylist instead of current situation:

    for(int xp = 0; xp < world_size_x; xp++) {         for(int zp = 0; zp < world_size_z; zp++) {             for(int yp = 0; yp < world_size_y; yp++) {             }           }       } 

my question is, how can make can use

for(int = 0; < blocks.length; i++) {} 

but still [x][y][z] coordinates?

currently i'm using block:

blocks[x][y][z]; 

how xyz dynamic arraylist?

if need more information, please tell me. i'll glad understand situation.

arraylist's equivalent of .length .size(), , equivalent of [...] .get(...).

that said, arraylist<arraylist<arraylist<...>>> pretty unwieldy structure work with; , although it's theoretically "dynamic", in practice it's difficult resize, because resizing involves creating many new elements have initialize.

if goal merely able specify size @ runtime (but have size remain constant after that), might find easier stick arrays, using variables worldsizex , worldsizey , worldsizez rather constants.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -