http://d.puremagic.com/issues/show_bug.cgi?id=5011
Summary: std.container: SList linearRemove produces wrong results Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: johannesp...@gmail.com --- Comment #0 from Johannes Pfau <johannesp...@gmail.com> 2010-10-07 10:32:11 PDT --- 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()) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------