Skip to content

Add new elements to UnionFind #729

@ABorgna

Description

@ABorgna

Summary

Add a UnionFind::insert(&mut self) -> K method that adds a new element, in its own disjoint set.

Motivation

UnionFind currently requires the number of elements to be set during initialization. Some algorithms may dynamically generate new items at runtime, so they would benefit from having such function (instead of over-allocating to some maximum element count if any).

We could optionally add with_capacity/len/is_empty too.

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