[Issue 8772] DList.remove doesn't work with result of std.range.take

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 7 07:49:24 PDT 2014


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


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra at gmail.com
         Resolution|                            |INVALID


--- Comment #3 from monarchdodra at gmail.com 2014-04-07 07:49:12 PDT ---
This is invalid, as "remove" is a "O(1)" operation, but removing a Take!Range
is linear operation. So that's an invalid argument.

The correct way to remove a Take!Range, is to use the linear removal function:
linearRemove:

//----
import std.range, std.algorithm, std.container;

void main()
{
    auto list = DList!int([1,2,3,4,5]);
    list.linearRemove(list[].find(3).take(1));
}
//----

Well, that's how it is right now anyways. If/when DList will have deterministic
ownership of its elements, things could change, since it would have to call
destructor on the removed elements...

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


More information about the Digitalmars-d-bugs mailing list