Knowledge

Rope (data structure)

Source 📝

3094:. Array-based strings have smaller overhead, so (for example) concatenation and split operations are faster on small datasets. However, when array-based strings are used for longer strings, time complexity and memory use for inserting and deleting characters becomes unacceptably large. In contrast, a rope data structure has stable performance regardless of data size. Further, the space complexity for ropes and arrays are both O(n). In summary, ropes are preferable when the data is large and modified often. 20: 1774: 1949: 1555: 3141: 1765:) and go to the right child (D). Then because 6 is greater than 1 and there's a left child, go to the left child (G). 2 is greater than 1 and there's a left child, so go to the left child again (J). Finally 2 is greater than 1 but there is no left child, so the character at index 1 of the short string "na" (ie "n") is the answer. (1-based index) 3075:
Greater overall space use when not being operated on, mainly to store parent nodes. There is a trade-off between how much of the total memory is such overhead and how long pieces of data are being processed as strings. The strings in example figures above are unrealistically short for modern
71:. A node with two children thus divides the whole string into two parts: the left subtree stores the first part of the string, the right subtree stores the second part of the string, and a node's weight is the length of the first part. 1761:
in Figure 2.1 shown on the right, start at the root node (A), find that 22 is greater than 10 and there is a left child, so go to the left child (B). 9 is less than 10, so subtract 9 from 10 (leaving
2088:
The second case reduces to the first by splitting the string at the split point to create two new leaf nodes, then creating a new node that is the parent of the two component strings.
2833: 3276: 2592: 2070: 1933: 1875: 1612: 1325: 1836: 2091:
For example, to split the 22-character rope pictured in Figure 2.3 into two equal component ropes of length 11, query the 12th character to locate the node
51:
program may use a rope to represent the text being edited, so that operations such as insertion, deletion, and random access can be done efficiently.
3368: 3701: 3120:, a data structure commonly used in text editors that allows efficient insertion and deletion operations clustered near the same location 3596: 3050:
Ropes enable much faster insertion and deletion of text than monolithic string arrays, on which operations have time complexity O(n).
3635: 3209: 3561: 3151: 3181: 3566: 91: 2115:. Travel up the tree and remove any right links to subtrees covering characters past position 11, subtracting the weight of 3571: 3188: 2616:-th character respectively, which extracts the string to delete in a separate node. Then concatenate the other two nodes. 3293: 3782: 3556: 3650: 3591: 3463: 3195: 3498: 3335: 3818: 3339: 3177: 3678: 3349: 3166: 3409: 3683: 3538: 3427: 3382: 3104: 3762: 3488: 3436: 1940:
As most rope operations require balanced trees, the tree may need to be re-balanced after concatenation.
3767: 3645: 3612: 3548: 3391: 3325: 3777: 3673: 3617: 3518: 3472: 3060: 2146:
As most rope operations require balanced trees, the tree may need to be re-balanced after splitting.
83: 44: 3053:
Ropes do not require O(n) extra memory when operated upon (arrays need that for copying operations).
3772: 3576: 3508: 3249: 3721: 3202: 2797: 67:), and each node further up the tree holds the sum of the lengths of all the leaves in its left 47:
that is used to efficiently store and manipulate longer strings or entire texts. For example, a
3405: 3162: 2562: 2040: 1903: 1891:, which is constant time. The weight of the parent node is set to the length of the left child 1845: 1582: 1295: 3813: 3668: 3528: 3456: 126:. Traverse down the left-most spine of the tree until you reach a leaf l', adding each node 3533: 3076:
architectures. The overhead is always O(n), but the constant can be made arbitrarily small.
28: 1812: 8: 3731: 2081:
The split point is at the end of a string (i.e. after the last character of a leaf node)
3660: 3627: 2910: 87: 3792: 3111: 3414: 3158: 3787: 3757: 3711: 3513: 3449: 3268: 3063:. For the text editing program example, this leads to an easy support for multiple 75: 3640: 3581: 3493: 3693: 3586: 40: 3807: 3503: 3480: 3301: 79: 3331:"C cords" implementation of ropes within the Boehm Garbage Collector library 74:
For rope operations, the strings stored in nodes are assumed to be constant
3706: 3523: 3378: 3272: 48: 142:) is at the top of the stack. Repeat the procedure for p's right subtree. 3716: 3358: 3123: 1883:
A concatenation can be performed simply by creating a new root node with
60: 3396: 63:
where each leaf (end node) holds a string and a length (also known as a
3387: 3117: 3107:
programming environment, which used ropes "almost since its inception"
19: 3423: 3418: 1773: 1624: 3373: 3354: 3140: 1948: 1554: 3330: 3059:
If only nondestructive versions of operations are used, rope is a
3752: 3345: 3267:(12). New York, NY, USA: John Wiley & Sons, Inc.: 1315–1330. 3247: 106:
is the length of the rope, that is, the weight of the root node.
68: 90:
attached for deallocation when no longer needed, although other
3248:
Boehm, Hans-J; Atkinson, Russ; Plass, Michael (December 1995).
3363: 3326:"absl::Cord" implementation of ropes within The Abseil library 23:
A simple rope built on the string of "Hello_my_name_is_Simon".
3400: 1777:
Figure 2.2: Concatenating two child ropes into a single rope.
2127:, in this case). Finally, build up the newly orphaned nodes 3736: 3064: 3441: 3432: 3254: 3082:
Increased complexity of source code; greater risk of bugs
2135:
by concatenating them together and creating a new parent
3126:, another data structure commonly used in text editors 2608:
operation. First, split the rope in three, divided by
78:
in the typical nondestructive case, allowing for some
3090:
traits of string and rope implementations, not their
2800: 2565: 2043: 1906: 1848: 1815: 1585: 1298: 3056:
Ropes do not require large contiguous memory spaces.
2924: 2827: 2586: 2064: 1927: 1869: 1830: 1606: 1319: 2139:with weight equal to the length of the left node 3805: 82:behavior. Leaf nodes are usually implemented as 3114:, a similar data structure from the early 1970s 1558:Figure 2.1: Example of index lookup on a rope. 1341:operations. The cost is the sum of the three. 3457: 2095:at the bottom level. Remove the link between 2084:The split point is in the middle of a string. 2077:There are two cases that must be dealt with: 3167:introducing citations to additional sources 3079:Increase in time to manage the extra storage 3464: 3450: 3636:Comparison of regular-expression engines 3157:Relevant discussion may be found on the 1947: 1772: 1553: 622:and rebuild the tree from the bottom-up. 18: 3243: 3241: 3239: 3237: 3235: 3806: 1757:For example, to find the character at 3597:Zhu–Takaoka string matching algorithm 3445: 1952:Figure 2.3: Splitting a rope in half. 3288: 3286: 3232: 3134: 3562:Boyer–Moore string-search algorithm 3004:O(1) amortized, O(log n) worst case 2971:O(1) amortized, O(log n) worst case 2119:from their parent nodes (only node 1569:: return the character at position 13: 3250:"Ropes: an Alternative to Strings" 2600:This operation can be done by two 16:Data structure for storing strings 14: 3830: 3651:Nondeterministic finite automaton 3592:Two-way string-matching algorithm 3319: 3283: 3261:Software: Practice and Experience 2925:Comparison with monolithic arrays 109: 3279:from the original on 2020-03-08. 3150:relies largely or entirely on a 3139: 3007:O(1) amortized, O(n) worst case 1879:time to compute the root weight) 1333:This operation can be done by a 3336:SGI C++ specification for ropes 2875: 1937:time, if the tree is balanced. 1762: 1758: 3567:Boyer–Moore–Horspool algorithm 3557:Apostolico–Giancarlo algorithm 3294:"Rope Implementation Overview" 2822: 2804: 2581: 2569: 2059: 2047: 1922: 1910: 1864: 1852: 1825: 1819: 1601: 1589: 1314: 1302: 102:In the following definitions, 54: 1: 3130: 97: 94:methods can be used as well. 3572:Knuth–Morris–Pratt algorithm 3499:Damerau–Levenshtein distance 3032: 3021: 3010: 2999: 2988: 2979:Iterate over each character 2977: 2966: 2955: 2944: 609: 7: 3763:Compressed pattern matching 3489:Approximate string matching 3471: 3097: 2828:{\displaystyle O(j+\log N)} 2107:and subtract the weight of 1627:search from the root node: 10: 3835: 3768:Longest common subsequence 3679:Needleman–Wunsch algorithm 3549:String-searching algorithm 3369:String-Like Ropes for Java 3338:(supported by STLPort and 3178:"Rope" data structure 1623:-th character, we begin a 618:Collect the set of leaves 84:basic fixed-length strings 3778:Sequential pattern mining 3745: 3692: 3659: 3626: 3618:Commentz-Walter algorithm 3606:Multiple string searching 3605: 3547: 3539:Wagner–Fischer algorithm 3479: 3061:persistent data structure 2752: 2587:{\displaystyle O(\log N)} 2474: 2065:{\displaystyle O(\log N)} 1928:{\displaystyle O(\log N)} 1870:{\displaystyle O(\log N)} 1788:: concatenate two ropes, 1768: 1607:{\displaystyle O(\log N)} 1320:{\displaystyle O(\log N)} 1224: 3788:String rewriting systems 3773:Longest common substring 3684:Smith–Waterman algorithm 3509:Gestalt pattern matching 3086:This table compares the 2618: 2148: 1943: 1629: 1549: 1343: 625: 145: 3722:Generalized suffix tree 3646:Thompson's construction 2486:: delete the substring 1248:, to form a new string 3819:String data structures 3674:Hirschberg's algorithm 3273:10.1002/spe.4380251203 2829: 2588: 2103:. Go to the parent of 2066: 1953: 1929: 1871: 1832: 1778: 1608: 1559: 1321: 1240:beginning at position 24: 3529:Levenshtein automaton 3519:Jaro–Winkler distance 2840:To report the string 2830: 2589: 2513:to form a new string 2067: 1967:into two new strings 1951: 1930: 1872: 1833: 1802:, into a single rope. 1776: 1609: 1557: 1322: 22: 3577:Rabin–Karp algorithm 3534:Levenshtein distance 3374:Ropes for JavaScript 3163:improve this article 2878:, and then traverse 2798: 2764:: output the string 2563: 2041: 1904: 1846: 1831:{\displaystyle O(1)} 1813: 1583: 1296: 1236:: insert the string 138:. The parent of l' ( 59:A rope is a type of 43:composed of smaller 29:computer programming 3732:Ternary search tree 2931: 2111:from the weight of 1963:: split the string 1898:, which would take 199:InOrderRopeIterator 154:InOrderRopeIterator 3661:Sequence alignment 3628:Regular expression 2929: 2911:in-order traversal 2825: 2584: 2062: 1954: 1925: 1867: 1828: 1779: 1604: 1560: 1317: 721:FIBONACCI_SEQUENCE 685:FIBONACCI_SEQUENCE 92:garbage collection 25: 3801: 3800: 3793:String operations 3228: 3227: 3213: 3044: 3043: 2917:starting at node 2882:starting at node 2876:weight(u) >= j 76:immutable objects 3826: 3758:Pattern matching 3712:Suffix automaton 3514:Hamming distance 3466: 3459: 3452: 3443: 3442: 3313: 3312: 3310: 3309: 3300:. Archived from 3290: 3281: 3280: 3258: 3245: 3223: 3220: 3214: 3212: 3171: 3143: 3135: 3112:Model T enfilade 2932: 2928: 2908: 2877: 2863:, find the node 2862: 2836: 2834: 2832: 2831: 2826: 2791:Time complexity: 2786: 2763: 2748: 2745: 2742: 2739: 2736: 2733: 2730: 2727: 2724: 2721: 2718: 2715: 2712: 2709: 2706: 2703: 2700: 2697: 2694: 2691: 2688: 2685: 2682: 2679: 2676: 2673: 2670: 2667: 2664: 2661: 2658: 2655: 2652: 2649: 2646: 2643: 2640: 2637: 2634: 2631: 2628: 2625: 2622: 2607: 2603: 2595: 2593: 2591: 2590: 2585: 2556:Time complexity: 2551: 2508: 2485: 2470: 2467: 2464: 2461: 2458: 2455: 2452: 2449: 2446: 2443: 2440: 2437: 2434: 2431: 2428: 2425: 2422: 2419: 2416: 2413: 2410: 2407: 2404: 2401: 2398: 2395: 2392: 2389: 2386: 2383: 2380: 2377: 2374: 2371: 2368: 2365: 2362: 2359: 2356: 2353: 2350: 2347: 2344: 2341: 2338: 2335: 2332: 2329: 2326: 2323: 2320: 2317: 2314: 2311: 2308: 2305: 2302: 2299: 2296: 2293: 2290: 2287: 2284: 2281: 2278: 2275: 2272: 2269: 2266: 2263: 2260: 2257: 2254: 2251: 2248: 2245: 2242: 2239: 2236: 2233: 2230: 2227: 2224: 2221: 2218: 2215: 2212: 2209: 2206: 2203: 2200: 2197: 2194: 2191: 2188: 2185: 2182: 2179: 2176: 2173: 2170: 2167: 2164: 2161: 2158: 2155: 2152: 2073: 2071: 2069: 2068: 2063: 2034:Time complexity: 2029: 2003: 1962: 1936: 1934: 1932: 1931: 1926: 1890: 1886: 1878: 1876: 1874: 1873: 1868: 1839: 1837: 1835: 1834: 1829: 1806:Time complexity: 1787: 1764: 1760: 1753: 1750: 1747: 1744: 1741: 1738: 1735: 1732: 1729: 1726: 1723: 1720: 1717: 1714: 1711: 1708: 1705: 1702: 1699: 1696: 1693: 1690: 1687: 1684: 1681: 1678: 1675: 1672: 1669: 1666: 1663: 1660: 1657: 1654: 1651: 1648: 1645: 1642: 1639: 1636: 1633: 1619:To retrieve the 1615: 1613: 1611: 1610: 1605: 1576:Time complexity: 1568: 1545: 1542: 1539: 1536: 1533: 1530: 1527: 1524: 1521: 1518: 1515: 1512: 1509: 1506: 1503: 1500: 1497: 1494: 1491: 1488: 1485: 1482: 1479: 1476: 1473: 1470: 1467: 1464: 1461: 1458: 1455: 1452: 1449: 1446: 1443: 1440: 1437: 1434: 1431: 1428: 1425: 1422: 1419: 1416: 1413: 1410: 1407: 1404: 1401: 1398: 1395: 1392: 1389: 1386: 1383: 1380: 1377: 1374: 1371: 1368: 1365: 1362: 1359: 1356: 1353: 1350: 1347: 1340: 1336: 1328: 1326: 1324: 1323: 1318: 1289:Time complexity: 1284: 1235: 1220: 1217: 1214: 1211: 1208: 1205: 1202: 1199: 1196: 1193: 1190: 1187: 1184: 1181: 1178: 1175: 1172: 1169: 1166: 1163: 1160: 1157: 1154: 1151: 1148: 1145: 1142: 1139: 1136: 1133: 1130: 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1100: 1097: 1094: 1091: 1088: 1085: 1082: 1079: 1076: 1073: 1070: 1067: 1064: 1061: 1058: 1055: 1052: 1049: 1046: 1043: 1040: 1037: 1034: 1031: 1028: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1004: 1001: 998: 995: 992: 989: 986: 983: 980: 977: 974: 971: 968: 965: 962: 959: 956: 953: 950: 947: 944: 941: 938: 935: 932: 929: 926: 923: 920: 917: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 872: 869: 866: 863: 860: 857: 854: 851: 848: 845: 842: 839: 836: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 725: 722: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 605: 602: 599: 596: 593: 590: 587: 584: 581: 578: 575: 572: 569: 566: 563: 560: 557: 554: 551: 548: 545: 542: 539: 536: 533: 530: 527: 524: 521: 518: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 356: 353: 350: 347: 344: 341: 338: 335: 332: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 290: 287: 284: 281: 278: 275: 272: 269: 266: 263: 260: 257: 254: 251: 248: 245: 242: 239: 236: 233: 230: 227: 224: 221: 218: 215: 212: 209: 206: 203: 200: 197: 194: 191: 188: 185: 182: 179: 176: 173: 170: 167: 164: 161: 158: 155: 152: 149: 3834: 3833: 3829: 3828: 3827: 3825: 3824: 3823: 3804: 3803: 3802: 3797: 3741: 3688: 3655: 3641:Regular grammar 3622: 3601: 3582:Raita algorithm 3543: 3494:Bitap algorithm 3475: 3470: 3322: 3317: 3316: 3307: 3305: 3292: 3291: 3284: 3252: 3246: 3233: 3224: 3218: 3215: 3172: 3170: 3156: 3144: 3133: 3100: 3071:Disadvantages: 2927: 2907: 2892: 2887: 2872: 2861: 2846: 2841: 2799: 2796: 2795: 2793: 2785: 2770: 2765: 2761: 2755: 2750: 2749: 2746: 2743: 2740: 2737: 2734: 2731: 2728: 2725: 2722: 2719: 2716: 2713: 2710: 2707: 2704: 2701: 2698: 2695: 2692: 2689: 2686: 2683: 2680: 2677: 2674: 2671: 2668: 2665: 2662: 2659: 2656: 2653: 2650: 2647: 2644: 2641: 2638: 2635: 2632: 2629: 2626: 2623: 2620: 2605: 2601: 2564: 2561: 2560: 2558: 2549: 2543: 2530: 2520: 2514: 2507: 2492: 2487: 2483: 2477: 2472: 2471: 2468: 2465: 2462: 2459: 2456: 2453: 2450: 2447: 2444: 2441: 2438: 2435: 2432: 2429: 2426: 2423: 2420: 2417: 2414: 2411: 2408: 2405: 2402: 2399: 2396: 2393: 2390: 2387: 2384: 2381: 2378: 2375: 2372: 2369: 2366: 2363: 2360: 2357: 2354: 2351: 2348: 2345: 2342: 2339: 2336: 2333: 2330: 2327: 2324: 2321: 2318: 2315: 2312: 2309: 2306: 2303: 2300: 2297: 2294: 2291: 2288: 2285: 2282: 2279: 2276: 2273: 2270: 2267: 2264: 2261: 2258: 2255: 2252: 2249: 2246: 2243: 2240: 2237: 2234: 2231: 2228: 2225: 2222: 2219: 2216: 2213: 2210: 2207: 2204: 2201: 2198: 2195: 2192: 2189: 2186: 2183: 2180: 2177: 2174: 2171: 2168: 2165: 2162: 2159: 2156: 2153: 2150: 2042: 2039: 2038: 2036: 2027: 2021: 2011: 2005: 2001: 1995: 1988: 1982: 1980: 1973: 1960: 1946: 1905: 1902: 1901: 1899: 1897: 1888: 1884: 1847: 1844: 1843: 1841: 1814: 1811: 1810: 1808: 1801: 1794: 1785: 1771: 1755: 1754: 1751: 1748: 1745: 1742: 1739: 1736: 1733: 1730: 1727: 1724: 1721: 1718: 1715: 1712: 1709: 1706: 1703: 1700: 1697: 1694: 1691: 1688: 1685: 1682: 1679: 1676: 1673: 1670: 1667: 1664: 1661: 1658: 1655: 1652: 1649: 1646: 1643: 1640: 1637: 1634: 1631: 1584: 1581: 1580: 1578: 1566: 1552: 1547: 1546: 1543: 1540: 1537: 1534: 1531: 1528: 1525: 1522: 1519: 1516: 1513: 1510: 1507: 1504: 1501: 1498: 1495: 1492: 1489: 1486: 1483: 1480: 1477: 1474: 1471: 1468: 1465: 1462: 1459: 1456: 1453: 1450: 1447: 1444: 1441: 1438: 1435: 1432: 1429: 1426: 1423: 1420: 1417: 1414: 1411: 1408: 1405: 1402: 1399: 1396: 1393: 1390: 1387: 1384: 1381: 1378: 1375: 1372: 1369: 1366: 1363: 1360: 1357: 1354: 1351: 1348: 1345: 1338: 1334: 1297: 1294: 1293: 1291: 1282: 1276: 1261: 1255: 1249: 1233: 1227: 1222: 1221: 1218: 1215: 1212: 1209: 1206: 1203: 1200: 1197: 1194: 1191: 1188: 1185: 1182: 1179: 1176: 1173: 1170: 1167: 1164: 1161: 1158: 1155: 1152: 1149: 1146: 1143: 1140: 1137: 1134: 1131: 1128: 1125: 1122: 1119: 1116: 1113: 1110: 1107: 1104: 1101: 1098: 1095: 1092: 1089: 1086: 1083: 1080: 1077: 1074: 1071: 1068: 1065: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1038: 1035: 1032: 1029: 1026: 1023: 1020: 1017: 1014: 1011: 1008: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 966: 963: 960: 957: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 918: 915: 912: 909: 906: 903: 900: 897: 894: 891: 888: 885: 882: 879: 876: 873: 870: 867: 864: 861: 858: 855: 852: 849: 846: 843: 840: 837: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 723: 720: 717: 714: 711: 708: 705: 702: 699: 696: 693: 690: 687: 684: 681: 678: 675: 672: 669: 666: 663: 660: 657: 654: 651: 648: 645: 642: 639: 636: 633: 630: 627: 612: 607: 606: 603: 600: 597: 594: 591: 588: 585: 582: 579: 576: 573: 570: 567: 564: 561: 558: 555: 552: 549: 546: 543: 540: 537: 534: 531: 528: 525: 522: 519: 516: 513: 510: 507: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 462: 459: 456: 453: 450: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 324: 321: 318: 315: 312: 309: 306: 303: 300: 297: 294: 291: 288: 285: 282: 279: 276: 273: 270: 267: 264: 261: 258: 255: 252: 249: 246: 243: 240: 237: 234: 231: 228: 225: 222: 219: 216: 213: 210: 207: 204: 201: 198: 195: 192: 189: 186: 183: 180: 177: 174: 171: 168: 165: 162: 159: 156: 153: 150: 147: 118:Create a stack 112: 100: 88:reference count 57: 17: 12: 11: 5: 3832: 3822: 3821: 3816: 3799: 3798: 3796: 3795: 3790: 3785: 3780: 3775: 3770: 3765: 3760: 3755: 3749: 3747: 3743: 3742: 3740: 3739: 3734: 3729: 3724: 3719: 3714: 3709: 3704: 3698: 3696: 3694:Data structure 3690: 3689: 3687: 3686: 3681: 3676: 3671: 3665: 3663: 3657: 3656: 3654: 3653: 3648: 3643: 3638: 3632: 3630: 3624: 3623: 3621: 3620: 3615: 3609: 3607: 3603: 3602: 3600: 3599: 3594: 3589: 3587:Trigram search 3584: 3579: 3574: 3569: 3564: 3559: 3553: 3551: 3545: 3544: 3542: 3541: 3536: 3531: 3526: 3521: 3516: 3511: 3506: 3501: 3496: 3491: 3485: 3483: 3477: 3476: 3469: 3468: 3461: 3454: 3446: 3440: 3439: 3430: 3421: 3412: 3403: 3394: 3385: 3376: 3371: 3366: 3364:Ropes for Java 3361: 3352: 3343: 3333: 3328: 3321: 3320:External links 3318: 3315: 3314: 3282: 3230: 3229: 3226: 3225: 3219:September 2011 3161:. Please help 3147: 3145: 3138: 3132: 3129: 3128: 3127: 3121: 3115: 3108: 3099: 3096: 3084: 3083: 3080: 3077: 3069: 3068: 3057: 3054: 3051: 3042: 3041: 3038: 3035: 3031: 3030: 3027: 3024: 3020: 3019: 3016: 3013: 3009: 3008: 3005: 3002: 2998: 2997: 2994: 2991: 2987: 2986: 2983: 2980: 2976: 2975: 2972: 2969: 2965: 2964: 2961: 2958: 2954: 2953: 2950: 2947: 2943: 2942: 2939: 2936: 2926: 2923: 2898: 2890: 2870: 2867:that contains 2852: 2844: 2838: 2837: 2824: 2821: 2818: 2815: 2812: 2809: 2806: 2803: 2788: 2776: 2768: 2754: 2751: 2619: 2598: 2597: 2583: 2580: 2577: 2574: 2571: 2568: 2553: 2547: 2535: 2525: 2518: 2498: 2490: 2476: 2473: 2149: 2086: 2085: 2082: 2075: 2074: 2061: 2058: 2055: 2052: 2049: 2046: 2031: 2025: 2016: 2009: 1999: 1993: 1986: 1978: 1971: 1945: 1942: 1924: 1921: 1918: 1915: 1912: 1909: 1895: 1881: 1880: 1866: 1863: 1860: 1857: 1854: 1851: 1827: 1824: 1821: 1818: 1803: 1799: 1792: 1786:Concat(S1, S2) 1770: 1767: 1630: 1617: 1616: 1603: 1600: 1597: 1594: 1591: 1588: 1573: 1551: 1548: 1344: 1331: 1330: 1316: 1313: 1310: 1307: 1304: 1301: 1286: 1280: 1271: 1259: 1253: 1244:in the string 1226: 1223: 626: 624: 623: 611: 608: 146: 144: 143: 111: 110:Collect leaves 108: 99: 96: 56: 53: 41:data structure 15: 9: 6: 4: 3: 2: 3831: 3820: 3817: 3815: 3812: 3811: 3809: 3794: 3791: 3789: 3786: 3784: 3781: 3779: 3776: 3774: 3771: 3769: 3766: 3764: 3761: 3759: 3756: 3754: 3751: 3750: 3748: 3744: 3738: 3735: 3733: 3730: 3728: 3725: 3723: 3720: 3718: 3715: 3713: 3710: 3708: 3705: 3703: 3700: 3699: 3697: 3695: 3691: 3685: 3682: 3680: 3677: 3675: 3672: 3670: 3667: 3666: 3664: 3662: 3658: 3652: 3649: 3647: 3644: 3642: 3639: 3637: 3634: 3633: 3631: 3629: 3625: 3619: 3616: 3614: 3611: 3610: 3608: 3604: 3598: 3595: 3593: 3590: 3588: 3585: 3583: 3580: 3578: 3575: 3573: 3570: 3568: 3565: 3563: 3560: 3558: 3555: 3554: 3552: 3550: 3546: 3540: 3537: 3535: 3532: 3530: 3527: 3525: 3522: 3520: 3517: 3515: 3512: 3510: 3507: 3505: 3504:Edit distance 3502: 3500: 3497: 3495: 3492: 3490: 3487: 3486: 3484: 3482: 3481:String metric 3478: 3474: 3467: 3462: 3460: 3455: 3453: 3448: 3447: 3444: 3438: 3434: 3431: 3429: 3425: 3422: 3420: 3416: 3413: 3411: 3407: 3404: 3402: 3398: 3395: 3393: 3389: 3386: 3384: 3380: 3377: 3375: 3372: 3370: 3367: 3365: 3362: 3360: 3356: 3353: 3351: 3347: 3344: 3341: 3337: 3334: 3332: 3329: 3327: 3324: 3323: 3304:on 2017-12-19 3303: 3299: 3295: 3289: 3287: 3278: 3274: 3270: 3266: 3262: 3256: 3251: 3244: 3242: 3240: 3238: 3236: 3231: 3222: 3211: 3208: 3204: 3201: 3197: 3194: 3190: 3187: 3183: 3180: â€“  3179: 3175: 3174:Find sources: 3168: 3164: 3160: 3154: 3153: 3152:single source 3148:This article 3146: 3142: 3137: 3136: 3125: 3122: 3119: 3116: 3113: 3109: 3106: 3102: 3101: 3095: 3093: 3089: 3081: 3078: 3074: 3073: 3072: 3066: 3062: 3058: 3055: 3052: 3049: 3048: 3047: 3039: 3036: 3033: 3028: 3025: 3022: 3017: 3014: 3011: 3006: 3003: 3000: 2995: 2992: 2989: 2984: 2981: 2978: 2973: 2970: 2967: 2962: 2959: 2956: 2951: 2948: 2945: 2940: 2937: 2934: 2933: 2922: 2920: 2916: 2912: 2905: 2901: 2897: 2893: 2885: 2881: 2873: 2866: 2859: 2855: 2851: 2847: 2819: 2816: 2813: 2810: 2807: 2801: 2792: 2789: 2783: 2779: 2775: 2771: 2760: 2757: 2756: 2617: 2615: 2611: 2578: 2575: 2572: 2566: 2557: 2554: 2550: 2542: 2538: 2534: 2528: 2524: 2517: 2512: 2505: 2501: 2497: 2493: 2482: 2479: 2478: 2147: 2144: 2142: 2138: 2134: 2130: 2126: 2122: 2118: 2114: 2110: 2106: 2102: 2098: 2094: 2089: 2083: 2080: 2079: 2078: 2056: 2053: 2050: 2044: 2035: 2032: 2028: 2019: 2015: 2008: 2002: 1992: 1985: 1977: 1970: 1966: 1959: 1956: 1955: 1950: 1941: 1938: 1919: 1916: 1913: 1907: 1894: 1861: 1858: 1855: 1849: 1822: 1816: 1807: 1804: 1798: 1791: 1784: 1781: 1780: 1775: 1766: 1628: 1626: 1622: 1598: 1595: 1592: 1586: 1577: 1574: 1572: 1565: 1562: 1561: 1556: 1342: 1311: 1308: 1305: 1299: 1290: 1287: 1283: 1274: 1270: 1266: 1262: 1252: 1247: 1243: 1239: 1234:Insert(i, S’) 1232: 1229: 1228: 805:collectLeaves 621: 617: 614: 613: 141: 137: 134:. Add l' to 133: 129: 125: 121: 117: 114: 113: 107: 105: 95: 93: 89: 85: 81: 80:copy-on-write 77: 72: 70: 66: 62: 52: 50: 46: 42: 38: 34: 30: 21: 3814:Binary trees 3726: 3707:Suffix array 3613:Aho–Corasick 3524:Lee distance 3306:. Retrieved 3302:the original 3297: 3264: 3260: 3216: 3206: 3199: 3192: 3185: 3173: 3149: 3091: 3087: 3085: 3070: 3046:Advantages: 3045: 3026:O(j + log n) 2918: 2914: 2909:by doing an 2903: 2899: 2895: 2888: 2883: 2879: 2868: 2864: 2857: 2853: 2849: 2842: 2839: 2790: 2781: 2777: 2773: 2766: 2762:Report(i, j) 2758: 2717:RopeLikeTree 2613: 2609: 2599: 2555: 2545: 2540: 2536: 2532: 2526: 2522: 2515: 2510: 2503: 2499: 2495: 2488: 2484:Delete(i, j) 2480: 2388:RopeLikeTree 2280:RopeLikeTree 2145: 2140: 2136: 2132: 2128: 2124: 2120: 2116: 2112: 2108: 2104: 2100: 2096: 2092: 2090: 2087: 2076: 2033: 2023: 2017: 2013: 2006: 1997: 1990: 1983: 1975: 1968: 1964: 1961:Split (i, S) 1957: 1939: 1892: 1882: 1805: 1796: 1789: 1782: 1756: 1620: 1618: 1575: 1570: 1563: 1367:CharSequence 1332: 1288: 1278: 1272: 1268: 1264: 1257: 1250: 1245: 1241: 1237: 1230: 1165:RopeLikeTree 1078:RopeLikeTree 619: 615: 139: 135: 131: 127: 123: 119: 115: 103: 101: 73: 64: 58: 49:text editing 36: 32: 26: 3717:Suffix tree 3359:Common Lisp 3298:www.sgi.com 3124:Piece table 3088:algorithmic 2968:Concatenate 2930:Complexity 2759:Definition: 2481:Definition: 1958:Definition: 1783:Definition: 1564:Definition: 1231:Definition: 616:Definition: 122:and a list 116:Definition: 61:binary tree 55:Description 3808:Categories 3308:2017-03-01 3189:newspapers 3131:References 3118:Gap buffer 1889:right = S2 1746:startIndex 1710:startIndex 1674:startIndex 1659:startIndex 775:isBalanced 634:isBalanced 229:ArrayDeque 157:implements 98:Operations 3424:SwiftRope 3419:Smalltalk 3340:libstdc++ 3159:talk page 3092:raw speed 2935:Operation 2886:. Output 2817:⁡ 2708:rebalance 2621:@Override 2576:⁡ 2412:rebalance 2379:rebalance 2271:rebalance 2253:rebalance 2054:⁡ 1917:⁡ 1885:left = S1 1859:⁡ 1632:@Override 1625:recursive 1596:⁡ 1309:⁡ 748:rebalance 610:Rebalance 361:@Override 316:@Override 3277:Archived 3098:See also 3015:O(log n) 2993:O(log n) 2960:O(log n) 2949:O(log n) 2627:RopeLike 2612:-th and 2606:Concat() 2604:and one 2166:RopeLike 2160:RopeLike 1567:Index(i) 1526:sequence 1448:sequence 1409:sequence 1370:sequence 1339:Concat() 1337:and two 952:RopeLike 937:RopeLike 883:RopeLike 868:RopeLike 754:RopeLike 745:RopeLike 640:RopeLike 460:getRight 367:RopeLike 232:<> 208:RopeLike 205:@NonNull 187:RopeLike 166:RopeLike 160:Iterator 3783:Sorting 3753:Parsing 3473:Strings 3433:"Ropey" 3406:pyropes 3203:scholar 3067:levels. 2941:String 2835:⁠ 2794:⁠ 2602:Split() 2594:⁠ 2559:⁠ 2509:, from 2072:⁠ 2037:⁠ 2022:, ..., 1996:, ..., 1935:⁠ 1900:⁠ 1877:⁠ 1842:⁠ 1838:⁠ 1809:⁠ 1734:indexOf 1698:indexOf 1641:indexOf 1614:⁠ 1579:⁠ 1403:prepend 1335:Split() 1327:⁠ 1292:⁠ 1277:, ..., 1256:, ..., 631:boolean 577:getLeft 520:getLeft 415:isEmpty 325:hasNext 322:boolean 304:getLeft 175:private 86:with a 69:subtree 45:strings 39:, is a 3410:Python 3205:  3198:  3191:  3184:  3176:  3023:Report 3012:Delete 3001:Append 2990:Insert 2753:Report 2705:return 2699:length 2648:length 2630:delete 2624:public 2475:Delete 2439:return 2364:return 2358:weight 2322:weight 2238:return 2202:weight 2151:public 1769:Concat 1725:return 1716:weight 1689:return 1680:weight 1635:public 1520:append 1502:concat 1484:return 1442:append 1439:return 1430:length 1400:return 1352:insert 1346:public 1225:Insert 1201:leaves 1177:leaves 1159:return 1102:leaves 1084:leaves 1072:return 1030:leaves 1027:return 958:leaves 934:static 919:leaves 907:leaves 898:return 889:leaves 865:static 853:return 838:leaves 826:leaves 817:return 793:leaves 742:static 733:weight 718:return 706:return 691:length 628:static 595:result 592:return 454:parent 427:parent 382:result 364:public 334:return 319:public 65:weight 3746:Other 3702:DAFSA 3669:BLAST 3428:Swift 3415:Ropes 3401:OCaml 3397:Ropes 3388:ropes 3383:Limbo 3379:Ropes 3355:ropes 3346:Ropes 3210:JSTOR 3196:books 3105:Cedar 3040:O(n) 3034:Build 3029:O(j) 3018:O(n) 2996:O(n) 2985:O(n) 2974:O(n) 2963:O(1) 2957:Split 2952:O(1) 2946:Index 2894:, …, 2848:, …, 2772:, …, 2693:start 2687:split 2672:start 2666:split 2639:start 2544:, …, 2521:, …, 2494:, …, 2460:right 2418:split 2400:split 2352:index 2346:split 2340:right 2334:split 2316:index 2298:right 2286:split 2259:split 2232:index 2226:split 2214:split 2196:index 2181:index 2172:split 1944:Split 1692:right 1550:Index 1496:Ropes 1472:split 1195:merge 1183:start 1171:merge 1147:range 1138:start 1114:start 1096:start 1057:range 1042:start 1012:range 1000:start 988:range 967:start 940:merge 901:merge 871:merge 820:merge 799:Ropes 724:<= 709:false 682:>= 679:depth 667:depth 655:depth 571:cleft 565:cleft 559:cleft 547:stack 532:cleft 526:while 514:right 508:cleft 499:right 487:stack 472:right 448:right 433:stack 409:stack 388:stack 337:stack 274:stack 253:while 220:stack 193:stack 181:Deque 178:final 151:class 148:final 35:, or 3737:Trie 3727:Rope 3437:Rust 3435:for 3426:for 3417:for 3408:for 3399:for 3390:for 3381:for 3357:for 3348:for 3182:news 3110:The 3103:The 3065:undo 3037:O(n) 2982:O(n) 2938:Rope 2874:and 2454:left 2442:Pair 2433:else 2394:left 2367:Pair 2319:> 2307:else 2301:))); 2241:Pair 2220:left 2199:< 2169:> 2157:< 2154:Pair 2131:and 2123:and 2099:and 2004:and 1974:and 1887:and 1840:(or 1795:and 1759:i=10 1728:left 1677:> 1647:char 1490:Rope 1466:base 1349:Rope 955:> 949:< 946:List 928:()); 925:size 886:> 880:< 877:List 847:()); 844:size 553:push 538:null 493:push 478:null 370:next 349:> 343:size 280:push 265:null 247:root 211:root 190:> 184:< 169:> 163:< 37:cord 33:rope 31:, a 3392:Nim 3269:doi 3255:PDF 3165:by 2913:of 2906:− 1 2860:− 1 2814:log 2784:− 1 2744:)); 2741:snd 2735:rhs 2729:fst 2723:lhs 2714:new 2681:rhs 2678:val 2660:lhs 2657:val 2645:int 2636:int 2614:i+j 2573:log 2529:− 1 2506:− 1 2427:)); 2424:snd 2409:)), 2406:fst 2385:new 2331:val 2292:snd 2277:new 2265:fst 2211:val 2178:int 2051:log 2020:+ 1 1914:log 1856:log 1763:i=1 1656:int 1638:int 1593:log 1541:)); 1538:snd 1532:lhs 1514:fst 1508:lhs 1487:new 1478:idx 1460:lhs 1457:val 1433:()) 1424:idx 1385:idx 1361:idx 1358:int 1306:log 1275:+ 1 1216:)); 1213:end 1207:mid 1189:mid 1162:new 1132:mid 1129:int 1123:)); 1108:get 1090:get 1075:new 1036:get 994:end 985:int 976:end 973:int 964:int 790:val 736:(); 670:(); 652:val 580:(); 523:(); 505:var 463:(); 445:var 442:(); 439:pop 424:var 418:()) 397:(); 394:pop 379:val 307:(); 238:var 235:(); 226:new 130:to 27:In 3810:: 3350:C# 3296:. 3285:^ 3275:. 3265:25 3263:. 3259:. 3234:^ 2921:. 2902:+ 2856:+ 2780:+ 2702:); 2675:); 2539:+ 2531:, 2502:+ 2463:); 2448:of 2373:of 2361:); 2310:if 2268:), 2247:of 2235:); 2190:if 2143:. 2012:= 1989:= 1981:, 1749:); 1740:ch 1719:); 1704:ch 1668:if 1650:ch 1529:), 1481:); 1451:); 1427:== 1418:if 1412:); 1388:== 1379:if 1267:, 1265:S' 1263:, 1238:S’ 1192:), 1156:); 1099:), 1060:== 1051:if 1045:); 1015:== 1006:if 814:); 784:)) 766:if 673:if 562:); 535:!= 502:); 475:!= 466:if 400:if 373:() 346:() 328:() 289:); 262:!= 3465:e 3458:t 3451:v 3342:) 3311:. 3271:: 3257:) 3253:( 3221:) 3217:( 3207:¡ 3200:¡ 3193:¡ 3186:¡ 3169:. 3155:. 2919:u 2915:T 2904:j 2900:i 2896:C 2891:i 2889:C 2884:u 2880:T 2871:i 2869:C 2865:u 2858:j 2854:i 2850:C 2845:i 2843:C 2823:) 2820:N 2811:+ 2808:j 2805:( 2802:O 2787:. 2782:j 2778:i 2774:C 2769:i 2767:C 2747:} 2738:. 2732:, 2726:. 2720:( 2711:( 2696:+ 2690:( 2684:= 2669:( 2663:= 2654:{ 2651:) 2642:, 2633:( 2610:i 2596:. 2582:) 2579:N 2570:( 2567:O 2552:. 2548:m 2546:C 2541:j 2537:i 2533:C 2527:i 2523:C 2519:1 2516:C 2511:s 2504:j 2500:i 2496:C 2491:i 2489:C 2469:} 2466:} 2457:, 2451:( 2445:. 2436:{ 2430:} 2421:. 2415:( 2403:. 2397:, 2391:( 2382:( 2376:( 2370:. 2355:- 2349:( 2343:. 2337:= 2328:{ 2325:) 2313:( 2304:} 2295:, 2289:. 2283:( 2274:( 2262:. 2256:( 2250:( 2244:. 2229:( 2223:. 2217:= 2208:{ 2205:) 2193:( 2187:{ 2184:) 2175:( 2163:, 2141:K 2137:P 2133:H 2129:K 2125:A 2121:D 2117:K 2113:D 2109:K 2105:G 2101:G 2097:K 2093:K 2060:) 2057:N 2048:( 2045:O 2030:. 2026:m 2024:C 2018:i 2014:C 2010:2 2007:S 2000:i 1998:C 1994:1 1991:C 1987:1 1984:S 1979:2 1976:S 1972:1 1969:S 1965:S 1923:) 1920:N 1911:( 1908:O 1896:1 1893:S 1865:) 1862:N 1853:( 1850:O 1826:) 1823:1 1820:( 1817:O 1800:2 1797:S 1793:1 1790:S 1752:} 1743:, 1737:( 1731:. 1722:} 1713:- 1707:, 1701:( 1695:. 1686:{ 1683:) 1671:( 1665:{ 1662:) 1653:, 1644:( 1621:i 1602:) 1599:N 1590:( 1587:O 1571:i 1544:} 1535:. 1523:( 1517:. 1511:. 1505:( 1499:. 1493:( 1475:( 1469:. 1463:= 1454:} 1445:( 1436:{ 1421:( 1415:} 1406:( 1397:{ 1394:) 1391:0 1382:( 1376:{ 1373:) 1364:, 1355:( 1329:. 1315:) 1312:N 1303:( 1300:O 1285:. 1281:m 1279:C 1273:i 1269:C 1260:i 1258:C 1254:1 1251:C 1246:s 1242:i 1219:} 1210:, 1204:, 1198:( 1186:, 1180:, 1174:( 1168:( 1153:2 1150:/ 1144:( 1141:+ 1135:= 1126:} 1120:1 1117:+ 1111:( 1105:. 1093:( 1087:. 1081:( 1069:{ 1066:) 1063:2 1054:( 1048:} 1039:( 1033:. 1024:{ 1021:) 1018:1 1009:( 1003:; 997:- 991:= 982:{ 979:) 970:, 961:, 943:( 931:} 922:. 916:, 913:0 910:, 904:( 895:{ 892:) 874:( 862:} 859:; 856:r 850:} 841:. 835:, 832:0 829:, 823:( 811:r 808:( 802:. 796:= 787:{ 781:r 778:( 772:! 769:( 763:{ 760:) 757:r 751:( 739:} 730:. 727:r 715:} 712:; 703:{ 700:) 697:2 694:- 688:. 676:( 664:. 661:r 658:= 649:{ 646:) 643:r 637:( 620:L 604:} 601:} 598:; 589:} 586:} 583:} 574:. 568:= 556:( 550:. 544:{ 541:) 529:( 517:. 511:= 496:( 490:. 484:{ 481:) 469:( 457:. 451:= 436:. 430:= 421:{ 412:. 406:! 403:( 391:. 385:= 376:{ 358:} 355:; 352:0 340:. 331:{ 313:} 310:} 301:. 298:c 295:= 292:c 286:c 283:( 277:. 271:{ 268:) 259:c 256:( 250:; 244:= 241:c 223:= 217:{ 214:) 202:( 196:; 172:{ 140:p 136:L 132:S 128:n 124:L 120:S 104:N

Index


computer programming
data structure
strings
text editing
binary tree
subtree
immutable objects
copy-on-write
basic fixed-length strings
reference count
garbage collection

recursive


in-order traversal
persistent data structure
undo
Cedar
Model T enfilade
Gap buffer
Piece table

single source
talk page
improve this article
introducing citations to additional sources
"Rope" data structure
news

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

↑