If the first element of the Range passed to linearRemove(Take!Range r) is the SList root element all elements of Range are removed, not only the elements of Take!Range.
Test case:
import std.container;
import std.range;
void main()
{
auto s = SList!int(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
auto r = s[];
auto r1 = take(r, 4);
assert(equal(r1, [1, 2, 3, 4]));
auto r2 = s.linearRemove(r1);
assert(s == SList!int(5, 6, 7, 8, 9, 10)); //fails
}
Solution:
In the linearRemove(Take!Range r) function
Range linearRemove(Take!Range r)
{
auto orig = r.original;
// We have something to remove here
if (orig._head == _root)
{
// remove straight from the head of the list
for (; !orig.empty; orig.popFront())
The for line needs to be changed to:
for (; !r.empty; r.popFront())
Comment #1 by ellery-newcomer — 2012-07-23T14:25:04Z