DataStructures.jl
DataStructures.jl copied to clipboard
Add empty! for all Heaps
I would like an empty! method for all heap types. It is currently only defined for BinaryMinMaxHeap.
Compared to using extract_all!, an empty! method would not allocate a vector, which might be important for performance oriented applications.
Maybe an implementation could look like this:
function Base.empty!(h::AbstractHeap)
while !isempty(h)
pop!(h)
end
h
end