Skip to content

binary_search and partition_point on Slice #281

@Eh2406

Description

@Eh2406

Would it be possible to add binary_search and partition_point and friends on Slice?

Particular use case I have is an optimization of retain. I currently have index_map.retain(|_, v| foo(&*v) < bar) which works correctly. I happen to know that this index_map is sorted by foo(&*v). I think it would be more efficient to do let cut = index_map.partition_point(foo(&*v) < bar); index_map.truncate(cut) (adjusted for off by one errors). But did not see the tools to do so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions