Array Capacity Field

dsimcha dsimcha at yahoo.com
Wed May 7 07:01:06 PDT 2008


I know it's been talked about before, but what is the status of the array
capacity field that's independent of length?  It would be useful to have such
a thing, for example, when working on a program that uses multi-dimensional
dynamic arrays to avoid excessive wasted space.  For example:

void main () {
    uint[][] Table;
    //Read in a huge jagged table of data from a file.
    //Do stuff that involves read-only access to Table[][] and
    // requires a lot of memory.
}

The above might result in running out of memory due to the amount of wasted
space in Table[][].  If there were a way to compact Table[][] once one knows
it will not be appended to, this would solve a lot of problems.



More information about the Digitalmars-d mailing list