queue container?
Steven Schveighoffer
schveiguy at yahoo.com
Fri Oct 28 18:55:56 PDT 2011
On Thu, 27 Oct 2011 22:52:33 -0400, J Arrizza <cppgent0 at gmail.com> wrote:
> (BTW, as great as this thread has gone, I was wondering if someone could
> answer my original question about using existing Array container for a
> queue?)
Using an array of any type as a queue is going to be awkward.
I'd recommend using a linked list or a deque. Both are available via
dcollections, though using dcollections' deque as a queue is equivalent to
using an array because of the implementation. SList is not suited for a
queue, since you cannot have O(1) addition on one end and O(1) removal on
the other.
It's also quite trivial to roll your own linked list-based queue.
-Steve
More information about the Digitalmars-d
mailing list