Why does std.container.BinaryHeap use RefCounted?

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 15 23:57:32 PST 2014


Original: 
http://forum.dlang.org/thread/uapqmdbtadpwnciwfdwn@forum.dlang.org
Reposting here, because I got no answer in D.learn:

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 mailing list