digitalmars.D.bugs - [Issue 4348] New: std.container.SList append
- d-bugmail puremagic.com (30/30) Jun 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4348
- d-bugmail puremagic.com (12/12) Jun 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4348
- d-bugmail puremagic.com (17/17) Jun 19 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4348
- d-bugmail puremagic.com (9/9) Jun 20 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4348
http://d.puremagic.com/issues/show_bug.cgi?id=4348 Summary: std.container.SList append Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc This shows how you can append to a std.container.SList: import std.container: SList; void main() { auto l = SList!int(1, 2); l.insertAfter(l[], 3); } But the standard D syntax too can be supported, despite it's O(n): import std.container: SList; void main() { auto l = SList!int(1, 2); l ~= 3; } (The member function "insertFront" might be named "prepend", that is shorter , equally readable and contains no upper case letters). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4348 Andrei Alexandrescu <andrei metalanguage.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei metalanguage.com 14:51:02 PDT --- ~= is only for containers that can implement it in time independent of the size of the container. Writing s.insertAfter(s[], value) hints the user that the cost is higher (i.e. proportional to the length of s[]). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4348 Answer to Comment 1: thank you for your answer, I didn't know about this rule. In arrays the append can require a full array copy, so it can be O(n), but it's (hopefully) O(1) on amortized time. If this rule is present and well established then you can close this bug report (the suggestion about the "prepend" name is for you, but you can ignore it if you don't like it). Another possibility is to find a compromise: instead of writing something hairy like: s.insertAfter(s[], value) You can use: s.linearAppend(value) That is less noisy and equally clear in its complexity :-) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 19 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4348 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 20 2010