UNPKG

esds

Version:

ES6 JS lightweight data structures (Priority Queue, Binary Search Tree (BST), Graph, Bloom Filters, Trie, Queue, Stack, Linked-List)

1,498 lines (371 loc) 15.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: Trie</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: Trie</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span>Trie<span class="signature">()</span><span class="type-signature"></span></h2> <div class="class-description">Trie Class</div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="Trie"><span class="type-signature"></span>new Trie<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line21">line 21</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Members</h3> <h4 class="name" id="size"><span class="type-signature"></span>size<span class="type-signature"></span></h4> <div class="description"> Returns number of elements </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line89">line 89</a> </li></ul></dd> </dl> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="add"><span class="type-signature"></span>add<span class="signature">(val, content<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Adds a new element to the Trie </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The value of the element</td> </tr> <tr> <td class="name"><code>content</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> null </td> <td class="description last">Content of the element, default null</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line32">line 32</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> true if element was created, false if element exists </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Clears the Trie </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line145">line 145</a> </li></ul></dd> </dl> <h4 class="name" id="contains"><span class="type-signature"></span>contains<span class="signature">(val)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Indicates if an element exists in the Trie </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="description last">The value of the element</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line77">line 77</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> true if element exists, false if element does not exists </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="find"><span class="type-signature"></span>find<span class="signature">(prefix)</span><span class="type-signature"> &rarr; {<a href="Element.html">Element</a>}</span></h4> <div class="description"> Returns a sub Trie given a prefix </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>prefix</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="description last">The prefix of the element(s) to be found</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line113">line 113</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Return Element matching the prefix </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="Element.html">Element</a></span> </dd> </dl> <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(val)</span><span class="type-signature"> &rarr; {any}</span></h4> <div class="description"> Returns content of an element </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="description last">The value of the element</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line97">line 97</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - Content of the element, return null if element does not exists or if its content is not set </div> <dl> <dt> Type </dt> <dd> <span class="param-type">any</span> </dd> </dl> <h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">(val)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Removes an element from the Trie </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="description last">The value of the element</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line126">line 126</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> true if element exists, false if element does not exists </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="toArray"><span class="type-signature"></span>toArray<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Converts and return an array of elements contained in the Trie </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line153">line 153</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(val, content<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Updates the content of an existing element </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last">The value of the element</td> </tr> <tr> <td class="name"><code>content</code></td> <td class="type"> <span class="param-type">any</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> null </td> <td class="description last">Content of the element, default null</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="Trie.mjs.html">Trie.mjs</a>, <a href="Trie.mjs.html#line55">line 55</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> true if element was updated, false if element does not exists </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BloomFilter.html">BloomFilter</a></li><li><a href="BST.html">BST</a></li><li><a href="Element.html">Element</a></li><li><a href="Graph.html">Graph</a></li><li><a href="List.html">List</a></li><li><a href="Node.html">Node</a></li><li><a href="PriorityQueue.html">PriorityQueue</a></li><li><a href="Queue.html">Queue</a></li><li><a href="Stack.html">Stack</a></li><li><a href="TreeElement.html">TreeElement</a></li><li><a href="Trie.html">Trie</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Thu Sep 23 2021 00:49:18 GMT-0700 (Pacific Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>