[Issue 4271] drop/pop methods for std.algorithm.BinaryHeap

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 4 15:40:23 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4271



--- Comment #2 from bearophile_hugs at eml.cc 2010-06-04 15:40:21 PDT ---
In most of my usages of a heap I don't have just to use the top item or just to
pop the top item, I have to pop the top item and then use the popped out item.

To perform this operation I can currently use something like:

item = heap.top();
heap.pop();

But this is not handy because that is not a single expression, so I can't put
it inside other expressions. So I have to use:

somefunction(heap.top(1)[0]);

But being this operation so common, I'd like to write simpler code:

somefunction(heap.top());

I have suggested to add the drop() method too to not decrease the performance
of the (uncommon) code that just needs to remove the top item with no need to
use it (or uses it using top() in other points of the code).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list