January 14, 2013
Andrey:

> D's containers are disappointment.

They will get better because I think D is slowly getting all the machinery to implement them well, finishing the implementation of const/immutable, shared and memory allocators.

Bye,
bearophile
January 14, 2013
On 2013-01-13 20:55, Damian wrote:
> As per title, it would be awesome if someone could link me to these. I'm
> quite suprised that D does not already contain these.. are there any
> plans for them joining Phobos?

Tango has a stack, at least:

https://github.com/SiegeLord/Tango-D2
http://www.dsource.org/projects/tango/docs/current/

-- 
/Jacob Carlborg
January 14, 2013
> Sorry, I meant to say, a dynamic array of pointers to fixed-sized arrays.

That's for a stack. For a queue a nice implementation is a power-of-2 growable circular queue of pointers to fixed-sized arrays (chunks); plus a ("intrusive", no more memory needed) linked list of some of the last free blocks (that need to be cleared if they contain indirections).

For a deque the implementation is similar, just a bit more complex.

(In theory there is a small queue optimization, a union on the dynamic array that implements the circular queue, to remove one indirection level when the queue needs only one chunk of memory, but then you have to add one test to tell apart the two configurations every time you add or remove an item, so probably it's not worth it).

Bye,
bearophile
1 2
Next ›   Last »