123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/critbits</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <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=="/>
- <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=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/critbits</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#CritBitTree" title="CritBitTree[T] = object">CritBitTree</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">$
- <li><a class="reference" href="#%24%2CCritBitTree%5BT%5D" title="`$`[T](c: CritBitTree[T]): string">`$`[T](c: CritBitTree[T]): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">[]
- <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>
- <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>
- </ul>
- <ul class="simple nested-toc-section">[]=
- <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>
- </ul>
- <ul class="simple nested-toc-section">commonPrefixLen
- <li><a class="reference" href="#commonPrefixLen%2CCritBitTree%5BT%5D" title="commonPrefixLen[T](c: CritBitTree[T]): int">commonPrefixLen[T](c: CritBitTree[T]): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">contains
- <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>
- </ul>
- <ul class="simple nested-toc-section">containsOrIncl
- <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>
- <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>
- </ul>
- <ul class="simple nested-toc-section">excl
- <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>
- </ul>
- <ul class="simple nested-toc-section">hasKey
- <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>
- </ul>
- <ul class="simple nested-toc-section">inc
- <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>
- </ul>
- <ul class="simple nested-toc-section">incl
- <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>
- <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>
- </ul>
- <ul class="simple nested-toc-section">len
- <li><a class="reference" href="#len%2CCritBitTree%5BT%5D" title="len[T](c: CritBitTree[T]): int">len[T](c: CritBitTree[T]): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">missingOrExcl
- <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>
- </ul>
- <ul class="simple nested-toc-section">toCritBitTree
- <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>
- <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>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">items
- <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>
- </ul>
- <ul class="simple nested-toc-section">itemsWithPrefix
- <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>
- </ul>
- <ul class="simple nested-toc-section">keys
- <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>
- </ul>
- <ul class="simple nested-toc-section">keysWithPrefix
- <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>
- </ul>
- <ul class="simple nested-toc-section">mpairs
- <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>
- </ul>
- <ul class="simple nested-toc-section">mpairsWithPrefix
- <li><a class="reference" href="#mpairsWithPrefix.i%2CCritBitTree%5BT%5D%2Cstring" title="mpairsWithPrefix[T](c: var CritBitTree[T]; prefix: string): tuple[key: string,
- val: var T]">mpairsWithPrefix[T](c: var CritBitTree[T]; prefix: string): tuple[key: string,
- val: var T]</a></li>
- </ul>
- <ul class="simple nested-toc-section">mvalues
- <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>
- </ul>
- <ul class="simple nested-toc-section">mvaluesWithPrefix
- <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>
- </ul>
- <ul class="simple nested-toc-section">pairs
- <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>
- </ul>
- <ul class="simple nested-toc-section">pairsWithPrefix
- <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>
- </ul>
- <ul class="simple nested-toc-section">values
- <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>
- </ul>
- <ul class="simple nested-toc-section">valuesWithPrefix
- <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>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <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>.)
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">critbits</span>
- <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>
- <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">"kitten"</span><span class="Punctuation">,</span> <span class="StringLit">"puppy"</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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>
- <span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">incl</span><span class="Punctuation">(</span><span class="StringLit">""</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="StringLit">""</span> <span class="Keyword">in</span> <span class="Identifier">critbitAsSet</span>
- <span class="Identifier">critbitAsSet</span><span class="Operator">.</span><span class="Identifier">excl</span><span class="Punctuation">(</span><span class="StringLit">""</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="StringLit">""</span> <span class="Keyword">notin</span> <span class="Identifier">critbitAsSet</span>
- <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">"kitten"</span><span class="Punctuation">,</span> <span class="StringLit">"puppy"</span><span class="Punctuation">]</span>
- <span class="Keyword">let</span> <span class="Identifier">same</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"puppy"</span><span class="Punctuation">,</span> <span class="StringLit">"kitten"</span><span class="Punctuation">,</span> <span class="StringLit">"puppy"</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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>
- <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">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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>
- <span class="Identifier">critbitAsDict</span><span class="Punctuation">[</span><span class="StringLit">"key2"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
- <span class="Identifier">doAssert</span> <span class="StringLit">"key2"</span> <span class="Keyword">in</span> <span class="Identifier">critbitAsDict</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">critbitAsDict</span><span class="Punctuation">[</span><span class="StringLit">"key2"</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
- <span class="Identifier">critbitAsDict</span><span class="Operator">.</span><span class="Identifier">excl</span><span class="Punctuation">(</span><span class="StringLit">"key1"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="StringLit">"key1"</span> <span class="Keyword">notin</span> <span class="Identifier">critbitAsDict</span>
- <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">"key2"</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre></p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="CritBitTree">
- <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>
- <dd>
-
- 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>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L54" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="$-procs-all">
- <div id="$,CritBitTree[T]">
- <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>
- <dd>
-
- Turns <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> into a string representation.
- <p><strong class="examples_text">Example:</strong></p>
- <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">"{:}"</span>
- <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">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</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">"""{"key1": 1, "key2": 2}"""</span>
- <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">"{}"</span>
- <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">"key1"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="LongStringLit">"""{"key1", "key2"}"""</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L477" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L477" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="[]-procs-all">
- <div id="[],CritBitTree[T],string">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string_2">[] proc</a></li>
- <li><a class="reference external" href="#[]=,CritBitTree[T],string,T">[]= proc</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L307" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L307" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="[],CritBitTree[T],string_2">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string">[] proc</a></li>
- <li><a class="reference external" href="#[]=,CritBitTree[T],string,T">[]= proc</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L317" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L317" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="[]=-procs-all">
- <div id="[]=,CritBitTree[T],string,sinkT">
- <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>
- <dd>
-
- <p>Alias for <a class="reference external" href="#incl,CritBitTree[T],string,T">incl</a>.</p>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#[],CritBitTree[T],string">[] proc</a></li>
- <li><a class="reference external" href="#[],CritBitTree[T],string_2">[] proc</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L291" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L291" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="commonPrefixLen-procs-all">
- <div id="commonPrefixLen,CritBitTree[T]">
- <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>
- <dd>
-
- 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.
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key1"</span><span class="Punctuation">)</span>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">)</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L510" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L510" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="contains-procs-all">
- <div id="contains,CritBitTree[T],string">
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L80" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L80" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="containsOrIncl-procs-all">
- <div id="containsOrIncl,CritBitTree[void],string">
- <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>
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
- <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
- <li><a class="reference external" href="#containsOrIncl,CritBitTree[T],string,T">containsOrIncl proc</a></li>
- <li><a class="reference external" href="#missingOrExcl,CritBitTree[T],string">missingOrExcl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <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">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span>
- <span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L230" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L230" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="containsOrIncl,CritBitTree[T],string,sinkT">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
- <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
- <li><a class="reference external" href="#containsOrIncl,CritBitTree[void],string">containsOrIncl proc</a></li>
- <li><a class="reference external" href="#missingOrExcl,CritBitTree[T],string">missingOrExcl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <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">"key"</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span>
- <span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">,</span> <span class="DecNumber">21</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">"key"</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">21</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L204" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L204" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="excl-procs-all">
- <div id="excl,CritBitTree[T],string">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
- <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <span class="Identifier">excl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L167" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L167" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="hasKey-procs-all">
- <div id="hasKey,CritBitTree[T],string">
- <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>
- <dd>
-
- Alias for <a class="reference external" href="#contains,CritBitTree[T],string">contains</a>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L89" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L89" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="inc-procs-all">
- <div id="inc,CritBitTree[int],string,int">
- <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>
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">"key"</span><span class="Punctuation">]</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
- <span class="Identifier">inc</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">"key"</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L253" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L253" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="incl-procs-all">
- <div id="incl,CritBitTree[void],string">
- <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>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
- <li><a class="reference external" href="#incl,CritBitTree[T],string,T">incl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L264" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L264" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="incl,CritBitTree[T],string,sinkT">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
- <li><a class="reference external" href="#incl,CritBitTree[void],string">incl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">,</span> <span class="DecNumber">42</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">c</span><span class="Punctuation">[</span><span class="StringLit">"key"</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="DecNumber">42</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L277" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L277" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="len-procs-all">
- <div id="len,CritBitTree[T]">
- <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>
- <dd>
-
- Returns the number of elements in <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> in O(1).
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"key1"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L61" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L61" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="missingOrExcl-procs-all">
- <div id="missingOrExcl,CritBitTree[T],string">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#excl,CritBitTree[T],string">excl proc</a></li>
- <li><a class="reference external" href="#containsOrIncl,CritBitTree[T],string,T">containsOrIncl proc</a></li>
- <li><a class="reference external" href="#containsOrIncl,CritBitTree[void],string">containsOrIncl proc</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <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">"key"</span><span class="Punctuation">)</span>
- <span class="Keyword">block</span><span class="Punctuation">:</span>
- <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>
- <span class="Identifier">incl</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span>
- <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">"key"</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L182" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L182" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="toCritBitTree-procs-all">
- <div id="toCritBitTree,sinkopenArray[string]">
- <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> {.
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Identifier">doAssert</span> <span class="Punctuation">[</span><span class="StringLit">"a"</span><span class="Punctuation">,</span> <span class="StringLit">"b"</span><span class="Punctuation">,</span> <span class="StringLit">"c"</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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L534" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L534" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="toCritBitTree,sinkopenArray[]">
- <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>
- <dd>
-
- 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>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Identifier">doAssert</span> <span class="Punctuation">{</span><span class="StringLit">"a"</span><span class="Punctuation">:</span> <span class="StringLit">"0"</span><span class="Punctuation">,</span> <span class="StringLit">"b"</span><span class="Punctuation">:</span> <span class="StringLit">"1"</span><span class="Punctuation">,</span> <span class="StringLit">"c"</span><span class="Punctuation">:</span> <span class="StringLit">"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">string</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Punctuation">{</span><span class="StringLit">"a"</span><span class="Punctuation">:</span> <span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="StringLit">"b"</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">"c"</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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L526" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L526" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="15">
- <h1><a class="toc-backref" href="#15">Iterators</a></h1>
- <dl class="item">
- <div id="items-iterators-all">
- <div id="items.i,CritBitTree[T]">
- <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>
- <dd>
-
- Alias for <a class="reference external" href="#keys.i,CritBitTree[T]">keys</a>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L371" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L371" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="itemsWithPrefix-iterators-all">
- <div id="itemsWithPrefix.i,CritBitTree[T],string">
- <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>
- <dd>
-
- Alias for <a class="reference external" href="#keysWithPrefix.i,CritBitTree[T],string">keysWithPrefix</a>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L447" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L447" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="keys-iterators-all">
- <div id="keys.i,CritBitTree[T]">
- <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>
- <dd>
-
- Yields all keys in lexicographical order.
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</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="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">"key1"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">]</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L339" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L339" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="keysWithPrefix-iterators-all">
- <div id="keysWithPrefix.i,CritBitTree[T],string">
- <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>
- <dd>
-
- Yields all keys starting with <tt class="docutils literal"><span class="pre"><span class="Identifier">prefix</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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">"key"</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"key1"</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">]</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L412" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L412" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="mpairs-iterators-all">
- <div id="mpairs.i,CritBitTree[T]">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#pairs.i,CritBitTree[T]">pairs iterator</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L389" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L389" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="mpairsWithPrefix-iterators-all">
- <div id="mpairsWithPrefix.i,CritBitTree[T],string">
- <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>
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#pairsWithPrefix.i,CritBitTree[T],string">pairsWithPrefix iterator</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L467" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L467" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="mvalues-iterators-all">
- <div id="mvalues.i,CritBitTree[T]">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#values.i,CritBitTree[T]">values iterator</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L363" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L363" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="mvaluesWithPrefix-iterators-all">
- <div id="mvaluesWithPrefix.i,CritBitTree[T],string">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#valuesWithPrefix.i,CritBitTree[T],string">valuesWithPrefix iterator</a></li>
- </ul>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L438" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L438" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="pairs-iterators-all">
- <div id="pairs.i,CritBitTree[T]">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#mpairs.i,CritBitTree[T]">mpairs iterator</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</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="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">"key1"</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">"key2"</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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L375" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L375" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="pairsWithPrefix-iterators-all">
- <div id="pairsWithPrefix.i,CritBitTree[T],string">
- <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>
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#mpairsWithPrefix.i,CritBitTree[T],string">mpairsWithPrefix iterator</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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">"key"</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">"key1"</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">"key2"</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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L452" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L452" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="values-iterators-all">
- <div id="values.i,CritBitTree[T]">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#mvalues.i,CritBitTree[T]">mvalues iterator</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</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="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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L349" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L349" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="valuesWithPrefix-iterators-all">
- <div id="valuesWithPrefix.i,CritBitTree[T],string">
- <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>
- <dd>
-
- <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>
- <p><strong>See also:</strong></p>
- <ul class="simple"><li><a class="reference external" href="#mvaluesWithPrefix.i,CritBitTree[T],string">mvaluesWithPrefix iterator</a></li>
- </ul>
- <p><strong class="examples_text">Example:</strong></p>
- <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>
- <span class="Keyword">let</span> <span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">{</span><span class="StringLit">"key1"</span><span class="Punctuation">:</span> <span class="DecNumber">42</span><span class="Punctuation">,</span> <span class="StringLit">"key2"</span><span class="Punctuation">:</span> <span class="DecNumber">43</span><span class="Punctuation">}</span><span class="Operator">.</span><span class="Identifier">toCritBitTree</span>
- <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">"key"</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>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/critbits.nim#L423" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/critbits.nim#L423" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2024-12-25 13:28:14 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|