Results 1 to 10 of 18

Thread: iterator for array structure

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    (Sorry, answered same time.)

    Well, the compiler will add the same mess and maybe more internally (N-dimensional dynamic array is actually array of arrays, each prime index having different allocation) You would just be in control over it. But sure it may need a little "thinking with indexes" sometimes.

    Also it's possible to simplify the indexing with inline functions:
    Code:
    function TChunk.GetIndex(const x, y, z: integer): integer; inline;
    begin
      result:=x + (z + y * ChunkDepth) * ChunkWidth; // Hope it went right ...
    end;
    
    pBlok:=@pChunk^.blocks[GetIndex(x, y, z)];
    Inlining places the code directly to where it's used, so there shouldn't be any parameter "overhead" or what it's called.
    Last edited by User137; 19-06-2013 at 06:06 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •