How do you remove/insert elements in a dynamic array without allocating?

Jonathan M Davis jmdavisProg at gmx.com
Tue Nov 6 22:43:51 PST 2012


On Wednesday, November 07, 2012 04:45:04 Malte Skarupke wrote:
> I don't anticipate that I will ever run into a situation where I
> want to append to a range without caring about whether it
> allocates and copies or not. If I want to append to a range, I
> will write the extra line to create a copy manually.
> Because of that I don't need the syntactic ambiguity of treating
> a range the same as an array.

In general, you can't append to ranges. You can chain ranges together with 
std.range.chain, but appending is not one of the operations that ranges 
support. That's the sort of thing that you'd do to a container, not a range. 
Granted, it doesn't help that arrays are containers of sorts in addition to 
being ranges, but that's abnormal. Normally ranges have no control over 
whatever is actually holding their data.

- Jonathan M Davis


More information about the Digitalmars-d mailing list