buckets-js
Version:
Buckets is a complete, fully tested and documented data structure library written in pure JavaScript.
875 lines (542 loc) • 21 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="generator" content="JsDoc Toolkit" />
<title>JsDoc Reference - buckets.arrays</title>
<style type="text/css">
/* default.css */
body
{
font: 13.5px sans-serif;
line-height: 20px;
max-width: 950px;
-webkit-font-smoothing: antialiased;
text-align: justify;
}
h1
{
padding: 0;
color: rgb(65, 131, 196);
margin: 0 auto;
padding-top: 18px;
}
#index
{
margin-top: 15px;
margin-left: 15px;
width: 160px;
position: absolute;
left: 8px;
padding: 8px;
background: #fafafa;
padding-top: 12px;
padding-left: 6px;
padding-right: 12px;
padding-bottom: 0px;
border: 1px solid rgba(0, 0, 0, 0.1);
}
#content
{
margin-left: 220px;
}
.classList li
{
padding: 0;
margin: 0 0 8px 0;
}
.summaryTable {
width: 100%;
}
h2 { font-size: 110%; }
caption, div.sectionTitle
{
box-sizing: border-box;
color: rgb(51, 51, 51);
background-color: #fafafa;
line-height: 25px;
font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';
font-size: 14px;
font-style: normal;
font-variant: normal;
font-weight: bold;
text-align: left;
padding: 2px 6px 2px 6px;
border: 1px rgb(216, 216, 216) solid;
}
div.sectionTitle { margin-bottom: 8px; }
.summaryTable thead { display: none; }
.summaryTable td
{
vertical-align: top;
padding: 4px;
border-bottom: 1px rgb(216, 216, 216) solid;
border-right: 1px rgb(216, 216, 216) solid;
border-left: 1px rgb(216, 216, 216) solid;
}
/*col#summaryAttributes {}*/
.summaryTable td.attributes
{
border-left: 1px;
width: 140px;
text-align: right;
}
td.attributes, .fixedFont
{
color: rgb(2, 74, 8);
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}
.summaryTable td.nameDescription
{
text-align: left;
}
.summaryTable { margin-bottom: 8px; }
.detailList .heading
{
font-weight: bold;
padding-bottom: 6px;
margin-left: 0;
}
.classList {
list-style-type: none;
padding: 0;
margin: 0 0 0 8px;
font-family: sans-serif;
font-size: 1em;
overflow: auto;
}
a { color:#4285f4;
text-decoration: none;
}
hr {
border: 0;
border-top: 1px solid rgb(216, 216, 216);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
td.nameDescription.fixedFont {
color: rgb(0, 0, 0);
}
span.light {
color: rgb(148, 149, 155);
font-weight: bold;
}
pre {
background: #fafafa;
padding-top: 16px;
padding-bottom: 16px;
padding-left: 16px;
padding-right: 16px;
/* border: 1px solid rgba(0, 0, 0, 0.1); */
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
font-style: normal;
font-variant: normal;
font-weight: normal;
border: 1px solid rgba(0, 0, 0, 0.1);
color: rgb(124, 19, 0);
}
</style>
</head>
<body>
<!-- ============================== header ================================= -->
<!-- begin static/header.html -->
<div id="header">
</div>
<!-- end static/header.html -->
<!-- ============================== classes index ============================ -->
<div id="index">
<!-- begin publish.classesIndex -->
<ul class="classList">
<li><a href="../symbols/buckets.arrays.html">buckets.arrays</a></li>
<li><a href="../symbols/buckets.Bag.html">buckets.Bag</a></li>
<li><a href="../symbols/buckets.BSTree.html">buckets.BSTree</a></li>
<li><a href="../symbols/buckets.Dictionary.html">buckets.Dictionary</a></li>
<li><a href="../symbols/buckets.Heap.html">buckets.Heap</a></li>
<li><a href="../symbols/buckets.LinkedList.html">buckets.LinkedList</a></li>
<li><a href="../symbols/buckets.MultiDictionary.html">buckets.MultiDictionary</a></li>
<li><a href="../symbols/buckets.PriorityQueue.html">buckets.PriorityQueue</a></li>
<li><a href="../symbols/buckets.Queue.html">buckets.Queue</a></li>
<li><a href="../symbols/buckets.Set.html">buckets.Set</a></li>
<li><a href="../symbols/buckets.Stack.html">buckets.Stack</a></li>
</ul>
<!-- end publish.classesIndex -->
</div>
<div id="content">
<!-- ============================== class title ============================ -->
<h1 class="classTitle">
Namespace buckets.arrays
</h1>
<!-- ============================== class summary ========================== -->
<p class="description">
Contains various functions for manipulating arrays.
</p>
<!-- ============================== constructor summary ==================== -->
<table class="summaryTable" cellspacing="0" summary="A summary of the constructor documented in the class buckets.arrays.">
<caption>Namespace Summary</caption>
<thead>
<tr>
<th scope="col">Constructor Name and Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nameDescription" >
<div class="fixedFont">
<b><a href="../symbols/buckets.arrays.html#constructor">buckets.arrays</a></b>
</div>
<div class="description"></div>
</td>
</tr>
</tbody>
</table>
<!-- ============================== properties summary ===================== -->
<!-- ============================== methods summary ======================== -->
<table class="summaryTable" cellspacing="0" summary="A summary of the methods documented in the class buckets.arrays.">
<caption>Method Summary</caption>
<thead>
<tr>
<th scope="col">Method Name and Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.contains">contains</a></b>(array, item, equalsFunction)
</div>
<div class="description">Returns true if the array contains the specified element.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.copy">copy</a></b>(array)
</div>
<div class="description">Returns a shallow copy of the specified array.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.equals">equals</a></b>(array1, array2, equalsFunction)
</div>
<div class="description">Returns true if the provided arrays are equal.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.forEach">forEach</a></b>(array, callback)
</div>
<div class="description">Executes the provided function once per element present in the array.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.frequency">frequency</a></b>(array, item, equalsFunction)
</div>
<div class="description">Returns the number of elements in the array equal
to the specified element.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.indexOf">indexOf</a></b>(array, item, equalsFunction)
</div>
<div class="description">Returns the index of the first occurrence of the specified item
within the specified array.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.lastIndexOf">lastIndexOf</a></b>(array, item, equalsFunction)
</div>
<div class="description">Returns the index of the last occurrence of the specified element
within the specified array.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.remove">remove</a></b>(array, item, equalsFunction)
</div>
<div class="description">Removes the first ocurrence of the specified element from the specified array.</div>
</td>
</tr>
<tr>
<td class="nameDescription">
<div class="fixedFont">buckets.arrays.<b><a href="../symbols/buckets.arrays.html#.swap">swap</a></b>(array, i, j)
</div>
<div class="description">Swaps the elements at the specified positions in the specified array.</div>
</td>
</tr>
</tbody>
</table>
<!-- ============================== events summary ======================== -->
<!-- ============================== constructor details ==================== -->
<div class="details"><a name="constructor"> </a>
<div class="sectionTitle">
Namespace Detail
</div>
<div class="fixedFont">
<b>buckets.arrays</b>
</div>
<div class="description">
</div>
</div>
<!-- ============================== field details ========================== -->
<!-- ============================== method details ========================= -->
<div class="sectionTitle">
Method Detail
</div>
<a name=".contains"> </a>
<div class="fixedFont"><static>
<span class="light">{boolean}</span>
<span class="light">buckets.arrays.</span><b>contains</b>(array, item, equalsFunction)
</div>
<div class="description">
Returns true if the array contains the specified element.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{*}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{Object}</span> <b>item</b>
</dt>
<dd>The element to search for.</dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{boolean}</span> True if the specified array contains the specified element.</dd>
</dl>
<hr />
<a name=".copy"> </a>
<div class="fixedFont"><static>
<span class="light">{Array}</span>
<span class="light">buckets.arrays.</span><b>copy</b>(array)
</div>
<div class="description">
Returns a shallow copy of the specified array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{*}</span> <b>array</b>
</dt>
<dd>The array to copy.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{Array}</span> A copy of the specified array.</dd>
</dl>
<hr />
<a name=".equals"> </a>
<div class="fixedFont"><static>
<span class="light">{boolean}</span>
<span class="light">buckets.arrays.</span><b>equals</b>(array1, array2, equalsFunction)
</div>
<div class="description">
Returns true if the provided arrays are equal.
Two arrays are considered equal if both contain the same number
of elements and all corresponding pairs of elements
are equal and are in the same order.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{Array}</span> <b>array1</b>
</dt>
<dd></dd>
<dt>
<span class="light fixedFont">{Array}</span> <b>array2</b>
</dt>
<dd></dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{boolean}</span> True if the two arrays are equal.</dd>
</dl>
<hr />
<a name=".forEach"> </a>
<div class="fixedFont"><static>
<span class="light">buckets.arrays.</span><b>forEach</b>(array, callback)
</div>
<div class="description">
Executes the provided function once per element present in the array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{Array}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{function(Object):*}</span> <b>callback</b>
</dt>
<dd>Function to execute,
invoked with an element as argument. To break the iteration you can
optionally return false in the callback.</dd>
</dl>
<hr />
<a name=".frequency"> </a>
<div class="fixedFont"><static>
<span class="light">{number}</span>
<span class="light">buckets.arrays.</span><b>frequency</b>(array, item, equalsFunction)
</div>
<div class="description">
Returns the number of elements in the array equal
to the specified element.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{Array}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{Object}</span> <b>item</b>
</dt>
<dd>The element.</dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{number}</span> The number of elements in the specified array.
equal to the specified item.</dd>
</dl>
<hr />
<a name=".indexOf"> </a>
<div class="fixedFont"><static>
<span class="light">{number}</span>
<span class="light">buckets.arrays.</span><b>indexOf</b>(array, item, equalsFunction)
</div>
<div class="description">
Returns the index of the first occurrence of the specified item
within the specified array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{*}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{*}</span> <b>item</b>
</dt>
<dd>The element to search for.</dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{number}</span> The index of the first occurrence of the specified element
or -1 if not found.</dd>
</dl>
<hr />
<a name=".lastIndexOf"> </a>
<div class="fixedFont"><static>
<span class="light">{number}</span>
<span class="light">buckets.arrays.</span><b>lastIndexOf</b>(array, item, equalsFunction)
</div>
<div class="description">
Returns the index of the last occurrence of the specified element
within the specified array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{*}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{Object}</span> <b>item</b>
</dt>
<dd>The element to search for.</dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{number}</span> The index of the last occurrence of the specified element
within the specified array or -1 if not found.</dd>
</dl>
<hr />
<a name=".remove"> </a>
<div class="fixedFont"><static>
<span class="light">{boolean}</span>
<span class="light">buckets.arrays.</span><b>remove</b>(array, item, equalsFunction)
</div>
<div class="description">
Removes the first ocurrence of the specified element from the specified array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{*}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{*}</span> <b>item</b>
</dt>
<dd>The element to remove.</dd>
<dt>
<span class="light fixedFont">{function(Object|Object):boolean=}</span> <b>equalsFunction</b>
</dt>
<dd>Optional function to
check equality between two elements. Receives two arguments and returns true if they are equal.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{boolean}</span> True If the array changed after this call.</dd>
</dl>
<hr />
<a name=".swap"> </a>
<div class="fixedFont"><static>
<span class="light">{boolean}</span>
<span class="light">buckets.arrays.</span><b>swap</b>(array, i, j)
</div>
<div class="description">
Swaps the elements at the specified positions in the specified array.
</div>
<dl class="detailList">
<dt class="heading">Parameters:</dt>
<dt>
<span class="light fixedFont">{Array}</span> <b>array</b>
</dt>
<dd>The array.</dd>
<dt>
<span class="light fixedFont">{number}</span> <b>i</b>
</dt>
<dd>The index of the first element.</dd>
<dt>
<span class="light fixedFont">{number}</span> <b>j</b>
</dt>
<dd>The index of second element.</dd>
</dl>
<dl class="detailList">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{boolean}</span> True if the array is defined and the indexes are valid.</dd>
</dl>
<!-- ============================== event details ========================= -->
<hr />
</div>
</body>
</html>