Containers I'd like to see in std.containers

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun May 30 16:59:02 PDT 2010


On 05/30/2010 05:32 PM, Simen kjaeraas wrote:
> Rainer Deyke <rainerd at eldwood.com> wrote:
>
>> Any container that supports pushing and popping on one end can be used
>> as a stack. Any container that supports pushing on one end and popping
>> on the other can be used as a queue. I don't think either of these need
>> their own container type.
>
> There are other concerns than simply what works. First of all is
> readability - having containers called queue and stack makes code easier
> to understand, even if this is done with a simple alias.
> There might also be a concern about efficiency, as there is a difference
> in how fast different containers can push and pop.

std.container is designed to provide operations only within strict 
complexity limits. So if something offers insertFront and removeFront or 
insertBack and removeBack, it should be usable as a stack.

Andrei



More information about the Digitalmars-d mailing list