On Tue, 11 Oct 2011 13:29:02 -0400, kennytm <[email protected]> wrote:
"Steven Schveighoffer" <[email protected]> wrote:
Yes, I'd agree either remove's implementation or its constraint
specification are buggy. It should not specify that it needs a forward
range and then use bi-directional range primitives.
I think remove's constraint is fine. With a SList you don't really want
to
remove the current node, but the 'next' node. SList should provide the
O(1)
removeNext and insertNext functions (c.f. C++11's std::forward_list).
See the definition of std.algorithm.remove here:
https://github.com/D-Programming-Language/phobos/blob/master/std/algorithm.d#L5927
And see line 5956 which uses popBack on the range which is determined not
to be a bidirectional range.
Looking at the code, I'd say the bug is simply that remove is overloaded
for forward ranges. I'd remove this whole overload.
But your points on SList are valid -- a linked list of any kind that does
not support O(1) removal or insertion is DOA.
-Steve