dynamic array capacity
spir
denis.spir at gmail.com
Wed Dec 29 09:48:01 PST 2010
On Wed, 29 Dec 2010 11:24:01 -0500
"Steven Schveighoffer" <schveiguy at yahoo.com> wrote:
> On Wed, 29 Dec 2010 07:29:29 -0500, spir <denis.spir at gmail.com> wrote:
>
> > Hello,
> >
> > Is there a common idiom to pre-allocate a dynamic array. I mean
> > allocating to avoid numerous re-allocations in loop, not setting length
> > & filling content.
>
> int[] x;
> x.reserve(10000); // pre-allocate at least 10000 elements for appending
>
> Another way to do it:
>
> Appender!(int[]) app;
> app.reserve(10000);
>
> this will perform much better than builtin array appending.
>
> -Steve
Thank you, Steven. I could not find anything like 'reserve' in the property table because it's not a property ;-)
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list