Closed HaoxuanGuo closed 7 months ago
No methods matching push! for Queue.
push!
Queue
❯ julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.10.1 (2024-02-13) _/ |\__'_|_|_|\__'_| | Built by Homebrew (v1.10.1) |__/ | julia> using DataStructures julia> q = Queue{Int}() Queue{Int64}(Deque [Int64[]]) julia> push!(q, 1) ERROR: MethodError: no method matching push!(::Queue{Int64}, ::Int64) Closest candidates are: push!(::Any, ::Any, ::Any) @ Base abstractarray.jl:3413 push!(::Any, ::Any, ::Any, ::Any...) @ Base abstractarray.jl:3414 push!(::Vector{Any}, ::Any) @ Base array.jl:1125 ... Stacktrace: [1] top-level scope @ REPL[3]:1 julia>
You can only add elements to the start of a Queue, so use pushfirst!
pushfirst!
If you want to be able to push onto either end use a Deque.
Deque
We should register an error hint for this
Thank you for your help.
No methods matching
push!
forQueue
.