[Issue 6957] New: std.array.removeSlice
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 15 16:56:34 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6957
Summary: std.array.removeSlice
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-11-15 16:55:49 PST ---
This is a spin off of bug 6849.
I suggest to introduce a function std.array.removeSlice (or a similar name).
It is similar to std.algorithm.remove, with some differences:
- It works on dynamic arrays.
- It works in-place, so unlike remove it changes the array "topology".
- it removes a slice, instead one or more indexes (but it's good to have an
overload that remove a single item).
Why it's useful:
- Removing items from dynamic arrays is a common operation.
- The semantics of std.algorithm.remove (that leaves the input array in a wrong
state) is bug prone and surprising for programmers coming from Python and other
languages.
- Removing whole slices is handy and can't be done with a single line of code
because D slice assignments don't support overlapping slices (they use memcpy
instead of memmove).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list