critbits.html 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  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/critbits</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/critbits</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="#CritBitTree" title="CritBitTree[T] = object">CritBitTree</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%2CCritBitTree%5BT%5D" title="`$`[T](c: CritBitTree[T]): string">`$`[T](c: CritBitTree[T]): string</a></li>
  66. </ul>
  67. <ul class="simple nested-toc-section">[]
  68. <li><a class="reference" href="#%5B%5D%2CCritBitTree%5BT%5D%2Cstring" title="`[]`[T](c: CritBitTree[T]; key: string): lent T">`[]`[T](c: CritBitTree[T]; key: string): lent T</a></li>
  69. <li><a class="reference" href="#%5B%5D%2CCritBitTree%5BT%5D%2Cstring_2" title="`[]`[T](c: var CritBitTree[T]; key: string): var T">`[]`[T](c: var CritBitTree[T]; key: string): var T</a></li>
  70. </ul>
  71. <ul class="simple nested-toc-section">[]=
  72. <li><a class="reference" href="#%5B%5D%3D%2CCritBitTree%5BT%5D%2Cstring%2CsinkT" title="`[]=`[T](c: var CritBitTree[T]; key: string; val: sink T)">`[]=`[T](c: var CritBitTree[T]; key: string; val: sink T)</a></li>
  73. </ul>
  74. <ul class="simple nested-toc-section">commonPrefixLen
  75. <li><a class="reference" href="#commonPrefixLen%2CCritBitTree%5BT%5D" title="commonPrefixLen[T](c: CritBitTree[T]): int">commonPrefixLen[T](c: CritBitTree[T]): int</a></li>
  76. </ul>
  77. <ul class="simple nested-toc-section">contains
  78. <li><a class="reference" href="#contains%2CCritBitTree%5BT%5D%2Cstring" title="contains[T](c: CritBitTree[T]; key: string): bool">contains[T](c: CritBitTree[T]; key: string): bool</a></li>
  79. </ul>
  80. <ul class="simple nested-toc-section">containsOrIncl
  81. <li><a class="reference" href="#containsOrIncl%2CCritBitTree%5Bvoid%5D%2Cstring" title="containsOrIncl(c: var CritBitTree[void]; key: string): bool">containsOrIncl(c: var CritBitTree[void]; key: string): bool</a></li>
  82. <li><a class="reference" href="#containsOrIncl%2CCritBitTree%5BT%5D%2Cstring%2CsinkT" title="containsOrIncl[T](c: var CritBitTree[T]; key: string; val: sink T): bool">containsOrIncl[T](c: var CritBitTree[T]; key: string; val: sink T): bool</a></li>
  83. </ul>
  84. <ul class="simple nested-toc-section">excl
  85. <li><a class="reference" href="#excl%2CCritBitTree%5BT%5D%2Cstring" title="excl[T](c: var CritBitTree[T]; key: string)">excl[T](c: var CritBitTree[T]; key: string)</a></li>
  86. </ul>
  87. <ul class="simple nested-toc-section">hasKey
  88. <li><a class="reference" href="#hasKey%2CCritBitTree%5BT%5D%2Cstring" title="hasKey[T](c: CritBitTree[T]; key: string): bool">hasKey[T](c: CritBitTree[T]; key: string): bool</a></li>
  89. </ul>
  90. <ul class="simple nested-toc-section">inc
  91. <li><a class="reference" href="#inc%2CCritBitTree%5Bint%5D%2Cstring%2Cint" title="inc(c: var CritBitTree[int]; key: string; val: int = 1)">inc(c: var CritBitTree[int]; key: string; val: int = 1)</a></li>
  92. </ul>
  93. <ul class="simple nested-toc-section">incl
  94. <li><a class="reference" href="#incl%2CCritBitTree%5Bvoid%5D%2Cstring" title="incl(c: var CritBitTree[void]; key: string)">incl(c: var CritBitTree[void]; key: string)</a></li>
  95. <li><a class="reference" href="#incl%2CCritBitTree%5BT%5D%2Cstring%2CsinkT" title="incl[T](c: var CritBitTree[T]; key: string; val: sink T)">incl[T](c: var CritBitTree[T]; key: string; val: sink T)</a></li>
  96. </ul>
  97. <ul class="simple nested-toc-section">len
  98. <li><a class="reference" href="#len%2CCritBitTree%5BT%5D" title="len[T](c: CritBitTree[T]): int">len[T](c: CritBitTree[T]): int</a></li>
  99. </ul>
  100. <ul class="simple nested-toc-section">missingOrExcl
  101. <li><a class="reference" href="#missingOrExcl%2CCritBitTree%5BT%5D%2Cstring" title="missingOrExcl[T](c: var CritBitTree[T]; key: string): bool">missingOrExcl[T](c: var CritBitTree[T]; key: string): bool</a></li>
  102. </ul>
  103. <ul class="simple nested-toc-section">toCritBitTree
  104. <li><a class="reference" href="#toCritBitTree%2CsinkopenArray%5Bstring%5D" title="toCritBitTree(items: sink openArray[string]): CritBitTree[void]">toCritBitTree(items: sink openArray[string]): CritBitTree[void]</a></li>
  105. <li><a class="reference" href="#toCritBitTree%2CsinkopenArray%5B%5D" title="toCritBitTree[T](pairs: sink openArray[(string, T)]): CritBitTree[T]">toCritBitTree[T](pairs: sink openArray[(string, T)]): CritBitTree[T]</a></li>
  106. </ul>
  107. </ul>
  108. </details>
  109. </li>
  110. <li>
  111. <details open>
  112. <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
  113. <ul class="simple simple-toc-section">
  114. <ul class="simple nested-toc-section">items
  115. <li><a class="reference" href="#items.i%2CCritBitTree%5BT%5D" title="items[T](c: CritBitTree[T]): string">items[T](c: CritBitTree[T]): string</a></li>
  116. </ul>
  117. <ul class="simple nested-toc-section">itemsWithPrefix
  118. <li><a class="reference" href="#itemsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="itemsWithPrefix[T](c: CritBitTree[T]; prefix: string): string">itemsWithPrefix[T](c: CritBitTree[T]; prefix: string): string</a></li>
  119. </ul>
  120. <ul class="simple nested-toc-section">keys
  121. <li><a class="reference" href="#keys.i%2CCritBitTree%5BT%5D" title="keys[T](c: CritBitTree[T]): string">keys[T](c: CritBitTree[T]): string</a></li>
  122. </ul>
  123. <ul class="simple nested-toc-section">keysWithPrefix
  124. <li><a class="reference" href="#keysWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="keysWithPrefix[T](c: CritBitTree[T]; prefix: string): string">keysWithPrefix[T](c: CritBitTree[T]; prefix: string): string</a></li>
  125. </ul>
  126. <ul class="simple nested-toc-section">mpairs
  127. <li><a class="reference" href="#mpairs.i%2CCritBitTree%5BT%5D" title="mpairs[T](c: var CritBitTree[T]): tuple[key: string, val: var T]">mpairs[T](c: var CritBitTree[T]): tuple[key: string, val: var T]</a></li>
  128. </ul>
  129. <ul class="simple nested-toc-section">mpairsWithPrefix
  130. <li><a class="reference" href="#mpairsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="mpairsWithPrefix[T](c: var CritBitTree[T]; prefix: string): tuple[key: string,
  131. val: var T]">mpairsWithPrefix[T](c: var CritBitTree[T]; prefix: string): tuple[key: string,
  132. val: var T]</a></li>
  133. </ul>
  134. <ul class="simple nested-toc-section">mvalues
  135. <li><a class="reference" href="#mvalues.i%2CCritBitTree%5BT%5D" title="mvalues[T](c: var CritBitTree[T]): var T">mvalues[T](c: var CritBitTree[T]): var T</a></li>
  136. </ul>
  137. <ul class="simple nested-toc-section">mvaluesWithPrefix
  138. <li><a class="reference" href="#mvaluesWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="mvaluesWithPrefix[T](c: var CritBitTree[T]; prefix: string): var T">mvaluesWithPrefix[T](c: var CritBitTree[T]; prefix: string): var T</a></li>
  139. </ul>
  140. <ul class="simple nested-toc-section">pairs
  141. <li><a class="reference" href="#pairs.i%2CCritBitTree%5BT%5D" title="pairs[T](c: CritBitTree[T]): tuple[key: string, val: T]">pairs[T](c: CritBitTree[T]): tuple[key: string, val: T]</a></li>
  142. </ul>
  143. <ul class="simple nested-toc-section">pairsWithPrefix
  144. <li><a class="reference" href="#pairsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="pairsWithPrefix[T](c: CritBitTree[T]; prefix: string): tuple[key: string, val: T]">pairsWithPrefix[T](c: CritBitTree[T]; prefix: string): tuple[key: string, val: T]</a></li>
  145. </ul>
  146. <ul class="simple nested-toc-section">values
  147. <li><a class="reference" href="#values.i%2CCritBitTree%5BT%5D" title="values[T](c: CritBitTree[T]): lent T">values[T](c: CritBitTree[T]): lent T</a></li>
  148. </ul>
  149. <ul class="simple nested-toc-section">valuesWithPrefix
  150. <li><a class="reference" href="#valuesWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="valuesWithPrefix[T](c: CritBitTree[T]; prefix: string): lent T">valuesWithPrefix[T](c: CritBitTree[T]; prefix: string): lent T</a></li>
  151. </ul>
  152. </ul>
  153. </details>
  154. </li>
  155. </ul>
  156. </div>
  157. <div class="nine columns" id="content">
  158. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L1" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  159. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L1" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  160. <div id="tocRoot"></div>
  161. <p class="module-desc">This module implements a <span id="crit-bit-tree_1">crit bit tree</span> which is an efficient container for a sorted set of strings, or for a sorted mapping of strings. Based on the <a class="reference external" href="https://www.imperialviolet.org/binary/critbit.pdf">excellent paper by Adam Langley</a>. (A crit bit tree is a form of <span id="radix-tree_1">radix tree</span> or <span id="patricia-trie_1">patricia trie</span>.)
  162. <p><strong class="examples_text">Example:</strong></p>
  163. <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">critbits</span>
  164. <span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  165. <span class="Keyword">var</span> <span class="Identifier">critbitAsSet</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">&quot;kitten&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;puppy&quot;</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  166. <span class="Identifier">doAssert</span> <span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
  167. <span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">incl</span><span class="Punctuation">(</span><span class="StringLit">&quot;&quot;</span><span class="Punctuation">)</span>
  168. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;&quot;</span> <span class="Keyword">in</span> <span class="Identifier">critbitAsSet</span>
  169. <span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">excl</span><span class="Punctuation">(</span><span class="StringLit">&quot;&quot;</span><span class="Punctuation">)</span>
  170. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;&quot;</span> <span class="Keyword">notin</span> <span class="Identifier">critbitAsSet</span>
  171. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">items</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;kitten&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;puppy&quot;</span><span class="Punctuation">]</span>
  172. <span class="Keyword">let</span> <span class="Identifier">same</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">&quot;puppy&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;kitten&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;puppy&quot;</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  173. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">same</span><span class="Operator">.</span><span class="Identifier">keys</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">keys</span><span class="Punctuation">)</span>
  174. <span class="Keyword">var</span> <span class="Identifier">critbitAsDict</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  175. <span class="Identifier">doAssert</span> <span class="Identifier">critbitAsDict</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
  176. <span class="Identifier">critbitAsDict</span><span class="Punctuation">[</span><span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
  177. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;key2&quot;</span> <span class="Keyword">in</span> <span class="Identifier">critbitAsDict</span>
  178. <span class="Identifier">doAssert</span> <span class="Identifier">critbitAsDict</span><span class="Punctuation">[</span><span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  179. <span class="Identifier">critbitAsDict</span><span class="Operator">.</span><span class="Identifier">excl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">)</span>
  180. <span class="Identifier">doAssert</span> <span class="StringLit">&quot;key1&quot;</span> <span class="Keyword">notin</span> <span class="Identifier">critbitAsDict</span>
  181. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">critbitAsDict</span><span class="Operator">.</span><span class="Identifier">pairs</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre></p>
  182. <div class="section" id="6">
  183. <h1><a class="toc-backref" href="#6">Imports</a></h1>
  184. <dl class="item">
  185. <a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>
  186. </dl>
  187. </div>
  188. <div class="section" id="7">
  189. <h1><a class="toc-backref" href="#7">Types</a></h1>
  190. <dl class="item">
  191. <div id="CritBitTree">
  192. <dt><pre><a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">object</span></pre></dt>
  193. <dd>
  194. The crit bit tree can either be used as a mapping from strings to some type <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt> or as a set of strings if <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">void</span></span></tt>.
  195. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L54" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  196. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L54" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  197. </dd>
  198. </div>
  199. </dl>
  200. </div>
  201. <div class="section" id="12">
  202. <h1><a class="toc-backref" href="#12">Procs</a></h1>
  203. <dl class="item">
  204. <div id="$-procs-all">
  205. <div id="$,CritBitTree[T]">
  206. <dt><pre><span class="Keyword">func</span> <a href="#%24%2CCritBitTree%5BT%5D"><span class="Identifier">`$`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a></pre></dt>
  207. <dd>
  208. Turns <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> into a string representation.
  209. <p><strong class="examples_text">Example:</strong></p>
  210. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">default</span> <span class="Operator">==</span> <span class="StringLit">&quot;{:}&quot;</span>
  211. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">toCritBitTree</span><span class="Punctuation">(</span><span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">}</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;{&quot;key1&quot;: 1, &quot;key2&quot;: 2}&quot;&quot;&quot;</span>
  212. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">default</span> <span class="Operator">==</span> <span class="StringLit">&quot;{}&quot;</span>
  213. <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">toCritBitTree</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="LongStringLit">&quot;&quot;&quot;{&quot;key1&quot;, &quot;key2&quot;}&quot;&quot;&quot;</span></pre>
  214. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L477" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  215. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L477" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  216. </dd>
  217. </div>
  218. </div>
  219. <div id="[]-procs-all">
  220. <div id="[],CritBitTree[T],string">
  221. <dt><pre><span class="Keyword">func</span> <a href="#%5B%5D%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">`[]`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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#lent"><span class="Identifier">lent</span></a> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
  222. <dd>
  223. <p>Retrieves the value at <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span><span class="Punctuation">[</span><span class="Identifier">key</span><span class="Punctuation">]</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> is not in <tt class="docutils literal"><span class="pre"><span class="Identifier">t</span></span></tt>, the <tt class="docutils literal"><span class="pre"><span class="Identifier">KeyError</span></span></tt> exception is raised. One can check with <tt class="docutils literal"><span class="pre"><span class="Identifier">hasKey</span></span></tt> whether the key exists.</p>
  224. <p><strong>See also:</strong></p>
  225. <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string_2">[] proc</a></li>
  226. <li><a class="reference external" href="#[]=,CritBitTree[T],string,T">[]= proc</a></li>
  227. </ul>
  228. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L307" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  229. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L307" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  230. </dd>
  231. </div>
  232. <div id="[],CritBitTree[T],string_2">
  233. <dt><pre><span class="Keyword">func</span> <a href="#%5B%5D%2CCritBitTree%5BT%5D%2Cstring_2"><span class="Identifier">`[]`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
  234. <dd>
  235. <p>Retrieves the value at <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span><span class="Punctuation">[</span><span class="Identifier">key</span><span class="Punctuation">]</span></span></tt>. The value can be modified. If <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> is not in <tt class="docutils literal"><span class="pre"><span class="Identifier">t</span></span></tt>, the <tt class="docutils literal"><span class="pre"><span class="Identifier">KeyError</span></span></tt> exception is raised.</p>
  236. <p><strong>See also:</strong></p>
  237. <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string">[] proc</a></li>
  238. <li><a class="reference external" href="#[]=,CritBitTree[T],string,T">[]= proc</a></li>
  239. </ul>
  240. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L317" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  241. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L317" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  242. </dd>
  243. </div>
  244. </div>
  245. <div id="[]=-procs-all">
  246. <div id="[]=,CritBitTree[T],string,sinkT">
  247. <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%3D%2CCritBitTree%5BT%5D%2Cstring%2CsinkT"><span class="Identifier">`[]=`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
  248. <dd>
  249. <p>Alias for <a class="reference external" href="#incl,CritBitTree[T],string,T">incl</a>.</p>
  250. <p><strong>See also:</strong></p>
  251. <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string">[] proc</a></li>
  252. <li><a class="reference external" href="#[],CritBitTree[T],string_2">[] proc</a></li>
  253. </ul>
  254. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L291" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  255. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L291" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  256. </dd>
  257. </div>
  258. </div>
  259. <div id="commonPrefixLen-procs-all">
  260. <div id="commonPrefixLen,CritBitTree[T]">
  261. <dt><pre><span class="Keyword">func</span> <a href="#commonPrefixLen%2CCritBitTree%5BT%5D"><span class="Identifier">commonPrefixLen</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
  262. <dd>
  263. Returns the length of the longest common prefix of all keys in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> is empty, returns 0.
  264. <p><strong class="examples_text">Example:</strong></p>
  265. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  266. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">commonPrefixLen</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
  267. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">)</span>
  268. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">commonPrefixLen</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
  269. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">)</span>
  270. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">commonPrefixLen</span> <span class="Operator">==</span> <span class="DecNumber">3</span></pre>
  271. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L510" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  272. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L510" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  273. </dd>
  274. </div>
  275. </div>
  276. <div id="contains-procs-all">
  277. <div id="contains,CritBitTree[T],string">
  278. <dt><pre><span class="Keyword">func</span> <a href="#contains%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">contains</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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 class="Identifier">inline</span>.}</pre></dt>
  279. <dd>
  280. Returns true if <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> contains the given <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>.
  281. <p><strong class="examples_text">Example:</strong></p>
  282. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  283. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  284. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">contains</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span></pre>
  285. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L80" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  286. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L80" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  287. </dd>
  288. </div>
  289. </div>
  290. <div id="containsOrIncl-procs-all">
  291. <div id="containsOrIncl,CritBitTree[void],string">
  292. <dt><pre><span class="Keyword">proc</span> <a href="#containsOrIncl%2CCritBitTree%5Bvoid%5D%2Cstring"><span class="Identifier">containsOrIncl</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
  293. <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. <p>Returns true if <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> contains the given <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>. If the key does not exist, it is inserted into <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt>.</p>
  296. <p><strong>See also:</strong></p>
  297. <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
  298. <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
  299. <li><a class="reference external" href="#containsOrIncl,CritBitTree[T],string,T">containsOrIncl proc</a></li>
  300. <li><a class="reference external" href="#missingOrExcl,CritBitTree[T],string">missingOrExcl proc</a></li>
  301. </ul>
  302. <p><strong class="examples_text">Example:</strong></p>
  303. <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
  304. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  305. <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">containsOrIncl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  306. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">contains</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  307. <span class="Keyword">block</span><span class="Punctuation">:</span>
  308. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  309. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  310. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">containsOrIncl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span></pre>
  311. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L230" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  312. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L230" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  313. </dd>
  314. </div>
  315. <div id="containsOrIncl,CritBitTree[T],string,sinkT">
  316. <dt><pre><span class="Keyword">proc</span> <a href="#containsOrIncl%2CCritBitTree%5BT%5D%2Cstring%2CsinkT"><span class="Identifier">containsOrIncl</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
  317. <dd>
  318. <p>Returns true if <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> contains the given <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>. If the key does not exist, <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span><span class="Punctuation">[</span><span class="Identifier">key</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="Identifier">val</span></span></tt> is performed.</p>
  319. <p><strong>See also:</strong></p>
  320. <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
  321. <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
  322. <li><a class="reference external" href="#containsOrIncl,CritBitTree[void],string">containsOrIncl proc</a></li>
  323. <li><a class="reference external" href="#missingOrExcl,CritBitTree[T],string">missingOrExcl proc</a></li>
  324. </ul>
  325. <p><strong class="examples_text">Example:</strong></p>
  326. <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
  327. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
  328. <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">containsOrIncl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
  329. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">contains</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  330. <span class="Keyword">block</span><span class="Punctuation">:</span>
  331. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
  332. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">21</span><span class="Punctuation">)</span>
  333. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">containsOrIncl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
  334. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">21</span></pre>
  335. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L204" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  336. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L204" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  337. </dd>
  338. </div>
  339. </div>
  340. <div id="excl-procs-all">
  341. <div id="excl,CritBitTree[T],string">
  342. <dt><pre><span class="Keyword">proc</span> <a href="#excl%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">excl</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span></pre></dt>
  343. <dd>
  344. <p>Removes <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> (and its associated value) from the set <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt>. If the <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> does not exist, nothing happens.</p>
  345. <p><strong>See also:</strong></p>
  346. <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
  347. <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
  348. </ul>
  349. <p><strong class="examples_text">Example:</strong></p>
  350. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  351. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  352. <span class="Identifier">excl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  353. <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">contains</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span></pre>
  354. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L167" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  355. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L167" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  356. </dd>
  357. </div>
  358. </div>
  359. <div id="hasKey-procs-all">
  360. <div id="hasKey,CritBitTree[T],string">
  361. <dt><pre><span class="Keyword">func</span> <a href="#hasKey%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">hasKey</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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 class="Identifier">inline</span>.}</pre></dt>
  362. <dd>
  363. Alias for <a class="reference external" href="#contains,CritBitTree[T],string">contains</a>.
  364. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L89" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  365. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L89" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  366. </dd>
  367. </div>
  368. </div>
  369. <div id="inc-procs-all">
  370. <div id="inc,CritBitTree[int],string,int">
  371. <dt><pre><span class="Keyword">proc</span> <a href="#inc%2CCritBitTree%5Bint%5D%2Cstring%2Cint"><span class="Identifier">inc</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> <span class="Other">=</span> <span class="DecNumber">1</span><span class="Other">)</span> {.<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>
  372. <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>
  373. <dd>
  374. Increments <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span><span class="Punctuation">[</span><span class="Identifier">key</span><span class="Punctuation">]</span></span></tt> by <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.
  375. <p><strong class="examples_text">Example:</strong></p>
  376. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
  377. <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
  378. <span class="Identifier">inc</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  379. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  380. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L253" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  381. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L253" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  382. </dd>
  383. </div>
  384. </div>
  385. <div id="incl-procs-all">
  386. <div id="incl,CritBitTree[void],string">
  387. <dt><pre><span class="Keyword">proc</span> <a href="#incl%2CCritBitTree%5Bvoid%5D%2Cstring"><span class="Identifier">incl</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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">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>
  388. <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
  389. <dd>
  390. <p>Includes <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt>.</p>
  391. <p><strong>See also:</strong></p>
  392. <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
  393. <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
  394. </ul>
  395. <p><strong class="examples_text">Example:</strong></p>
  396. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  397. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  398. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">hasKey</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span></pre>
  399. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L264" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  400. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L264" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  401. </dd>
  402. </div>
  403. <div id="incl,CritBitTree[T],string,sinkT">
  404. <dt><pre><span class="Keyword">proc</span> <a href="#incl%2CCritBitTree%5BT%5D%2Cstring%2CsinkT"><span class="Identifier">incl</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
  405. <dd>
  406. <p>Inserts <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> with value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt>.</p>
  407. <p><strong>See also:</strong></p>
  408. <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
  409. <li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
  410. </ul>
  411. <p><strong class="examples_text">Example:</strong></p>
  412. <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
  413. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
  414. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">42</span></pre>
  415. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L277" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  416. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L277" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  417. </dd>
  418. </div>
  419. </div>
  420. <div id="len-procs-all">
  421. <div id="len,CritBitTree[T]">
  422. <dt><pre><span class="Keyword">func</span> <a href="#len%2CCritBitTree%5BT%5D"><span class="Identifier">len</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
  423. <dd>
  424. Returns the number of elements in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in O(1).
  425. <p><strong class="examples_text">Example:</strong></p>
  426. <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  427. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
  428. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L61" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  429. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L61" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  430. </dd>
  431. </div>
  432. </div>
  433. <div id="missingOrExcl-procs-all">
  434. <div id="missingOrExcl,CritBitTree[T],string">
  435. <dt><pre><span class="Keyword">proc</span> <a href="#missingOrExcl%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">missingOrExcl</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</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></pre></dt>
  436. <dd>
  437. <p>Returns true if <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> does not contain the given <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>. If the key does exist, <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">excl</span><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">)</span></span></tt> is performed.</p>
  438. <p><strong>See also:</strong></p>
  439. <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
  440. <li><a class="reference external" href="#containsOrIncl,CritBitTree[T],string,T">containsOrIncl proc</a></li>
  441. <li><a class="reference external" href="#containsOrIncl,CritBitTree[void],string">containsOrIncl proc</a></li>
  442. </ul>
  443. <p><strong class="examples_text">Example:</strong></p>
  444. <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
  445. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  446. <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">missingOrExcl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  447. <span class="Keyword">block</span><span class="Punctuation">:</span>
  448. <span class="Keyword">var</span> <span class="Identifier">c</span><span class="Punctuation">:</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span>
  449. <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  450. <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">missingOrExcl</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span>
  451. <span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">contains</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span></pre>
  452. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L182" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  453. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L182" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  454. </dd>
  455. </div>
  456. </div>
  457. <div id="toCritBitTree-procs-all">
  458. <div id="toCritBitTree,sinkopenArray[string]">
  459. <dt><pre><span class="Keyword">proc</span> <a href="#toCritBitTree%2CsinkopenArray%5Bstring%5D"><span class="Identifier">toCritBitTree</span></a><span class="Other">(</span><span class="Identifier">items</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.
  460. <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>
  461. <dd>
  462. Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">CritBitTree</span></span></tt> that contains the given <tt class="docutils literal"><span class="pre"><span class="Identifier">items</span></span></tt>.
  463. <p><strong class="examples_text">Example:</strong></p>
  464. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Punctuation">[</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;b&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;c&quot;</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span> <span class="Keyword">is</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></pre>
  465. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L534" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  466. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L534" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  467. </dd>
  468. </div>
  469. <div id="toCritBitTree,sinkopenArray[]">
  470. <dt><pre><span class="Keyword">proc</span> <a href="#toCritBitTree%2CsinkopenArray%5B%5D"><span class="Identifier">toCritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">pairs</span><span class="Other">:</span> <a href="system.html#sink"><span class="Identifier">sink</span></a> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Other">(</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  471. <dd>
  472. Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">CritBitTree</span></span></tt> that contains the given <tt class="docutils literal"><span class="pre"><span class="Identifier">pairs</span></span></tt>.
  473. <p><strong class="examples_text">Example:</strong></p>
  474. <pre class="listing"><span class="Identifier">doAssert</span> <span class="Punctuation">{</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;0&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;b&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;1&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;c&quot;</span><span class="Punctuation">:</span> <span class="StringLit">&quot;2&quot;</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span> <span class="Keyword">is</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span>
  475. <span class="Identifier">doAssert</span> <span class="Punctuation">{</span><span class="StringLit">&quot;a&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="StringLit">&quot;b&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;c&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span> <span class="Keyword">is</span> <span class="Identifier">CritBitTree</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span></pre>
  476. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L526" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  477. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L526" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  478. </dd>
  479. </div>
  480. </div>
  481. </dl>
  482. </div>
  483. <div class="section" id="15">
  484. <h1><a class="toc-backref" href="#15">Iterators</a></h1>
  485. <dl class="item">
  486. <div id="items-iterators-all">
  487. <div id="items.i,CritBitTree[T]">
  488. <dt><pre><span class="Keyword">iterator</span> <a href="#items.i%2CCritBitTree%5BT%5D"><span class="Identifier">items</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a></pre></dt>
  489. <dd>
  490. Alias for <a class="reference external" href="#keys.i,CritBitTree[T]">keys</a>.
  491. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L371" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  492. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L371" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  493. </dd>
  494. </div>
  495. </div>
  496. <div id="itemsWithPrefix-iterators-all">
  497. <div id="itemsWithPrefix.i,CritBitTree[T],string">
  498. <dt><pre><span class="Keyword">iterator</span> <a href="#itemsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">itemsWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</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#string"><span class="Identifier">string</span></a></pre></dt>
  499. <dd>
  500. Alias for <a class="reference external" href="#keysWithPrefix.i,CritBitTree[T],string">keysWithPrefix</a>.
  501. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L447" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  502. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L447" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  503. </dd>
  504. </div>
  505. </div>
  506. <div id="keys-iterators-all">
  507. <div id="keys.i,CritBitTree[T]">
  508. <dt><pre><span class="Keyword">iterator</span> <a href="#keys.i%2CCritBitTree%5BT%5D"><span class="Identifier">keys</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a></pre></dt>
  509. <dd>
  510. Yields all keys in lexicographical order.
  511. <p><strong class="examples_text">Example:</strong></p>
  512. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  513. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  514. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">keys</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span></pre>
  515. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L339" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  516. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L339" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  517. </dd>
  518. </div>
  519. </div>
  520. <div id="keysWithPrefix-iterators-all">
  521. <div id="keysWithPrefix.i,CritBitTree[T],string">
  522. <dt><pre><span class="Keyword">iterator</span> <a href="#keysWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">keysWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</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#string"><span class="Identifier">string</span></a></pre></dt>
  523. <dd>
  524. Yields all keys starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt>.
  525. <p><strong class="examples_text">Example:</strong></p>
  526. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  527. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  528. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">keysWithPrefix</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">]</span></pre>
  529. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L412" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  530. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L412" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  531. </dd>
  532. </div>
  533. </div>
  534. <div id="mpairs-iterators-all">
  535. <div id="mpairs.i,CritBitTree[T]">
  536. <dt><pre><span class="Keyword">iterator</span> <a href="#mpairs.i%2CCritBitTree%5BT%5D"><span class="Identifier">mpairs</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  537. <dd>
  538. <p>Yields all <tt class="docutils literal"><span class="pre"><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">)</span></span></tt>-pairs of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in the lexicographical order of the corresponding keys. The yielded values can be modified.</p>
  539. <p><strong>See also:</strong></p>
  540. <ul class="simple"><li><a class="reference external" href="#pairs.i,CritBitTree[T]">pairs iterator</a></li>
  541. </ul>
  542. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L389" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  543. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L389" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  544. </dd>
  545. </div>
  546. </div>
  547. <div id="mpairsWithPrefix-iterators-all">
  548. <div id="mpairsWithPrefix.i,CritBitTree[T],string">
  549. <dt><pre><span class="Keyword">iterator</span> <a href="#mpairsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">mpairsWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span>
  550. <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  551. <dd>
  552. <p>Yields all (key, value)-pairs of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt>. The yielded values can be modified.</p>
  553. <p><strong>See also:</strong></p>
  554. <ul class="simple"><li><a class="reference external" href="#pairsWithPrefix.i,CritBitTree[T],string">pairsWithPrefix iterator</a></li>
  555. </ul>
  556. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L467" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  557. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L467" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  558. </dd>
  559. </div>
  560. </div>
  561. <div id="mvalues-iterators-all">
  562. <div id="mvalues.i,CritBitTree[T]">
  563. <dt><pre><span class="Keyword">iterator</span> <a href="#mvalues.i%2CCritBitTree%5BT%5D"><span class="Identifier">mvalues</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span></pre></dt>
  564. <dd>
  565. <p>Yields all values of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in the lexicographical order of the corresponding keys. The values can be modified.</p>
  566. <p><strong>See also:</strong></p>
  567. <ul class="simple"><li><a class="reference external" href="#values.i,CritBitTree[T]">values iterator</a></li>
  568. </ul>
  569. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L363" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  570. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L363" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  571. </dd>
  572. </div>
  573. </div>
  574. <div id="mvaluesWithPrefix-iterators-all">
  575. <div id="mvaluesWithPrefix.i,CritBitTree[T],string">
  576. <dt><pre><span class="Keyword">iterator</span> <a href="#mvaluesWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">mvaluesWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span></pre></dt>
  577. <dd>
  578. <p>Yields all values of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt> of the corresponding keys. The values can be modified.</p>
  579. <p><strong>See also:</strong></p>
  580. <ul class="simple"><li><a class="reference external" href="#valuesWithPrefix.i,CritBitTree[T],string">valuesWithPrefix iterator</a></li>
  581. </ul>
  582. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L438" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  583. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L438" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  584. </dd>
  585. </div>
  586. </div>
  587. <div id="pairs-iterators-all">
  588. <div id="pairs.i,CritBitTree[T]">
  589. <dt><pre><span class="Keyword">iterator</span> <a href="#pairs.i%2CCritBitTree%5BT%5D"><span class="Identifier">pairs</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  590. <dd>
  591. <p>Yields all <tt class="docutils literal"><span class="pre"><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">,</span> <span class="Identifier">value</span><span class="Punctuation">)</span></span></tt>-pairs of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in the lexicographical order of the corresponding keys.</p>
  592. <p><strong>See also:</strong></p>
  593. <ul class="simple"><li><a class="reference external" href="#mpairs.i,CritBitTree[T]">mpairs iterator</a></li>
  594. </ul>
  595. <p><strong class="examples_text">Example:</strong></p>
  596. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  597. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  598. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">pairs</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="Identifier">val</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">,</span> <span class="Identifier">val</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
  599. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L375" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  600. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L375" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  601. </dd>
  602. </div>
  603. </div>
  604. <div id="pairsWithPrefix-iterators-all">
  605. <div id="pairsWithPrefix.i,CritBitTree[T],string">
  606. <dt><pre><span class="Keyword">iterator</span> <a href="#pairsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">pairsWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span>
  607. <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">]</span></pre></dt>
  608. <dd>
  609. <p>Yields all (key, value)-pairs of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt>.</p>
  610. <p><strong>See also:</strong></p>
  611. <ul class="simple"><li><a class="reference external" href="#mpairsWithPrefix.i,CritBitTree[T],string">mpairsWithPrefix iterator</a></li>
  612. </ul>
  613. <p><strong class="examples_text">Example:</strong></p>
  614. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  615. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  616. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">pairsWithPrefix</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">,</span> <span class="Identifier">val</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">key</span><span class="Punctuation">:</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">,</span> <span class="Identifier">val</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
  617. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L452" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  618. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L452" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  619. </dd>
  620. </div>
  621. </div>
  622. <div id="values-iterators-all">
  623. <div id="values.i,CritBitTree[T]">
  624. <dt><pre><span class="Keyword">iterator</span> <a href="#values.i%2CCritBitTree%5BT%5D"><span class="Identifier">values</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#lent"><span class="Identifier">lent</span></a> <span class="Identifier">T</span></pre></dt>
  625. <dd>
  626. <p>Yields all values of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in the lexicographical order of the corresponding keys.</p>
  627. <p><strong>See also:</strong></p>
  628. <ul class="simple"><li><a class="reference external" href="#mvalues.i,CritBitTree[T]">mvalues iterator</a></li>
  629. </ul>
  630. <p><strong class="examples_text">Example:</strong></p>
  631. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  632. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">2</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  633. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">values</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span></pre>
  634. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L349" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  635. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L349" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  636. </dd>
  637. </div>
  638. </div>
  639. <div id="valuesWithPrefix-iterators-all">
  640. <div id="valuesWithPrefix.i,CritBitTree[T],string">
  641. <dt><pre><span class="Keyword">iterator</span> <a href="#valuesWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring"><span class="Identifier">valuesWithPrefix</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="critbits.html#CritBitTree"><span class="Identifier">CritBitTree</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">prefix</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#lent"><span class="Identifier">lent</span></a> <span class="Identifier">T</span></pre></dt>
  642. <dd>
  643. <p>Yields all values of <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt> of the corresponding keys.</p>
  644. <p><strong>See also:</strong></p>
  645. <ul class="simple"><li><a class="reference external" href="#mvaluesWithPrefix.i,CritBitTree[T],string">mvaluesWithPrefix iterator</a></li>
  646. </ul>
  647. <p><strong class="examples_text">Example:</strong></p>
  648. <pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sequtils</span> <span class="Keyword">import</span> <span class="Identifier">toSeq</span>
  649. <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">&quot;key1&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">&quot;key2&quot;</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
  650. <span class="Identifier">doAssert</span> <span class="Identifier">toSeq</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">valuesWithPrefix</span><span class="Punctuation">(</span><span class="StringLit">&quot;key&quot;</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="DecNumber">43</span><span class="Punctuation">]</span></pre>
  651. <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L423" class="link-seesrc" target="_blank">Source</a>&nbsp;&nbsp;
  652. <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L423" class="link-seesrc" target="_blank" >Edit</a>&nbsp;&nbsp;
  653. </dd>
  654. </div>
  655. </div>
  656. </dl>
  657. </div>
  658. </div>
  659. </div>
  660. <div class="twelve-columns footer">
  661. <span class="nim-sprite"></span>
  662. <br>
  663. <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:14 UTC</small>
  664. </div>
  665. </div>
  666. </div>
  667. <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
  668. </body>
  669. </html>