Simple, efficient FIFO queue in Elixir?

359 views
Skip to first unread message

Joshua Petitt

unread,
Jan 30, 2016, 9:14:13 AM1/30/16
to elixir-lang-talk
Is there a simple, efficient FIFO queue in Elixir?

I have looked at using list with reverse, but I am (prematurely) worried about the reverse for a "large" list?

Is there a built-in FIFO queue for Elixir or Erlang that I can just use?  I need push, pop and peek functionality.

TIA

Darian Moody

unread,
Jan 30, 2016, 9:33:28 AM1/30/16
to elixir-lang-talk
Hi Joshua,

I think Erlang's queue type is what you are after: http://erlang.org/doc/man/queue.html

Simple drop down to Erlang to use it. (e.g :queue.function_name())

Darian

Ben Wilson

unread,
Jan 30, 2016, 9:33:34 AM1/30/16
to elixir-lang-talk

Joshua Petitt

unread,
Jan 30, 2016, 9:37:59 AM1/30/16
to elixir-lang-talk
Awesome, thank you!  I don't know how google didn't find this for me :-)

Joshua Petitt

unread,
Jan 30, 2016, 10:26:16 AM1/30/16
to elixir-lang-talk
Darian, this worked perfectly, thank you again

Ben Wilson

unread,
Jan 30, 2016, 10:29:37 AM1/30/16
to elixir-l...@googlegroups.com
As an aside, I highly recommend reading https://www.cs.cmu.edu/~rwh/theses/okasaki.pdf which outlines both the theoretical underpinnings of erlang's queue implementation as well as a variety of other data structures. That author is even referenced in the documentation of Erlang's queue.

On Sat, Jan 30, 2016 at 10:26 AM, Joshua Petitt <joshp...@gmail.com> wrote:
Darian, this worked perfectly, thank you again

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/i0SZoS6CpRU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/436e2d13-9ef6-4d1d-a03a-46cb0d18b8ec%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Joshua Petitt

unread,
Jan 30, 2016, 10:55:46 AM1/30/16
to elixir-lang-talk
Thanks Ben, I'll look at this tonight
Reply all
Reply to author
Forward
0 new messages