Deque impl.

bearophile bearophileHUGS at lycos.com
Wed Jan 30 17:48:58 PST 2013


Steven Schveighoffer:

> Hm... I thought deque's major draw was that it had O(1) 
> insertion/removal from the front and back, and ALSO had O(1) 
> indexing.

Amortized O(1) insert/removal, and hard O(1) for indexing. And 
the multiplicative constants must be low.


> My implementation (probably very naive) is two D arrays placed 
> front to front.  This allows the O(1) insertion/removal and 
> O(1) indexing.

What's the memory behavour if you keep using it like a queue 
(adding at the end and removing from the head)?

See my first comment:

http://forum.dlang.org/thread/mailman.852.1359488662.22503.digitalmars-d@puremagic.com#post-kkfkonazfgsuqddkuimy:40forum.dlang.org

Bye,
bearophile


More information about the Digitalmars-d mailing list