Remove element from DList

cal callumenator at gmail.com
Sat Oct 6 17:47:23 PDT 2012


On Saturday, 6 October 2012 at 21:39:29 UTC, cal wrote:
> I'd like to remove a single element from a std.container.DList. 
> For that I need a range, but I'm not sure how to get a single 
> element 'range'.
>
> I thought something like this might work:
>
> auto list = DList!int([1,2,3,4]);
> auto r = list[];
> while(r.front != 3)
>    r.popFront;
>
> list.remove(r.take(1));
>
> But the the range returned by r.take(1) is not valid as an 
> argument to DList.remove. What is the correct way to do this?

One solution:
list.linearRemove(list[].find(3).takeOne);


More information about the Digitalmars-d-learn mailing list