Skip to content

Add a min heap option to PriorityQueue #15947

Closed
@treeman

Description

@treeman

Currently PriorityQueue defaults to a max-heap and if you want to use it as a min-heap you need to overload Ord and change the comparison.

But you should be able to use the default ordering and simply specify that you want a min-heap, so we can use it for types like (uint, &str) for example.

The simple idea would be to simply make a new_min_heap and a min_heap_with_capacity constructors.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions