queue container?
Gor Gyolchanyan
gor.f.gyolchanyan at gmail.com
Wed Oct 26 00:18:27 PDT 2011
The best implementation of queue IMO is using a doubly-linked list,
which is missing from Phobos.
I wanted ti implement a thread-safe queue too, but i failed due to the
lack of appropriate lists.
On Wed, Oct 26, 2011 at 6:38 AM, J Arrizza <cppgent0 at gmail.com> wrote:
> I need a Queue (put on the front and pop from the back). The best I can
> come up with so far is:
> Array!string list;
> list.insertBack("a1");
> list.insertBefore(list.opSlice(0,1), "a2");
> list.insertBefore(list.opSlice(0,1), "a3");
> list.insertBefore(list.opSlice(0,1), "a4");
> list.insertBefore(list.opSlice(0,1), "a5");
> while (!list.empty())
> {
> string s = list.back();
> list.removeBack();
> writeln("x: ", s);
> }
> Having to insertBack when the list empty and insertBefore with the range,
> seems strange to me. Is there a better way?
> John
>
>
>
>
More information about the Digitalmars-d
mailing list