D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6957 - std.array.removeSlice
Summary: std.array.removeSlice
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: bootcamp
Depends on:
Blocks:
 
Reported: 2011-11-15 16:55 UTC by bearophile_hugs
Modified: 2024-12-01 16:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-11-15 16:55:49 UTC
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).
Comment 1 dlangBugzillaToGithub 2024-12-01 16:14:40 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9917

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB