UNPKG

linked-map

Version:
2,408 lines (735 loc) 28.2 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: LinkedMap</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: LinkedMap</h1> <section> <header> <h2> LinkedMap </h2> </header> <article> <div class="container-overview"> <dt> <h4 class="name" id="LinkedMap"><span class="type-signature"></span>new LinkedMap<span class="signature">()</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Create a LinkedMap structure. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line5">line 5</a> </li></ul></dd> </dl> </dd> </div> <h3 class="subsection-title">Methods</h3> <dl> <dt> <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Remove all entries from the LinkedMap. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line292">line 292</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="each"><span class="type-signature"></span>each<span class="signature">(callback, context)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Iterate through each entry in the LinkedMap. </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>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">The required callback function that will be invoked for each entry. It receives the key and the value as parameters. To break out of the loop, return <tt>false</tt>.</td> </tr> <tr> <td class="name"><code>context</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The optional context with which to call the callback. Effectively, the value of <tt>this</tt>.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line203">line 203</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(key)</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Lookup the value associated with the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to return the value.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line47">line 47</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The value if it exists, or <tt>null</tt> if it does not. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="head"><span class="type-signature"></span>head<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Get the first value in the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line71">line 71</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The first value, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="headKey"><span class="type-signature"></span>headKey<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Get the first key in the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line55">line 55</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The first key, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="keys"><span class="type-signature"></span>keys<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> </dt> <dd> <div class="description"> Obtain a list of all keys known to the LinkedMap, in order. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line303">line 303</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The list of keys. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> </dd> <dt> <h4 class="name" id="next"><span class="type-signature"></span>next<span class="signature">(key, circular)</span><span class="type-signature"> &rarr; {*}</span></h4> </dt> <dd> <div class="description"> Obtain the next value in the linked list for the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to return the next value.</td> </tr> <tr> <td class="name"><code>circular</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="description last">Optionally supply <tt>true</tt> to treat the linked list circularly. Defaults to <tt>false</tt>.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line247">line 247</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The next value, or <tt>null</tt> if the given key was not found or the given key is the last in the linked list and <tt>circular</tt> is <tt>false</tt>. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </dd> <dt> <h4 class="name" id="nextKey"><span class="type-signature"></span>nextKey<span class="signature">(key, circular)</span><span class="type-signature"> &rarr; {*}</span></h4> </dt> <dd> <div class="description"> Obtain the next key in the linked list for the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to return the next key.</td> </tr> <tr> <td class="name"><code>circular</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="description last">Optionally supply <tt>true</tt> to treat the linked list circularly. Defaults to <tt>false</tt>.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line221">line 221</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The next key, or <tt>null</tt> if the given key was not found or the given key is the last in the linked list and <tt>circular</tt> is <tt>false</tt>. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </dd> <dt> <h4 class="name" id="pop"><span class="type-signature"></span>pop<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Obtain and remove the last value from the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line183">line 183</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The last value removed, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="previous"><span class="type-signature"></span>previous<span class="signature">(key, circular)</span><span class="type-signature"> &rarr; {*}</span></h4> </dt> <dd> <div class="description"> Obtain the previous value in the linked list for the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to return the previous value.</td> </tr> <tr> <td class="name"><code>circular</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="description last">Optionally supply <tt>true</tt> to treat the linked list circularly. Defaults to <tt>false</tt>.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line285">line 285</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The previous value, or <tt>null</tt> if the given key was not found or the given key is the last in the linked list and <tt>circular</tt> is <tt>false</tt>. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </dd> <dt> <h4 class="name" id="previousKey"><span class="type-signature"></span>previousKey<span class="signature">(key, circular)</span><span class="type-signature"> &rarr; {*}</span></h4> </dt> <dd> <div class="description"> Obtain the previous key in the linked list for the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to return the previous key.</td> </tr> <tr> <td class="name"><code>circular</code></td> <td class="type"> <span class="param-type">Boolean</span> </td> <td class="description last">Optionally supply <tt>true</tt> to treat the linked list circularly. Defaults to <tt>false</tt>.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line259">line 259</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The previous key, or <tt>null</tt> if the given key was not found or the given key is the last in the linked list and <tt>circular</tt> is <tt>false</tt>. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </dd> <dt> <h4 class="name" id="push"><span class="type-signature"></span>push<span class="signature">(key, value)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Append the given key-value pair to the end of the linked list. </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>key</code></td> <td class="type"> </td> <td class="description last">The key to append.</td> </tr> <tr> <td class="name"><code>value</code></td> <td class="type"> </td> <td class="description last">The value to append.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line111">line 111</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">(key)</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Remove the entry for the given <tt>key</tt>. </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>key</code></td> <td class="type"> </td> <td class="description last">The key for which to remove the entry.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line192">line 192</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The value associated with the given <tt>key</tt>, or <tt>null</tt> if <tt>key</tt> does not exist. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="shift"><span class="type-signature"></span>shift<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Obtain and remove the first value from the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line175">line 175</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The first value removed, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="size"><span class="type-signature"></span>size<span class="signature">()</span><span class="type-signature"> &rarr; {number}</span></h4> </dt> <dd> <div class="description"> Obtain the number of elements in the LinkedMap. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line38">line 38</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The number of elements. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> </dd> <dt> <h4 class="name" id="tail"><span class="type-signature"></span>tail<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Get the last value in the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line79">line 79</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The last value, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="tailKey"><span class="type-signature"></span>tailKey<span class="signature">()</span><span class="type-signature"> &rarr; {*|null}</span></h4> </dt> <dd> <div class="description"> Get the last key in the linked list. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line63">line 63</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The last key, or <tt>null</tt> if the structure is empty. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> | <span class="param-type">null</span> </dd> </dl> </dd> <dt> <h4 class="name" id="unshift"><span class="type-signature"></span>unshift<span class="signature">(key, value)</span><span class="type-signature"></span></h4> </dt> <dd> <div class="description"> Prepend the given key-value pair to the front of the linked list. </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>key</code></td> <td class="type"> </td> <td class="description last">The key to prepend.</td> </tr> <tr> <td class="name"><code>value</code></td> <td class="type"> </td> <td class="description last">The value to prepend.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line88">line 88</a> </li></ul></dd> </dl> </dd> <dt> <h4 class="name" id="values"><span class="type-signature"></span>values<span class="signature">()</span><span class="type-signature"> &rarr; {Array}</span></h4> </dt> <dd> <div class="description"> Obtain a list of all values known to the LinkedMap, in order. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="linked-map.js.html">linked-map.js</a>, <a href="linked-map.js.html#line315">line 315</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="LinkedMap.html">LinkedMap</a></li></ul> </nav> <br clear="both"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sun Jun 28 2015 12:13:27 GMT-0700 (PDT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>