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

Add std.ArrayList.remove #2247

Closed
daurnimator opened this issue Apr 10, 2019 · 4 comments · Fixed by #2262
Closed

Add std.ArrayList.remove #2247

daurnimator opened this issue Apr 10, 2019 · 4 comments · Fixed by #2262
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@daurnimator
Copy link
Contributor

There should be a function std.ArrayList.remove that moves fields down to fill the empty space.

It may be useful to add a backwards iterator at the same time.

@andrewrk andrewrk added this to the 0.5.0 milestone Apr 10, 2019
@andrewrk andrewrk added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library. labels Apr 10, 2019
@andrewrk
Copy link
Member

Hmm. That's not really advisable for a lot of use cases. It would at least have to have an awkward sounding name.

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Apr 11, 2019
@daurnimator
Copy link
Contributor Author

To be more specific, I need to filter an ArrayList to remove some values. In my case, I already know the indexes of the items to be removed.

We currently only have ArrayList.swapRemove, however I need to retain order.

@Tetralux
Copy link
Contributor

Tetralux commented May 2, 2019

Maybe orderedRemove or shiftRemove.
In Jai, this is called array_ordered_remove IIRC.

If you were gonna add remove though, I'd default it to swapRemove, for speed.

Maybe that means that I wouldn't add it and just have swapRemove and orderedRemove.

@andrewrk
Copy link
Member

andrewrk commented May 3, 2019

I like orderedRemove.

@andrewrk andrewrk added the accepted This proposal is planned. label May 3, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.5.0 Sep 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants