Dynamic Array reserve

Jacob Carlborg doob at me.com
Sat Dec 16 16:46:49 UTC 2017


On 2017-12-16 15:11, Vino wrote:
> Hi All,
> 
>   Request your help on reserve an dynamic array when the capacity is 
> reached to a point(eg: 80%) so the array to extend the reserve by next 20%
> 
> Example:
> Array!string Test;
> Test. reserve(100) - Initall
> Test =(.........) - The number of entries are dynamic
> if (array.capacity > 80%) { array.reserve(100+20%)

There's a "capacity" property which you can use. Compare that to the 
length of the array to know when it has reach 80%.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list