Results 1 to 8 of 8

Thread: Get total size of multidimensional array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Get total size of multidimensional array

    Hi.
    I encountered a problem, where i need to get size of 3D array, because i will use size of this to "SetLength" of other dynamic array (1D).

    What i have is this:
    Code:
    myarray[0..255, 0..255, 0..7] of tmyRecord;
    dynarray: array of tmyObject;
    3D array is used to render 3D map. Because i render only specific range (not whole map at once), the X, Y ranges may vary. They could be for ex: X: 17 - 24, Y: 0 - 7.
    Z is always max 7.

    Because of that i must sum them up: X * Y * Z. I get some value.
    And then i set the length of dynamic array to this sum.

    I mean

    Code:
    sum:= X * Y * Z; 
    SetLength(dynarray, sum);
    But is it safe and correct way to do?

    What i need is the SUM of NR_OF_OBJECTS within specified X,Y,Z range.


    Should i be aware of something? Crashes, leaks?

    Im just not sure if im doing it correctly.


    Thanks for any help.
    Last edited by hwnd; 18-10-2012 at 11:00 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
  •