Containers I'd like to see in std.containers

Justin Spahr-Summers Justin.SpahrSummers at gmail.com
Sun May 30 21:26:35 PDT 2010


On Mon, 31 May 2010 00:32:44 +0200, Simen kjaeraas 
<simen.kjaras at gmail.com> 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.

This strikes me as a reason to actually not provide such aliases. Even 
for stacks and queues, there are tradeoffs involved in the selection of 
containers. For instance, vectors and linked lists can both service for 
a stack implementation, but they have rather different performance and 
memory characteristics. Similarly for deques implemented with arrays or 
doubly-linked lists.


More information about the Digitalmars-d mailing list