www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Heap question

reply bearophile <bearophileHUGS lycos.com> writes:
I'd like to create an empty heap, and then add to it an arbitrary (and
statically unknown) number of items, keeping the heap invariant valid all the
time (this means the heap invariant is valid after each item is added to the
heap, so I am free to pop items in any moment). Do you know if this is possible
(and how) with the heap of std.container?

Bye,
bearophile
Aug 13 2011
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 08/13/2011 03:44 PM, bearophile wrote:
 I'd like to create an empty heap, and then add to it an arbitrary (and
statically unknown) number of items, keeping the heap invariant valid all the
time (this means the heap invariant is valid after each item is added to the
heap, so I am free to pop items in any moment). Do you know if this is possible
(and how) with the heap of std.container?

 Bye,
 bearophile
I think you cannot, which would clearly be a bug. The fact that it even does not work with std.container.Array as the underlying storage is probably a bug in either std.container or DMD. Another thing that needs fixing is that std.container does not implement the container interface for built-in arrays.
Aug 13 2011