Deque
Fast bounded deque using two rotating lists.
Install / Use
/learn @discord/DequeREADME
Deque
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.
Features
- Bounded size
EnumerableprotocolCollectableprotocolInspectprotocol
Usage
Add it to mix.exs
defp deps do
[{:deque, "~> 1.0"}]
end
Then use it like other Elixir data structures.
# Deque<[3, 2, 1]>
deque =
Deque.new(5)
|> Deque.appendleft(1)
|> Deque.appendleft(2)
|> Deque.appendleft(3)
# Deque<[2, 1]>
{3, deque} = Deque.popleft(deque)
# Deque<[6, 7, 8, 9, 10]>
Enum.into(0..10, Deque.new(5))
License
Deque is released under the MIT License. Check LICENSE file for more information.
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
