Skip to content

slices: add DeleteFunc #54768

Closed
Closed
@Deleplace

Description

@Deleplace

I propose we add this new func to golang.org/x/exp/slices :

// DeleteFunc removes any elements from s for which del returns true.
// DeleteFunc modifies the contents of the slice s; it does not create a new slice.
// When DeleteFunc removes m elements in total, it might not modify the elements s[len(s)-m:len(s)]. If 
// those elements contain pointers you might consider zeroing those elements so that objects they
// reference can be garbage collected.
func DeleteFunc[S ~[]E, E any](s S, del func(E) bool) S

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions