Bug 6959 – std.container's BinaryHeap doesn't work with Array!(T)
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-16T06:27:00Z
Last change time
2011-11-16T07:07:07Z
Assigned to
nobody
Creator
zetetyck
Comments
Comment #0 by zetetyck — 2011-11-16T06:27:06Z
The documentation of BinaryHeap in std.container says that:
"If Store is a range, the BinaryHeap cannot grow beyond the size of that range. If Store is a container that supports insertBack, the BinaryHeap may grow by adding elements to the container."
But the Array!(T) container, which does have a insertBack() method, can't be used with a BinaryHeap, as the following code:
import std.container;
void main() {
auto array = Array!(int)();
auto heap = heapify(array);
//auto heap = BinaryHeap!(Array!(int))(array); // gives same error
}
Gives the following compilation error:
\phobos\std\container.d(2660): Error: this._store()[this._length()] is not an lvalue
This happens to make growable BinaryHeaps impossible using only Phobos containers.
Comment #1 by zetetyck — 2011-11-16T07:07:07Z
*** This issue has been marked as a duplicate of issue 5998 ***