ropes.html 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <!-- This file is generated by Nim. -->
  4. <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>std/ropes</title>
  9. <!-- Google fonts -->
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  11. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  12. <!-- Favicon -->
  13. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  14. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  15. <!-- CSS -->
  16. <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
  17. <!-- JS -->
  18. <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
  19. </head>
  20. <body>
  21. <div class="document" id="documentId">
  22. <div class="container">
  23. <h1 class="title">std/ropes</h1>
  24. <div class="row">
  25. <div class="three columns">
  26. <div class="theme-select-wrapper">
  27. <label for="theme-select">Theme:&nbsp;</label>
  28. <select id="theme-select" onchange="setTheme(this.value)">
  29. <option value="auto">🌗 Match OS</option>
  30. <option value="dark">🌑 Dark</option>
  31. <option value="light">🌕 Light</option>
  32. </select>
  33. </div>
  34. <div id="global-links">
  35. <ul class="simple-boot">
  36. <li><a href="manual.html">Manual</a></li>
  37. <li><a href="lib.html">Standard library</a></li>
  38. <li> <a id="indexLink" href="theindex.html">Index</a></li>
  39. <li><a href="compiler/theindex.html">Compiler docs</a></li>
  40. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  41. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  42. </ul>
  43. </div>
  44. <div id="searchInputDiv">
  45. Search: <input type="search" id="searchInput"
  46. oninput="search()" />
  47. </div>
  48. <ul class="simple simple-toc" id="toc-list">
  49. <li>
  50. <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
  51. </li>
  52. <li>
  53. <details open>
  54. <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
  55. <ul class="simple simple-toc-section">
  56. <li><a class="reference" href="#Rope" title="Rope {.acyclic.} = ref object">Rope</a></li>
  57. </ul>
  58. </details>
  59. </li>
  60. <li>
  61. <details open>
  62. <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
  63. <ul class="simple simple-toc-section">
  64. <ul class="simple nested-toc-section">$
  65. <li><a class="reference" href="#%24%2CRope" title="`$`(r: Rope): string">`$`(r: Rope): string</a></li>
  66. </ul>
  67. <ul class="simple nested-toc-section">%
  68. <li><a class="reference" href="#%25%2Cstring%2CopenArray%5BRope%5D" title="`%`(frmt: string; args: openArray[Rope]): Rope">`%`(frmt: string; args: openArray[Rope]): Rope</a></li>
  69. </ul>
  70. <ul class="simple nested-toc-section">&
  71. <li><a class="reference" href="#%26%2CRope%2CRope" title="`&amp;`(a, b: Rope): Rope">`&amp;`(a, b: Rope): Rope</a></li>
  72. <li><a class="reference" href="#%26%2CopenArray%5BRope%5D" title="`&amp;`(a: openArray[Rope]): Rope">`&amp;`(a: openArray[Rope]): Rope</a></li>
  73. <li><a class="reference" href="#%26%2CRope%2Cstring" title="`&amp;`(a: Rope; b: string): Rope">`&amp;`(a: Rope; b: string): Rope</a></li>
  74. <li><a class="reference" href="#%26%2Cstring%2CRope" title="`&amp;`(a: string; b: Rope): Rope">`&amp;`(a: string; b: Rope): Rope</a></li>
  75. </ul>
  76. <ul class="simple nested-toc-section">[]
  77. <li><a class="reference" href="#%5B%5D%2CRope%2Cint" title="`[]`(r: Rope; i: int): char">`[]`(r: Rope; i: int): char</a></li>
  78. </ul>
  79. <ul class="simple nested-toc-section">add
  80. <li><a class="reference" href="#add%2CRope%2CRope" title="add(a: var Rope; b: Rope)">add(a: var Rope; b: Rope)</a></li>
  81. <li><a class="reference" href="#add%2CRope%2Cstring" title="add(a: var Rope; b: string)">add(a: var Rope; b: string)</a></li>
  82. </ul>
  83. <ul class="simple nested-toc-section">addf
  84. <li><a class="reference" href="#addf%2CRope%2Cstring%2CopenArray%5BRope%5D" title="addf(c: var Rope; frmt: string; args: openArray[Rope])">addf(c: var Rope; frmt: string; args: openArray[Rope])</a></li>
  85. </ul>
  86. <ul class="simple nested-toc-section">disableCache
  87. <li><a class="reference" href="#disableCache" title="disableCache()">disableCache()</a></li>
  88. </ul>
  89. <ul class="simple nested-toc-section">enableCache
  90. <li><a class="reference" href="#enableCache" title="enableCache()">enableCache()</a></li>
  91. </ul>
  92. <ul class="simple nested-toc-section">equalsFile
  93. <li><a class="reference" href="#equalsFile%2CRope%2CFile" title="equalsFile(r: Rope; f: File): bool">equalsFile(r: Rope; f: File): bool</a></li>
  94. <li><a class="reference" href="#equalsFile%2CRope%2Cstring" title="equalsFile(r: Rope; filename: string): bool">equalsFile(r: Rope; filename: string): bool</a></li>
  95. </ul>
  96. <ul class="simple nested-toc-section">len
  97. <li><a class="reference" href="#len%2CRope" title="len(a: Rope): int">len(a: Rope): int</a></li>
  98. </ul>
  99. <ul class="simple nested-toc-section">rope
  100. <li><a class="reference" href="#rope%2CBiggestFloat" title="rope(f: BiggestFloat): Rope">rope(f: BiggestFloat): Rope</a></li>
  101. <li><a class="reference" href="#rope%2CBiggestInt" title="rope(i: BiggestInt): Rope">rope(i: BiggestInt): Rope</a></li>
  102. <li><a class="reference" href="#rope%2Cstring" title="rope(s: string = &quot;&quot;): Rope">rope(s: string = &quot;&quot;): Rope</a></li>
  103. </ul>
  104. <ul class="simple nested-toc-section">write
  105. <li><a class="reference" href="#write%2CFile%2CRope" title="write(f: File; r: Rope)">write(f: File; r: Rope)</a></li>
  106. <li><a class="reference" href="#write%2CStream%2CRope" title="write(s: Stream; r: Rope)">write(s: Stream; r: Rope)</a></li>
  107. </ul>
  108. </ul>
  109. </details>
  110. </li>
  111. <li>
  112. <details open>
  113. <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
  114. <ul class="simple simple-toc-section">
  115. <ul class="simple nested-toc-section">items
  116. <li><a class="reference" href="#items.i%2CRope" title="items(r: Rope): char">items(r: Rope): char</a></li>
  117. </ul>
  118. <ul class="simple nested-toc-section">leaves
  119. <li><a class="reference" href="#leaves.i%2CRope" title="leaves(r: Rope): string">leaves(r: Rope): string</a></li>
  120. </ul>
  121. </ul>
  122. </details>
  123. </li>
  124. </ul>
  125. </div>
  126. <div class="nine columns" id="content">
  127. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  128. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  129. <div id="tocRoot"></div>
  130. <p class="module-desc">This module contains support for a <span id="rope_1">rope</span> data type. Ropes can represent very long strings efficiently; in particular, concatenation is done in O(1) instead of O(n). They are essentially concatenation trees that are only flattened when converting to a native Nim string. The empty string is represented by <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>. Ropes are immutable and subtrees can be shared without copying. Leaves can be cached for better memory efficiency at the cost of runtime efficiency.</p>
  131. <div class="section" id="6">
  132. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  133. <dl class="item">
  134. <a class="reference external" href="streams.html">streams</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="formatfloat.html">formatfloat</a>, <a class="reference external" href="assertions.html">assertions</a>
  135. </dl>
  136. </div>
  137. <div class="section" id="7">
  138. <h1><a class="toc-backref" href="#7">Types</a></h1>
  139. <dl class="item">
  140. <div id="Rope">
  141. <dt><pre><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span class="Identifier">acyclic</span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span></pre></dt>
  142. <dd>
  143. A rope data type. The empty rope is represented by <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>.
  144. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L35" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  145. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L35" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  146. </dd>
  147. </div>
  148. </dl>
  149. </div>
  150. <div class="section" id="12">
  151. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  152. <dl class="item">
  153. <div id="$-procs-all">
  154. <div id="$,Rope">
  155. <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CRope"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroToString&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  156. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  157. <dd>
  158. Converts a rope back to a string.
  159. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L291" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  160. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L291" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  161. </dd>
  162. </div>
  163. </div>
  164. <div id="%-procs-all">
  165. <div id="%,string,openArray[Rope]">
  166. <dt><pre><span class="Keyword">proc</span> <a href="#%25%2Cstring%2CopenArray%5BRope%5D"><span class="Identifier">`%`</span></a><span class="Other">(</span><span class="Identifier">frmt</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  167. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroFormat&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  168. <dd>
  169. <tt class="docutils literal"><span class="pre"><span class="Operator">%</span></span></tt> substitution operator for ropes. Does not support the <tt class="docutils literal"><span class="pre"><span class="Operator">$</span><span class="Identifier">identifier</span></span></tt> nor <tt class="docutils literal"><span class="pre"><span class="Operator">$</span><span class="Punctuation">{</span><span class="Identifier">identifier</span><span class="Punctuation">}</span></span></tt> notations.
  170. <p><strong class="examples_text">Example:</strong></p>
  171. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r1</span> <span class="Operator">=</span> <span class="StringLit">&quot;$1 $2 $3&quot;</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;is&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;a great language&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
  172. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r1</span> <span class="Operator">==</span> <span class="StringLit">&quot;Nim is a great language&quot;</span>
  173. <span class="Keyword">let</span> <span class="Identifier">r2</span> <span class="Operator">=</span> <span class="StringLit">&quot;$# $# $#&quot;</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;is&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;a great language&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
  174. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r2</span> <span class="Operator">==</span> <span class="StringLit">&quot;Nim is a great language&quot;</span>
  175. <span class="Keyword">let</span> <span class="Identifier">r3</span> <span class="Operator">=</span> <span class="StringLit">&quot;${1} ${2} ${3}&quot;</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;is&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;a great language&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
  176. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r3</span> <span class="Operator">==</span> <span class="StringLit">&quot;Nim is a great language&quot;</span></pre>
  177. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L296" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  178. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L296" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  179. </dd>
  180. </div>
  181. </div>
  182. <div id="&amp;-procs-all">
  183. <div id="&,Rope,Rope">
  184. <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CRope%2CRope"><span class="Identifier">`&amp;`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroConcRopeRope&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  185. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  186. <dd>
  187. The concatenation operator for ropes.
  188. <p><strong class="examples_text">Example:</strong></p>
  189. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, &quot;</span><span class="Punctuation">)</span> <span class="Operator">&amp;</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim!&quot;</span><span class="Punctuation">)</span>
  190. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  191. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L175" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  192. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L175" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  193. </dd>
  194. </div>
  195. <div id="&,openArray[Rope]">
  196. <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CopenArray%5BRope%5D"><span class="Identifier">`&amp;`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroConcOpenArray&quot;</span><span class="Other">,</span>
  197. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  198. <dd>
  199. The concatenation operator for an <tt class="docutils literal"><span class="pre"><span class="Identifier">openArray</span></span></tt> of ropes.
  200. <p><strong class="examples_text">Example:</strong></p>
  201. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Operator">&amp;</span><span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, &quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;!&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
  202. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  203. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L207" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  204. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L207" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  205. </dd>
  206. </div>
  207. <div id="&,Rope,string">
  208. <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CRope%2Cstring"><span class="Identifier">`&amp;`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroConcRopeStr&quot;</span><span class="Other">,</span>
  209. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  210. <dd>
  211. The concatenation operator for ropes.
  212. <p><strong class="examples_text">Example:</strong></p>
  213. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, &quot;</span><span class="Punctuation">)</span> <span class="Operator">&amp;</span> <span class="StringLit">&quot;Nim!&quot;</span>
  214. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  215. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L191" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  216. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L191" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  217. </dd>
  218. </div>
  219. <div id="&,string,Rope">
  220. <dt><pre><span class="Keyword">proc</span> <a href="#%26%2Cstring%2CRope"><span class="Identifier">`&amp;`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroConcStrRope&quot;</span><span class="Other">,</span>
  221. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  222. <dd>
  223. The concatenation operator for ropes.
  224. <p><strong class="examples_text">Example:</strong></p>
  225. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="StringLit">&quot;Hello, &quot;</span> <span class="Operator">&amp;</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim!&quot;</span><span class="Punctuation">)</span>
  226. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  227. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L199" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  228. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L199" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  229. </dd>
  230. </div>
  231. </div>
  232. <div id="[]-procs-all">
  233. <div id="[],Rope,int">
  234. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CRope%2Cint"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroCharAt&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  235. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  236. <dd>
  237. Returns the character at position <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt> in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>. This is quite expensive! Worst-case: O(n). If <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span> <span class="Operator">&gt;=</span> <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Keyword">or</span> <span class="Identifier">i</span> <span class="Operator">&lt;</span> <span class="DecNumber">0</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="DecNumber">0</span></span></tt> is returned.
  238. <p><strong class="examples_text">Example:</strong></p>
  239. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, Nim!&quot;</span><span class="Punctuation">)</span>
  240. <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'H'</span>
  241. <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">7</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'N'</span>
  242. <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">22</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span></pre>
  243. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L233" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  244. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L233" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  245. </dd>
  246. </div>
  247. </div>
  248. <div id="add-procs-all">
  249. <div id="add,Rope,Rope">
  250. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CRope%2CRope"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1Rope&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  251. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  252. <dd>
  253. Adds <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> to the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.
  254. <p><strong class="examples_text">Example:</strong></p>
  255. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, &quot;</span><span class="Punctuation">)</span>
  256. <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim!&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
  257. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  258. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L215" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  259. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L215" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  260. </dd>
  261. </div>
  262. <div id="add,Rope,string">
  263. <dt><pre><span class="Keyword">proc</span> <a href="#add%2CRope%2Cstring"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1Str&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  264. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  265. <dd>
  266. Adds <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> to the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.
  267. <p><strong class="examples_text">Example:</strong></p>
  268. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello, &quot;</span><span class="Punctuation">)</span>
  269. <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim!&quot;</span><span class="Punctuation">)</span>
  270. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Hello, Nim!&quot;</span></pre>
  271. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L224" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  272. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L224" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  273. </dd>
  274. </div>
  275. </div>
  276. <div id="addf-procs-all">
  277. <div id="addf,Rope,string,openArray[Rope]">
  278. <dt><pre><span class="Keyword">proc</span> <a href="#addf%2CRope%2Cstring%2CopenArray%5BRope%5D"><span class="Identifier">addf</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">frmt</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
  279. <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  280. <dd>
  281. Shortcut for <tt class="docutils literal"><span class="pre"><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">frmt</span> <span class="Operator">%</span> <span class="Identifier">args</span><span class="Punctuation">)</span></span></tt>.
  282. <p><strong class="examples_text">Example:</strong></p>
  283. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Dash: &quot;</span><span class="Punctuation">)</span>
  284. <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">addf</span> <span class="StringLit">&quot;$1 $2 $3&quot;</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Nim&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;is&quot;</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;a great language&quot;</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
  285. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;Dash: Nim is a great language&quot;</span></pre>
  286. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L349" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  287. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L349" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  288. </dd>
  289. </div>
  290. </div>
  291. <div id="disableCache-procs-all">
  292. <div id="disableCache">
  293. <dt><pre><span class="Keyword">proc</span> <a href="#disableCache"><span class="Identifier">disableCache</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  294. <dd>
  295. The cache is discarded and disabled. The GC will reuse its used memory.
  296. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L170" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  297. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L170" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  298. </dd>
  299. </div>
  300. </div>
  301. <div id="enableCache-procs-all">
  302. <div id="enableCache">
  303. <dt><pre><span class="Keyword">proc</span> <a href="#enableCache"><span class="Identifier">enableCache</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  304. <dd>
  305. Enables the caching of leaves. This reduces the memory footprint at the cost of runtime efficiency.
  306. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L165" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  307. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L165" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  308. </dd>
  309. </div>
  310. </div>
  311. <div id="equalsFile-procs-all">
  312. <div id="equalsFile,Rope,File">
  313. <dt><pre><span class="Keyword">proc</span> <a href="#equalsFile%2CRope%2CFile"><span class="Identifier">equalsFile</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1File&quot;</span><span class="Other">,</span>
  314. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  315. <dd>
  316. Returns true if the contents of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> equal <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
  317. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L362" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  318. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L362" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  319. </dd>
  320. </div>
  321. <div id="equalsFile,Rope,string">
  322. <dt><pre><span class="Keyword">proc</span> <a href="#equalsFile%2CRope%2Cstring"><span class="Identifier">equalsFile</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1Str&quot;</span><span class="Other">,</span>
  323. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  324. <dd>
  325. Returns true if the contents of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> equal <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> does not exist, false is returned.
  326. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L389" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  327. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L389" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  328. </dd>
  329. </div>
  330. </div>
  331. <div id="len-procs-all">
  332. <div id="len,Rope">
  333. <dt><pre><span class="Keyword">proc</span> <a href="#len%2CRope"><span class="Identifier">len</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  334. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  335. <dd>
  336. The rope's length.
  337. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L49" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  338. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L49" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  339. </dd>
  340. </div>
  341. </div>
  342. <div id="rope-procs-all">
  343. <div id="rope,BiggestFloat">
  344. <dt><pre><span class="Keyword">proc</span> <a href="#rope%2CBiggestFloat"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1BiggestFloat&quot;</span><span class="Other">,</span>
  345. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  346. <dd>
  347. Converts a float to a rope.
  348. <p><strong class="examples_text">Example:</strong></p>
  349. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="FloatNumber">4.29</span><span class="Punctuation">)</span>
  350. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;4.29&quot;</span></pre>
  351. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L157" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  352. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L157" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  353. </dd>
  354. </div>
  355. <div id="rope,BiggestInt">
  356. <dt><pre><span class="Keyword">proc</span> <a href="#rope%2CBiggestInt"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1BiggestInt&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  357. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  358. <dd>
  359. Converts an int to a rope.
  360. <p><strong class="examples_text">Example:</strong></p>
  361. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="DecNumber">429</span><span class="Punctuation">)</span>
  362. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;429&quot;</span></pre>
  363. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L149" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  364. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L149" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  365. </dd>
  366. </div>
  367. <div id="rope,string">
  368. <dt><pre><span class="Keyword">proc</span> <a href="#rope%2Cstring"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">&quot;&quot;</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1Str&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  369. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  370. <dd>
  371. Converts a string to a rope.
  372. <p><strong class="examples_text">Example:</strong></p>
  373. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;I'm a rope&quot;</span><span class="Punctuation">)</span>
  374. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">&quot;I'm a rope&quot;</span></pre>
  375. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L130" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  376. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L130" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  377. </dd>
  378. </div>
  379. </div>
  380. <div id="write-procs-all">
  381. <div id="write,File,Rope">
  382. <dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2CRope"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nro$1&quot;</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
  383. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  384. <dd>
  385. Writes a rope to a file.
  386. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L283" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  387. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L283" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  388. </dd>
  389. </div>
  390. <div id="write,Stream,Rope">
  391. <dt><pre><span class="Keyword">proc</span> <a href="#write%2CStream%2CRope"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">&quot;nroWriteStream&quot;</span><span class="Other">,</span>
  392. <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
  393. <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  394. <dd>
  395. Writes a rope to a stream.
  396. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L287" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  397. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L287" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  398. </dd>
  399. </div>
  400. </div>
  401. </dl>
  402. </div>
  403. <div class="section" id="15">
  404. <h1><a class="toc-backref" href="#15">Iterators</a></h1>
  405. <dl class="item">
  406. <div id="items-iterators-all">
  407. <div id="items.i,Rope">
  408. <dt><pre><span class="Keyword">iterator</span> <a href="#items.i%2CRope"><span class="Identifier">items</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  409. <dd>
  410. Iterates over any character in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
  411. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L278" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  412. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L278" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  413. </dd>
  414. </div>
  415. </div>
  416. <div id="leaves-iterators-all">
  417. <div id="leaves.i,Rope">
  418. <dt><pre><span class="Keyword">iterator</span> <a href="#leaves.i%2CRope"><span class="Identifier">leaves</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  419. <dd>
  420. Iterates over any leaf string in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
  421. <p><strong class="examples_text">Example:</strong></p>
  422. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;Hello&quot;</span><span class="Punctuation">)</span> <span class="Operator">&amp;</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">&quot;, Nim!&quot;</span><span class="Punctuation">)</span>
  423. <span class="Keyword">let</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">&quot;Hello&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;, Nim!&quot;</span><span class="Punctuation">]</span>
  424. <span class="Keyword">var</span> <span class="Identifier">index</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
  425. <span class="Keyword">for</span> <span class="Identifier">leave</span> <span class="Keyword">in</span> <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">leaves</span><span class="Punctuation">:</span>
  426. <span class="Identifier">doAssert</span> <span class="Identifier">leave</span> <span class="Operator">==</span> <span class="Identifier">s</span><span class="Punctuation">[</span><span class="Identifier">index</span><span class="Punctuation">]</span>
  427. <span class="Identifier">inc</span><span class="Punctuation">(</span><span class="Identifier">index</span><span class="Punctuation">)</span></pre>
  428. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L257" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  429. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L257" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  430. </dd>
  431. </div>
  432. </div>
  433. </dl>
  434. </div>
  435. </div>
  436. </div>
  437. <div class="twelve-columns footer">
  438. <span class="nim-sprite"></span>
  439. <br>
  440. <small style="color: var(--hint);">Made with Nim. Generated: 2025-01-09 12:00:09 UTC</small>
  441. </div>
  442. </div>
  443. </div>
  444. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  445. </body>
  446. </html>