| 1 |
@safe unittest |
| 2 |
{ |
| 3 |
import std.container.slist; |
| 4 |
|
| 5 |
import std.algorithm.comparison : equal; |
| 6 |
import std.container : SList; |
| 7 |
|
| 8 |
auto s = SList!int(1, 2, 3); |
| 9 |
assert(equal(s[], [1, 2, 3])); |
| 10 |
|
| 11 |
s.removeFront(); |
| 12 |
assert(equal(s[], [2, 3])); |
| 13 |
|
| 14 |
s.insertFront([5, 6]); |
| 15 |
assert(equal(s[], [5, 6, 2, 3])); |
| 16 |
|
| 17 |
// If you want to apply range operations, simply slice it. |
| 18 |
import std.algorithm.searching : countUntil; |
| 19 |
import std.range : popFrontN, walkLength; |
| 20 |
|
| 21 |
auto sl = SList!int(1, 2, 3, 4, 5); |
| 22 |
assert(countUntil(sl[], 2) == 1); |
| 23 |
|
| 24 |
auto r = sl[]; |
| 25 |
popFrontN(r, 2); |
| 26 |
assert(walkLength(r) == 3); |
| 27 |
} |
| 28 |
|