1

I have a tree-like structure using Node objects with references to other Node objects. Node is a class. Now, one of the routines I'm writing needs a minimum priority queue, which I'm implementing using std.container.BinaryHeap and std.container.Array. I'm instantiating it as follows:

Node[] r;
auto heap = BinaryHeap!(Array!(Node), "a > b")(Array!Node(r));

As part of the routine, I insert elements into heap using insert and remove elements from it using removeAny. Now, the routine works correctly, but afterwards, the tree-like structure breaks (my invariants for it fail), due to nodes being missing. What's going on here and why is this happening?

Koz Ross
  • 3,040
  • 2
  • 24
  • 44

1 Answers1

1

could be http://d.puremagic.com/issues/show_bug.cgi?id=6998 - std.container.Array destroys class instances

Nils
  • 26
  • 1
  • This was reported in 2011-12 and *still* hasn't been addressed? That's a bit of a worry - I suspected that was the problem. Short of brute copying, is there any way around this? I'm using ``Array`` for ``BinaryHeap`` and no other reason, so is there a way I can avoid it? – Koz Ross Mar 29 '14 at 04:02
  • For anyone who is watching - it appears the issue was fixed about 14 days ago. – Koz Ross Apr 26 '14 at 00:38