SList: How do I use linearRemove?

sigod via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 26 08:51:06 PDT 2014


Take a look at unittests in [std.container.slist][0]:

```
unittest
{
     auto s = SList!int(1, 2, 3, 4, 5);
     auto r = s[];
     popFrontN(r, 3);
     auto r1 = s.linearRemove(r);
     assert(s == SList!int(1, 2, 3));
     assert(r1.empty);
}

unittest
{
     auto s = SList!int(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
     auto r = s[];
     popFrontN(r, 3);
     auto r1 = take(r, 4);
     assert(equal(r1, [4, 5, 6, 7]));
     auto r2 = s.linearRemove(r1);
     assert(s == SList!int(1, 2, 3, 8, 9, 10));
     assert(equal(r2, [8, 9, 10]));
}
```

[0]: 
https://github.com/D-Programming-Language/phobos/blob/master/std/container/slist.d#L575


More information about the Digitalmars-d-learn mailing list