Open
Description
As suggested in this discourse discussion, I am bringing this issue here:
using DataStructures
import Base.isless
struct SEvent{F1}
callback::F1
time::Float64
end
function SEvent(callback::F1, time) where F1
SEvent{F1}(callback, time)
end
function isless(a::SEvent, b::SEvent)
isless(a.time, b.time)
end
Now I try to put SEvent
s into a heap:
s1 = SEvent(10) do x
4
end
s2 = SEvent(3) do x
5
end
a = MutableBinaryMinHeap{Any}() # Or try {SEvent}, the result will be the same
push!(a,s1)
This will cause an error:
ERROR: LoadError: MethodError: Cannot `convert` an object of type
DataStructures.MutableBinaryHeapNode{SEvent{var"#9#10"}} to an object of type
DataStructures.MutableBinaryHeapNode{Any}
Is there no way to put a parametrized struct into a parametrized container like a heap?
Activity