December 16, 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.

December 16, 2014
On 2014-12-16 07:57:32 +0000, Tobias Pankrath said:

> 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.

I ran into the same issue with one of the other containers the other day.  It was causing me a substantial amount of confusion has it was automatically deallocating things I put into it for reasons I did not care to understand at the time.

-Shammah