On Sunday, 12 October 2014 at 09:45:22 UTC, Algo wrote:
DList seems to have an issue with remove:

void main()
{
    import std.container, std.range, std.algorithm;
    auto list = DList!int([1, 2, 4, 6]);
    auto res = find(list[], 2);
    list.remove(res); //ok
    /*
    list.remove(res.takeOne);
Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Result)
    list.remove(res.take(1));
Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Take!(Range))
    */
}

Are there any known workarounds besides linearRemove?

There is (unfortunatly) no support for takeOne in DList.

However, "linearRemove" is not a workaround or worst than remove. It is just that it accepts a wider range of input, when O(1) cannot be guaranteed. If you are operating with a range of length 1, then linearRemove is still O(1).

Reply via email to