[Issue 12563] New: std.container.SList.reverse
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 11 17:50:58 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12563
Issue ID: 12563
Summary: std.container.SList.reverse
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I suggest to add to std.container.SList a method that reverses the list
in-place efficiently (O(n) and with no or nearly no memory allocations),
equivalent to this functions that reverses a singly linked list:
Node* reverse(Node* s1) pure nothrow {
Node* s2;
while (s1) {
auto next = s1.next;
s1.next = s2;
s2 = s1;
s1 = next;
}
return s2;
}
--
More information about the Digitalmars-d-bugs
mailing list