www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12123] New: heap.pop

https://d.puremagic.com/issues/show_bug.cgi?id=12123

           Summary: heap.pop
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is a split from Issue 5462 .

In code that uses the BinaryHeap I often use two lines of code like (note it
use removeFront and not popFront):

auto item = heap.front;
heap.removeFront;

So I suggest to add to BinaryHeap a handy member function pop() that does both
things:

auto item = heap.pop;

(In a dynamic array a pop() should call back+popBack, so it's a function
specialized for heaps.)

See also:

http://stackoverflow.com/questions/12600330/pop-back-return-value

http://ptgmedia.pearsoncmg.com/images/020163371x/supplements/Exception_Handling_Article.html

http://www.gotw.ca/gotw/008.htm

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