UNPKG

forerunnerdb

Version:

A NoSQL document store database for browsers and Node.js.

3,119 lines (837 loc) 34.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: BinaryTree</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: BinaryTree</h1> <section> <header> <h2> BinaryTree </h2> </header> <article> <div class="container-overview"> <h4 class="name" id="BinaryTree"><span class="type-signature"></span>new BinaryTree<span class="signature">(val, index)</span><span class="type-signature"></span></h4> <div class="description"> The binary tree class. </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">Object</span> </td> <td class="description last">The object to index.</td> </tr> <tr> <td class="name"><code>index</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The index object.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line9">line 9</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="_compareFunc"><span class="type-signature">(private) </span>_compareFunc<span class="signature">(a, b)</span><span class="type-signature"> &rarr; {number}</span></h4> <div class="description"> Default compare method. Can be overridden. </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>a</code></td> <td class="type"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>b</code></td> <td class="type"> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BinaryTree.js.html">BinaryTree.js</a>, <a href="BinaryTree.js.html#line93">line 93</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> <h4 class="name" id="_compareFunc"><span class="type-signature">(private) </span>_compareFunc<span class="signature">(a, b)</span><span class="type-signature"> &rarr; {number}</span></h4> <div class="description"> Default compare method. Can be overridden. </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>a</code></td> <td class="type"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>b</code></td> <td class="type"> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line260">line 260</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">number</span> </dd> </dl> <h4 class="name" id="_hashFunc"><span class="type-signature">(private) </span>_hashFunc<span class="signature">(obj)</span><span class="type-signature"></span></h4> <div class="description"> Default hash function. Can be overridden. </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>obj</code></td> <td class="type"> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BinaryTree.js.html">BinaryTree.js</a>, <a href="BinaryTree.js.html#line121">line 121</a> </li></ul></dd> </dl> <h4 class="name" id="data"><span class="type-signature"></span>data<span class="signature">(val<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets the data this tree node holds. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>val</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The tree node data.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line24">line 24</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="decouple"><span class="type-signature"></span>decouple<span class="signature">(data, copies<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Returns a non-referenced version of the passed object / array. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> </td> <td class="description last">The object or array to return as a non-referenced version.</td> </tr> <tr> <td class="name"><code>copies</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Optional number of copies to produce. If specified, the return value will be an array of decoupled objects, each distinct from the other.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line340">line 340</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="index"><span class="type-signature"></span>index<span class="signature">(obj<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets the index object used to determine which fields are indexed in the objects being added to the tree and in what order they are sorted. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The index object.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line40">line 40</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="inOrder"><span class="type-signature"></span>inOrder<span class="signature">(resultArr<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Returns an array of all items in the tree in ascending order. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>resultArr</code></td> <td class="type"> <span class="param-type">Array</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Used internally by the method.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line211">line 211</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> Ascending order results array. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="insert"><span class="type-signature"></span>insert<span class="signature">(val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Inserts a value into the binary tree. </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">String</span> | <span class="param-type">Number</span> | <span class="param-type">Array</span> </td> <td class="description last">The value to insert.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line102">line 102</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="insertLeft"><span class="type-signature"></span>insertLeft<span class="signature">(val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Inserts an object into the left side of this node's tree, or creates a new tree node on the left and then inserts the object. </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">Object</span> </td> <td class="description last">The object to insert.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line155">line 155</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="insertMiddle"><span class="type-signature"></span>insertMiddle<span class="signature">(val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Inserts an object into the middle of this node's tree, or creates a new tree node in the middle and then inserts the object. </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">Object</span> </td> <td class="description last">The object to insert.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line170">line 170</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="insertRight"><span class="type-signature"></span>insertRight<span class="signature">(val)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Inserts an object into the right side of this node's tree, or creates a new tree node on the right and then inserts the object. </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">Object</span> </td> <td class="description last">The object to insert.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line197">line 197</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="keys"><span class="type-signature"></span>keys<span class="signature">(obj)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Scans the passed object and returns an array of objects, each containing the key and the value of each object key. </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>obj</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The object to scan keys from.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line237">line 237</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> An array of key/val objects. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="left"><span class="type-signature"></span>left<span class="signature">(tree<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets the node's left tree node. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>tree</code></td> <td class="type"> <span class="param-type"><a href="BinaryTree.html">BinaryTree</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The tree node.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line60">line 60</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="lookup"><span class="type-signature"></span>lookup<span class="signature">(query)</span><span class="type-signature"> &rarr; {Array}</span></h4> <div class="description"> Retrieves results based on the query object. </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>query</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">The query object.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line365">line 365</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The result array. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array</span> </dd> </dl> <h4 class="name" id="middle"><span class="type-signature"></span>middle<span class="signature">(tree<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets the node's middle tree node. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>tree</code></td> <td class="type"> <span class="param-type"><a href="BinaryTree.html">BinaryTree</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The tree node.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line74">line 74</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="right"><span class="type-signature"></span>right<span class="signature">(tree<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Gets / sets the node's right tree node. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>tree</code></td> <td class="type"> <span class="param-type"><a href="BinaryTree.html">BinaryTree</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">The tree node.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line88">line 88</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="sortAsc"><span class="type-signature"></span>sortAsc<span class="signature">(a, b)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Sorts the passed value a against the passed value b ascending. </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>a</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The first value to compare.</td> </tr> <tr> <td class="name"><code>b</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The second value to compare.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line298">line 298</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> 1 if a is sorted after b, -1 if a is sorted before b. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> <h4 class="name" id="sortDesc"><span class="type-signature"></span>sortDesc<span class="signature">(a, b)</span><span class="type-signature"> &rarr; {*}</span></h4> <div class="description"> Sorts the passed value a against the passed value b descending. </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>a</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The first value to compare.</td> </tr> <tr> <td class="name"><code>b</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="description last">The second value to compare.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="BTree.js.html">BTree.js</a>, <a href="BTree.js.html#line319">line 319</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> 1 if a is sorted after b, -1 if a is sorted before b. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">*</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ActiveBucket.html">ActiveBucket</a></li><li><a href="Angular.html">Angular</a></li><li><a href="AutoBind.html">AutoBind</a></li><li><a href="BinaryTree.html">BinaryTree</a></li><li><a href="Collection.html">Collection</a></li><li><a href="CollectionGroup.html">CollectionGroup</a></li><li><a href="Core.html">Core</a></li><li><a href="Db.html">Db</a></li><li><a href="Document.html">Document</a></li><li><a href="Grid.html">Grid</a></li><li><a href="Highchart.html">Highchart</a></li><li><a href="IndexBinaryTree.html">IndexBinaryTree</a></li><li><a href="IndexHashMap.html">IndexHashMap</a></li><li><a href="Infinilist.html">Infinilist</a></li><li><a href="KeyValueStore.html">KeyValueStore</a></li><li><a href="Metrics.html">Metrics</a></li><li><a href="OldView.html">OldView</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Overload.html">Overload</a></li><li><a href="Path.html">Path</a></li><li><a href="Persist.html">Persist</a></li><li><a href="ReactorIO.html">ReactorIO</a></li><li><a href="Serialiser.html">Serialiser</a></li><li><a href="Shared.overload.html">overload</a></li><li><a href="View.html">View</a></li></ul><h3>Mixins</h3><ul><li><a href="ChainReactor.html">ChainReactor</a></li><li><a href="crcTable.html">crcTable</a></li><li><a href="Shared.html">Shared</a></li></ul><h3>Global</h3><ul><li><a href="global.html#%2522boolean,function%2522">"boolean, function"</a></li><li><a href="global.html#%2522string,*,function%2522">"string, *, function"</a></li><li><a href="global.html#%2522string,function%2522">"string, function"</a></li><li><a href="global.html#boolean">boolean</a></li><li><a href="global.html#function">function</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Thu Nov 19 2015 13:31:32 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>