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.
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
mergeshould 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.