--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/6da32317-b3d4-439c-9ded-21786188179e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Performance is really key here. It's difficult to make a general purpose immutable queue that performs well in most situations. It's not too difficult to make a decent queue that fits one use case. The result is that if you need a queue, you build it for your specific use case. If performance doesn't matter, using a list (pop and append) works in a pinch.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K2yyayMRV-y3Tia9bQkYNAhECMybQpYHyU29hiqcsnJA%40mail.gmail.com.
I love queues as a data structure. Erlang provides the :queue module and that's what you use in Elixir, but the API for :queue is "meh" at best. It's queue-as-a-last-argument, it has three different APIs (original, extended, Okasaki) and it's just not Elixir-y. I think queues make great candidates for an additional collection type in the Elixir standard library, so I propose to add a Queue module to the stdlib. The API for Queue that I imagined goes something like this:
I cleaned up the code, fixed some ordering issues (yesterday's version behaved by default more like a stack than a queue), optimized the Enumerable implementation, borrowed Andrea's implementation for the Inspect protocol, which is much better that my initial quick and dirty implementation, and largely adopted Andrea's suggestions for names, as I think they're better that the names I initially picked. I only kept 'pop' instead of 'get' as I think 'get' doesn't explain that the element will be removed from the queue.
Andrea and all, do you have any other suggestions for my current implementation?
-vincent