I am working on implementing the Rope data structure in C++ for completely abstract objects. The problem I am having is that I can’t figure out the implementation of the critical “split” operation. The Wikipedia page is helpful, but vague and highly theoretical, and the images attached to the text do not help my understanding of the algorithm. Is there a good implementation, or a paper that provides sample code? I have tried reading the original papers, but they don’t really help either.
I am working on implementing the Rope data structure in C++ for completely abstract
Share
Suppose we have a rope structure like
If
leftis null, then the characters arestring[0], ..., string[length - 1]. Otherwise, the characters are the ones inleftfollowed by the ones inright. Leaving aside questions of storage management, the substring operation is