chore: factor out Array.equals
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
d709599ad9
commit
fc1c9162d6
3 changed files with 16 additions and 16 deletions
16
avl.js
16
avl.js
|
@ -1,19 +1,3 @@
|
|||
// TODO: Factor out to common module
|
||||
Array.prototype.equals = function (other) {
|
||||
if (this.length != other.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let i = this.length;
|
||||
while (--i >= 0) {
|
||||
if (this[i] !== other[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
function balanceFactor(node) {
|
||||
if (!node) {
|
||||
return 0;
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
<script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
|
||||
<script src="https://unpkg.com/d3-graphviz@3.0.5/build/d3-graphviz.js"></script>
|
||||
|
||||
<script src="utils.js"></script>
|
||||
|
||||
<script src="node.js"></script>
|
||||
<script src="ranked_tree.js"></script>
|
||||
<script src="avl.js"></script>
|
||||
|
|
14
utils.js
Normal file
14
utils.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
Array.prototype.equals = function (other) {
|
||||
if (this.length != other.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let i = this.length;
|
||||
while (--i >= 0) {
|
||||
if (this[i] !== other[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
Loading…
Reference in a new issue