Skip to content

BTreeSet and BTreeMap append optimization #34666

@xosmig

Description

@xosmig

When the largest key of one tree is less than the smallest key of another tree, there is a way to merge trees using only O(log n) operations.
Maybe logarithmic merge should be a separate method.
I'm ready to work on it.

UPD:
Also sometimes it may be better to push elements of one tree to another one with O(min_length log(max_length)) operations instead of rebuild with O(n + m) operations (like in #32526).

But the problem is that it's hard to determine which approach is better in a particular case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`C-enhancementCategory: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions