JuliaCollections / DataStructures.jl

Julia implementation of Data structures
https://juliacollections.github.io/DataStructures.jl/latest/
MIT License
679 stars 242 forks source link

Error on push! for Queue #902

Closed nguiard closed 3 months ago

nguiard commented 3 months ago

Hi, I'm getting:

julia> using DataStructures

julia> q = Queue{Int64}()
Queue{Int64}(Deque [Int64[]])

julia> push!(q, 1)
ERROR: MethodError: no method matching push!(::Queue{Int64}, ::Int64)

...

Julia 10.2, DataStructures 0.18.18. push! on Deque works, but fails on Queue. isempty works... Am I missing something?

nguiard commented 3 months ago

If I manually copy the function definition from queue.jl in the repl

function Base.push!(q::Queue, x)
    push!(q.store, x)
    return q
end

then try again, push! now works... Any idea? I'm quite confused

StephenVavasis commented 3 months ago

For DataStructures version 0.18 (stable current release), the function to add an item to a Queue is enqueue!. This is has been changed to push! in the DEV version of the package, which will become the stable version down the road. If you prefer to use push!, then upgrade to the DEV version via: ] at the REPL to enter Package mode, then add DataStructures#master.

nguiard commented 3 months ago

Oh! My bad, I was looking at the dev docs, effectively. Thanks and sorry for the inconvenience