Skip to content

Commit

Permalink
VIP - Add join_to_list for :queue
Browse files Browse the repository at this point in the history
  • Loading branch information
shahryarjb committed May 6, 2024
1 parent a937051 commit dcc7ad0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/modules/queue_assistant.ex
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ defmodule QueueAssistant do
# [2, 3, 4, 5]
```
"""
@spec out(queue_type()) :: {:empty | {:value, any()}, queue_type()}
@dialyzer {:nowarn_function, out: 1}
@spec out(queue_type()) :: {:empty, {[], []}} | {{:value, any()}, queue_type()}
def out(queue) do
:queue.out(queue)
end
Expand Down Expand Up @@ -607,6 +608,15 @@ defmodule QueueAssistant do
:queue.peek_r(queue)
end

@doc """
Please see `join/2` and `to_list/1`.
"""
@spec join_to_list(queue_type(), queue_type()) :: list(any())
def join_to_list(queue, queue1) do
:queue.join(queue, queue1)
|> :queue.to_list()
end

# The "Okasaki API" is inspired by "Purely Functional Data Structures" by Chris Okasaki.
# It regards queues as lists. This API is by many regarded as strange and avoidable.
# For example, many reverse operations have lexically reversed names, some with more
Expand Down

0 comments on commit dcc7ad0

Please sign in to comment.