Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.array.removeSlice #9917

Open
dlangBugzillaToGithub opened this issue Nov 15, 2011 · 0 comments
Open

std.array.removeSlice #9917

dlangBugzillaToGithub opened this issue Nov 15, 2011 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2011-11-15T16:55:49Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=6957

CC List

Description

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).
@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants