Why does std.container.BinaryHeap use RefCounted?
Tobias Pankrath via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 9 07:12:03 PST 2014
std.container.BinrayHeap
(http://dlang.org/library/std/container/BinaryHeap.html)
implements a binary heap on top of a) a given random access range
or b) another container that supports random access.
Regardless of it's underlying data structure type, it wraps its
store in RefCounted, but I don't see why this is necessary.
In case b) the container itself uses reference counting, so
holding a simple reference to a container should be enough.
In case a) the given range might use ref counting under the hood,
see b). Or not, than it is probably relying on the GC, and no
reference count is needed.
More information about the Digitalmars-d-learn
mailing list