Admittedly, the following sort of works:
size = 2^10;
randData = k /@ RandomInteger[size, size];
AbsoluteTiming[Fold[
ResourceFunction["IndexedQueue"][
heap, #2, "Remove"] &,
Fold[
ResourceFunction["IndexedQueue"][
heap, #2, "Enqueue"] &,
Clear[heap];
heap = ResourceFunction["IndexedQueue"][{
"InitialSize" -> Length[randData],
"NullElement" -> Missing[],
"ComparisonFunction" -> Greater}, {},
"Initialize"],
randData],
RandomSample[Range[size]][[1 ;; size]]
]];
ResourceFunction["IndexedQueue"][heap, "EmptyQ"]
Out[]= True
Even though, obviously:
DeleteCases[heap[[1]], Alternatives[Missing[], -1]]
Out[] ={k[954], k[615]}
Possibly this is just "multicomputational junk", meaning path-dependent artifacts, which are left over from the insert / delete process, have no inherent meaning, and shouldn't be there for optimization reasons.