Apparently, there is no way to empty! a queue.
Doc for DataStructures.jl shows an empty! method for a stack, but not for a queue.
It is quite difficult to tell what sort of beast a queue is since it wraps dequeue.
When I display my queue in the REPL, the beginning looks like this:
What follows is an array (well, a vector) of the NamedTuples that have been enqueued.
The appears to get no way to get at that array.
What to do to empty it?
To move on, I switched to a vector as I don’t care about all the fancy semantics. It works.
You can iterate over it, so
collect(queue) works to get a copy of the queue as an array.
Normally, you don’t want to poke around in the internals of some other package’s data structure.
If you don’t need queue semantics, you definitely shouldn’t use a queue data structure.
empty! is definitively defined for a Queue object:
I had a function for empty!(df::DataFrame). This blocked the use of empty! from DataStructures. Should I have done import Base.empty! ?
Just asking. The array is adequate to the purpose.
I believe so. If you create a custom empty! for your data type then I believe can can do
function Base.empty!() to ensure you don’t hide the others.
No, because defining your own
Base.empty!(df::DataFrame) would be type piracy, and could easily conflict e.g. if the
DataFrames package decides to implement
Either call your function something else, or call
Base.empty!(queue) when you want to use the standard