Fastest Way to Append Multiple Elements to an Array
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Dec 19 18:42:59 PST 2014
On Friday, 19 December 2014 at 14:41:07 UTC, Anonymous wrote:
> What a big surprise. If you make an array of struct, each item
> of your array has the length of the struct. structs a values.
> If you want to append a struct to an array just append a
> pointer to the struct:
>
> ----------
> struct arg{uint a,r,g,h;};
>
> arg * [] argh;
> arg [] argv;
>
> foreach(immutable i; 0..1000)
> argh ~= new arg;
> ----------
>
> so in argh, each item is a size_t pointer. damn.
> In argv, the delta between each item is
> (a.sizeof+r.sizeof+g.sizeof+h.sizeof)
> In argh, the delta between each item is (arg *).sizeof
The two versions which zeljkog compared both deal with values,
not pointers. You're barking up the wrong tree.
More information about the Digitalmars-d-learn
mailing list