<div dir="ltr">Hi. Anatoly,<div><br></div><div>A deque is a structure that only supports adding to the front of the "line" or back of the "line".  While a queue is LILO (last in last out, or first in, first out), a stack is LIFO (last in, first out) a deque allows pulling from either end, but not the middle.  I have never used one, so i cannot speak to the use cases.</div><div><br></div><div>Examples:A queue could be a line at a bus stop or in front of a bank teller.  A stack would be a paper inbox on a desk or a gun clip.  A deque could be a section of water pipe, or a train tunnel through a mountain (the train could stop and back out).</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature">--<br>Broadus</div></div>
<br><div class="gmail_quote">On Thu, Mar 19, 2015 at 6:04 AM, anatoly techtonik <span dir="ltr"><<a href="mailto:techtonik@gmail.com" target="_blank">techtonik@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><a href="https://docs.python.org/2/library/collections.html#collections.deque" target="_blank">https://docs.python.org/2/library/collections.html#collections.deque</a><br>
<br>
The documentation is detailed, descriptive, but.. it fails to answer<br>
the main question - what is deque?<br>
<br>
"Deques are a generalization of stacks and queues (the name is<br>
pronounced “deck” and is short for “double-ended queue”). Deques<br>
support thread-safe, memory efficient appends and pops from either<br>
side of the deque with approximately the same O(1) performance in<br>
either direction."<br>
<br>
I must say that I came to the point where I don't get what that means.<br>
Explaining the concept of double-ended queue or circular buffer with<br>
words like "thread-safe" and "memory efficient" is not helpful.<br>
<span class="HOEnZb"><font color="#888888">--<br>
anatoly t.<br>
_______________________________________________<br>
docs mailing list<br>
<a href="mailto:docs@python.org">docs@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/docs" target="_blank">https://mail.python.org/mailman/listinfo/docs</a><br>
</font></span></blockquote></div><br></div>