Closed hawkw closed 7 years ago
One way to do this that springs initially to mind is to create an unbalanced branch as the root node, rather than a leaf, and then call .rebalance()
on it. If we were to, say, put the whole string in the left child of a branch and then rebalance that node immediately, we'd end up with a nice, balanced tree using our already existing .rebalance()
method.
Of course, this may not be the best way to do this, but it was the obvious way, to me.
@cjm00, what do you think?
Currently, when we create a new Rope from a String, we put the whole string in one
Leaf
node. That means that indexing-based operations will initially have roughly the same time overhead as indexing a String, and we won't see performance improvements until the Rope has beenappend
ed orinsert
ed into enough to turn it into a nice tree structure. We might want to consider having theRope::from<String>
implementation split the string into chunks so that we can reap Rope performance benefits immediately.