Skip to content
Fast bounded deque using two rotating lists.
Branch: master
Clone or download
Latest commit 49076ec Jun 21, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench Add best and average case. Sep 11, 2017
test Deque.take_while/2 Sep 11, 2017
.gitignore Deque.take_while/2 Sep 11, 2017
.travis.yml Updated build versions Jun 20, 2018
LICENSE Initial commit Feb 15, 2017 update readme Jun 21, 2018
mix.exs Bumped version to 1.2.0 Jun 20, 2018
mix.lock Upgrade benchfella dependency May 1, 2018


Master Version

Erlang only supports fast prepends to lists while appending requires a full copy. Getting the size of a list is also a O(n) operation. This library implements a deque using two rotating lists to support fast append and prepend as well as O(1) size via an internal counter.


  • Bounded size
  • Enumerable protocol
  • Collectable protocol
  • Inspect protocol


Add it to mix.exs

defp deps do
  [{:deque, "~> 1.0"}]

Then use it like other Elixir data structures.

# Deque<[3, 2, 1]>
deque =
  |> Deque.appendleft(1)
  |> Deque.appendleft(2)
  |> Deque.appendleft(3)

# Deque<[2, 1]>
{3, deque} = Deque.popleft(deque)

# Deque<[6, 7, 8, 9, 10]>


Deque is released under the MIT License. Check LICENSE file for more information.

You can’t perform that action at this time.