Any interest in having these in Phobos?

https://github.com/bitwise-github/d-containers

Phobos doesn't currently have a Queue(T), and Array(T) leaves much to be desired. The containers I've built are very full featured, fast, and are unittested fairly thoroughly. I intend to add range checking to both containers as well. Inspiration was taken from C++'s vector and queue, C#'s generic List and Queue, and D's Array.

I'm not sure how the container's I've built would be integrated though. They do go against the current container spec, but for good reason.

The container spec says containers should be reference types, but I guess this clashed with the idea of Phobos being @nogc so someone tried to make Array(T) ref counted. The result is std.container.Array being a struct with an instance of RefCounted inside it, which is bad for performance, but also inflexible. Innocent looking code like the following will do 2 separate allocations: One for the RefCounted payload, and one for the Array's data. On top of being a performance hit, it doesn't allow the user to choose how they want to manage memory.

Array!int a = Array!int(1, 2, 3); // 2 allocations, or else! >:D

The containers I've built are simple value types with a postblit. Using this as a base, one can simply use the container as-is if they like(which I do), but it's also trivial to make either a ref-counted version, or GC version.

See here for example:
https://github.com/bitwise-github/d-containers/blob/master/main.d

    Bit


Reply via email to