auto myRope = Rope( Rope("Hello, "), Rope( Rope("Flu"), Rope("id"), ), ); assert(myRope.leafFrom(0) == Rope("Hello, ")); assert(myRope.leafFrom(7) == Rope("Flu")); assert(myRope.leafFrom(10) == Rope("id")); assert(myRope.leafFrom(2) == Rope("llo, ")); assert(myRope.leafFrom(7) == Rope("Flu")); assert(myRope.leafFrom(8) == Rope("lu")); assert(myRope.leafFrom(9) == Rope("u")); assert(myRope.leafFrom(myRope.length) == Rope.init);
Get a leaf node that is a subrope starting with the given index. The length of the node may vary, and does not have to reach the end of the rope.