Subject: Re: [boost] [review] Heaps: Mergeable Heaps
From: BernardH (boost-dev.ml_at_[hidden])
Date: 2011-06-06 04:21:56
Andrew Sutton <asutton.list <at> gmail.com> writes:
> > the current Heap::merge() and Heap::merge_and_clear() are somewhat odd ...
> > thoughts?
> So... taking a quick look, we shouldn't call the operation merge(), we
> should call it heap_merge() to avoid ADL issues with std::merge. We
> don't want to break merge_sort :) I see two algorithms:
> void heap_merge(Heap1& lhs, Heap2& rhs);
> void heap_union(const Heap1& lhs, const Heap2& rhs, Heap3& result);
> The first transfers all objects owned by rhs into lhs. I think that's
> important. The second is more like std::merge (but without iterators).
> Obviously, there should be specializations for Mergeable heaps.
FWIW, I also found Heap::merge() and Heap::merge_and_clear() Â«somewhat oddÂ» and
was left wondering why not overload ::insert() (which copies elements from a
source) and reuse splice() name from std::list<> which moves nodes from one
container to the other.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk