From 0214ee81e63bd2eedf2b6e65580d3bf76e6f1eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 13 Feb 2026 16:23:07 +0100 Subject: [PATCH 1/2] Retu{=> r}n typo Sponsored-by: https://beaverlabs.net --- lib/qex.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/qex.ex b/lib/qex.ex index 011736e..15d8ae6 100644 --- a/lib/qex.ex +++ b/lib/qex.ex @@ -193,7 +193,7 @@ defmodule Qex do end @doc """ - Retun the first item in the queue, raise if it's empty + Return the first item in the queue, raise if it's empty iex> q1 = Qex.new 1..3 iex> Qex.first!(q1) @@ -224,7 +224,7 @@ defmodule Qex do end @doc """ - Retun the last item in the queue, raise if it's empty + Return the last item in the queue, raise if it's empty iex> q1 = Qex.new 1..3 iex> Qex.last!(q1) From 843e8b559df50e55d482914b560444366f637ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 13 Feb 2026 16:24:39 +0100 Subject: [PATCH 2/2] Add Qex.len(), forwarding to :queue.len() Sponsored-by: https://beaverlabs.net --- lib/qex.ex | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/qex.ex b/lib/qex.ex index 15d8ae6..84e8889 100644 --- a/lib/qex.ex +++ b/lib/qex.ex @@ -237,4 +237,17 @@ defmodule Qex do :empty -> raise "Queue is empty" end end + + @doc """ + Return the number of elements in the queue. + This operation takes linear time. + + iex> q1 = Qex.new 1..3 + iex> Qex.len(q1) + 3 + """ + @spec len(t) :: non_neg_integer + def len(%__MODULE__{data: q}) do + :queue.len(q) + end end