Re: Creating dynamic arrays of known size

2012-03-09 Thread Andrej Mitrovic
Isn't this just as good? Key[] keys; keys.reserve(num_keys) foreach (key; keys_in_aa) keys ~= key;

Re: Creating dynamic arrays of known size

2012-03-09 Thread Steven Schveighoffer
On Fri, 09 Mar 2012 01:59:34 -0500, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, March 08, 2012 22:05:57 H. S. Teoh wrote: On Thu, Mar 08, 2012 at 09:13:13PM -0800, H. S. Teoh wrote: So, I'm plodding along with my AA implementation that *hopefully* will eventually reach the

Re: Creating dynamic arrays of known size

2012-03-09 Thread H. S. Teoh
On Fri, Mar 09, 2012 at 03:10:21PM +0100, Andrej Mitrovic wrote: Isn't this just as good? Key[] keys; keys.reserve(num_keys) foreach (key; keys_in_aa) keys ~= key; I suppose that should work. Although it does open up a new can of worms: reserve is @system and also impure. I can see

Creating dynamic arrays of known size

2012-03-08 Thread H. S. Teoh
So, I'm plodding along with my AA implementation that *hopefully* will eventually reach the point where it's usable enough to be dropped into druntime. I'm writing .keys and .values right now, and wondering what's the best way to construct the returned array. Obviously, using =~ repeatedly is a

Re: Creating dynamic arrays of known size

2012-03-08 Thread H. S. Teoh
On Thu, Mar 08, 2012 at 09:13:13PM -0800, H. S. Teoh wrote: So, I'm plodding along with my AA implementation that *hopefully* will eventually reach the point where it's usable enough to be dropped into druntime. I'm writing .keys and .values right now, and wondering what's the best way to

Re: Creating dynamic arrays of known size

2012-03-08 Thread Jonathan M Davis
On Thursday, March 08, 2012 22:05:57 H. S. Teoh wrote: On Thu, Mar 08, 2012 at 09:13:13PM -0800, H. S. Teoh wrote: So, I'm plodding along with my AA implementation that *hopefully* will eventually reach the point where it's usable enough to be dropped into druntime. I'm writing .keys and