茱莉亚流行音乐!为 PriorityQueue 抛出错误

Julia popfirst! is throwing error for PriorityQueue

提问人:Vinod 提问时间:9/2/2023 更新时间:9/2/2023 访问量:33

问:

using DataStructures
x = PriorityQueue(Base.Order.Forward, "a" => 2, "b" => 3, "c" => 1)
Base.popfirst!(x)

正在抛出错误

ERROR: MethodError: no method matching popfirst!(::PriorityQueue{String, Int64, Base.Order.ForwardOrdering})
Closest candidates are:
  popfirst!(::OrderedSet) at C:\Users\Vinod\.julia\packages\OrderedCollections\SInLM\src\ordered_set.jl:58
  popfirst!(::AbstractChannel) at channels.jl:11
  popfirst!(::CircularDeque) at C:\Users\Vinod\.julia\packages\DataStructures\MKv4P\src\circ_deque.jl:91
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[34]:1

所有其他方法似乎都有效。

数据结构

Julia 优先级队列

评论


答:

2赞 Sundar R 9/2/2023 #1

这是开发中版本的文档(您可以在侧边栏的左下角看到“版本 [dev]”)。因此,将在 DataStructures 的下一个版本中提供(除非该决定因某种原因而改变 - 因为它仍然是一个开发中的版本)。popfirst!

要访问当前版本的文档,您可以单击左下角的该框并选择(或者,如果您出于某种原因使用旧版本的 DataStructures,请改为选择该版本)。对于当前的稳定版本,您可以使用 或 代替:[dev]stabledequeue_pair!dequeue!popfirst!

dequeue!(pq)              # remove and return the lowest priority key
dequeue_pair!(pq)         # remove and return the lowest priorty key and value

https://juliacollections.github.io/DataStructures.jl/stable/priority-queue/#Priority-Queue-1 相比