esds
Version:
ES6 JS lightweight data structures (Priority Queue, Binary Search Tree (BST), Graph, Bloom Filters, Trie, Queue, Stack, Linked-List)
1,054 lines (229 loc) • 11.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: PriorityQueue</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: PriorityQueue</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>PriorityQueue<span class="signature">(type<span class="signature-attributes">opt</span>, comparator<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h2>
<div class="class-description">Priority Queue</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="PriorityQueue"><span class="type-signature"></span>new PriorityQueue<span class="signature">(type<span class="signature-attributes">opt</span>, comparator<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<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>type</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">(min|max|custom) - default min. If custom {comparator} should be provided</td>
</tr>
<tr>
<td class="name"><code>comparator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Custom comparator function. E.g. (a,b) => a.priority - b.priority</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line7">line 7</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="isEmpty"><span class="type-signature"></span>isEmpty<span class="type-signature"></span></h4>
<div class="description">
Returns true/false if PQ is empty
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line111">line 111</a>
</li></ul></dd>
</dl>
<h4 class="name" id="peek"><span class="type-signature"></span>peek<span class="type-signature"></span></h4>
<div class="description">
Peek heap element
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line125">line 125</a>
</li></ul></dd>
</dl>
<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="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line104">line 104</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)</span><span class="type-signature"></span></h4>
<div class="description">
Add a new value to the queue
</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"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line24">line 24</a>
</li></ul></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 PQ
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line97">line 97</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"> → {boolean}</span></h4>
<div class="description">
Returns true/false if PQ contains certain value among its entries,
</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 to search for.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line88">line 88</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">boolean</span>
</dd>
</dl>
<h4 class="name" id="poll"><span class="type-signature"></span>poll<span class="signature">()</span><span class="type-signature"> → {any}</span></h4>
<div class="description">
Retrieves and remove element with the highest priority
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line75">line 75</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
element
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">any</span>
</dd>
</dl>
<h4 class="name" id="toArray"><span class="type-signature"></span>toArray<span class="signature">()</span><span class="type-signature"> → {Array}</span></h4>
<div class="description">
Converts and return an array from stack
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="PriorityQueue.mjs.html">PriorityQueue.mjs</a>, <a href="PriorityQueue.mjs.html#line118">line 118</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</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>