Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
KACTL's current treap implementation lacks lazy propagation (IMO, quite an important feature). Adding this is nontrivial if you don't understand the implementation. I chose to add reverse interval, as it is not uncommon, nontrivial and requires little code.
In order to reduce code size, I implemented the treap as described in cp-algorithms.
Some stats:
Runs in 0.74 on substring reversals. code
Runs in 0.66 on cut and paste if we don't push, code. 0.73 if we do push.
Runs in 0.65 with the old implementation.
So performance seems to be basically the same. It may be harder to understand because of return-by-reference, but I think it should be understandable by the comments and sample usages.
If you use the treap as a set, merge has a precondition that max_val(l) < min_val(r). Should we use a line to include that comment?
If you want, I can codegolf away 2 lines related to rev without hurting readability too much.