@amaui/amaui-binary-tree
Advanced tools
Comparing version 1.0.1 to 1.0.11
@@ -21,3 +21,3 @@ import { TMethod } from '@amaui/models'; | ||
root: AmauiNode; | ||
static build(value: any[]): AmauiBinaryTree; | ||
static make(value: any[]): AmauiBinaryTree; | ||
static lowestCommonAncestor(value: AmauiNode | any, value1: AmauiNode | any, root: AmauiNode): AmauiNode | undefined; | ||
@@ -32,3 +32,3 @@ static maxDepth(amauiNode: AmauiNode): number; | ||
array(variant?: TArrayVariant): Array<any>; | ||
build(value: any[]): AmauiBinaryTree; | ||
make(value: any[]): AmauiBinaryTree; | ||
add(value: AmauiNode | any): AmauiBinaryTree; | ||
@@ -35,0 +35,0 @@ find(value: any): AmauiNode | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.AmauiNode = exports.AmauiBinaryTree = void 0; | ||
var _utils = require("@amaui/utils"); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AmauiBinaryTree = exports.AmauiNode = void 0; | ||
const utils_1 = require("@amaui/utils"); | ||
class AmauiNode { | ||
constructor(value, left, right) { | ||
this.value = value; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
constructor(value, left, right) { | ||
this.value = value; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
} | ||
exports.AmauiNode = AmauiNode; | ||
class AmauiBinaryTree { | ||
constructor() { | ||
this.root = void 0; | ||
} | ||
static build(value) { | ||
return new AmauiBinaryTree().build(value); | ||
} | ||
static lowestCommonAncestor(value, value1, root) { | ||
let lca; | ||
const lowestCommonAncestorMethod = amauiNode => { | ||
if (!amauiNode) return; | ||
const mid = amauiNode.value === (value instanceof AmauiNode ? value.value : value) || amauiNode.value === (value1 instanceof AmauiNode ? value1.value : value1); | ||
const left = lowestCommonAncestorMethod(amauiNode.left); | ||
const right = lowestCommonAncestorMethod(amauiNode.right); | ||
if (mid && left || mid && right || left && right) lca = amauiNode; | ||
return left || right || mid; | ||
}; | ||
lowestCommonAncestorMethod(root); | ||
return lca; | ||
} | ||
static maxDepth(amauiNode) { | ||
const maxDepthMethod = value => { | ||
if (value === undefined) return 0; | ||
return Math.max(1 + maxDepthMethod(value.left), 1 + maxDepthMethod(value.right)); | ||
}; | ||
return maxDepthMethod(amauiNode); | ||
} | ||
static valid(value) { | ||
const isValid = amauiNode => { | ||
var _amauiNode$left, _amauiNode$right; | ||
if (amauiNode === undefined) return true; | ||
if (((_amauiNode$left = amauiNode.left) === null || _amauiNode$left === void 0 ? void 0 : _amauiNode$left.value) >= amauiNode.value) return false; | ||
if (((_amauiNode$right = amauiNode.right) === null || _amauiNode$right === void 0 ? void 0 : _amauiNode$right.value) <= amauiNode.value) return false; | ||
return isValid(amauiNode.left) && isValid(amauiNode.right); | ||
}; | ||
return isValid(value.root); | ||
} | ||
static preorder(value, method) { | ||
if (value !== undefined && (0, _utils.is)('function', method)) { | ||
method(value, value.left, value.right); | ||
this.preorder(value.left, method); | ||
this.preorder(value.right, method); | ||
static make(value) { return new AmauiBinaryTree().make(value); } | ||
static lowestCommonAncestor(value, value1, root) { | ||
let lca; | ||
const lowestCommonAncestorMethod = (amauiNode) => { | ||
if (!amauiNode) | ||
return; | ||
const mid = amauiNode.value === (value instanceof AmauiNode ? value.value : value) || amauiNode.value === (value1 instanceof AmauiNode ? value1.value : value1); | ||
const left = lowestCommonAncestorMethod(amauiNode.left); | ||
const right = lowestCommonAncestorMethod(amauiNode.right); | ||
if (mid && left || mid && right || left && right) | ||
lca = amauiNode; | ||
return left || right || mid; | ||
}; | ||
lowestCommonAncestorMethod(root); | ||
return lca; | ||
} | ||
} | ||
static inorder(value, method) { | ||
if (value !== undefined && (0, _utils.is)('function', method)) { | ||
this.inorder(value.left, method); | ||
method(value, value.left, value.right); | ||
this.inorder(value.right, method); | ||
static maxDepth(amauiNode) { | ||
const maxDepthMethod = (value) => { | ||
if (value === undefined) | ||
return 0; | ||
return Math.max(1 + maxDepthMethod(value.left), 1 + maxDepthMethod(value.right)); | ||
}; | ||
return maxDepthMethod(amauiNode); | ||
} | ||
} | ||
static postorder(value, method) { | ||
if (value !== undefined && (0, _utils.is)('function', method)) { | ||
this.postorder(value.left, method); | ||
this.postorder(value.right, method); | ||
method(value, value.left, value.right); | ||
static valid(value) { | ||
const isValid = (amauiNode) => { | ||
var _a, _b; | ||
if (amauiNode === undefined) | ||
return true; | ||
if (((_a = amauiNode.left) === null || _a === void 0 ? void 0 : _a.value) >= amauiNode.value) | ||
return false; | ||
if (((_b = amauiNode.right) === null || _b === void 0 ? void 0 : _b.value) <= amauiNode.value) | ||
return false; | ||
return isValid(amauiNode.left) && isValid(amauiNode.right); | ||
}; | ||
return isValid(value.root); | ||
} | ||
} | ||
static min(value) { | ||
let amauiNode = value; | ||
while (((_amauiNode = amauiNode) === null || _amauiNode === void 0 ? void 0 : _amauiNode.left) !== undefined) { | ||
var _amauiNode; | ||
amauiNode = amauiNode.left; | ||
static preorder(value, method) { | ||
if (value !== undefined && (0, utils_1.is)('function', method)) { | ||
method(value, value.left, value.right); | ||
this.preorder(value.left, method); | ||
this.preorder(value.right, method); | ||
} | ||
} | ||
return amauiNode; | ||
} | ||
static max(value) { | ||
let amauiNode = value; | ||
while (((_amauiNode2 = amauiNode) === null || _amauiNode2 === void 0 ? void 0 : _amauiNode2.right) !== undefined) { | ||
var _amauiNode2; | ||
amauiNode = amauiNode.right; | ||
static inorder(value, method) { | ||
if (value !== undefined && (0, utils_1.is)('function', method)) { | ||
this.inorder(value.left, method); | ||
method(value, value.left, value.right); | ||
this.inorder(value.right, method); | ||
} | ||
} | ||
return amauiNode; | ||
} | ||
array(variant = 'preorder') { | ||
const value = []; | ||
if (AmauiBinaryTree[variant]) AmauiBinaryTree[variant](this.root, amauiNode => value.push(amauiNode.value)); | ||
return value; | ||
} | ||
build(value) { | ||
if ((0, _utils.is)('array', value)) value.forEach(item => this.add(item)); | ||
return this; | ||
} | ||
add(value) { | ||
const amauiNode = value instanceof AmauiNode ? value : new AmauiNode(value); | ||
if (!this.root) { | ||
this.root = amauiNode; | ||
return this; | ||
static postorder(value, method) { | ||
if (value !== undefined && (0, utils_1.is)('function', method)) { | ||
this.postorder(value.left, method); | ||
this.postorder(value.right, method); | ||
method(value, value.left, value.right); | ||
} | ||
} | ||
let atmNode = this.root; | ||
while (atmNode) { | ||
if (amauiNode.value === atmNode.value) return this; // Left | ||
if (amauiNode.value < atmNode.value) { | ||
if (atmNode.left === undefined) { | ||
atmNode.left = amauiNode; | ||
return this; | ||
static min(value) { | ||
let amauiNode = value; | ||
while ((amauiNode === null || amauiNode === void 0 ? void 0 : amauiNode.left) !== undefined) | ||
amauiNode = amauiNode.left; | ||
return amauiNode; | ||
} | ||
static max(value) { | ||
let amauiNode = value; | ||
while ((amauiNode === null || amauiNode === void 0 ? void 0 : amauiNode.right) !== undefined) | ||
amauiNode = amauiNode.right; | ||
return amauiNode; | ||
} | ||
array(variant = 'preorder') { | ||
const value = []; | ||
if (AmauiBinaryTree[variant]) | ||
AmauiBinaryTree[variant](this.root, (amauiNode) => value.push(amauiNode.value)); | ||
return value; | ||
} | ||
make(value) { | ||
if ((0, utils_1.is)('array', value)) | ||
value.forEach(item => this.add(item)); | ||
return this; | ||
} | ||
add(value) { | ||
const amauiNode = value instanceof AmauiNode ? value : new AmauiNode(value); | ||
if (!this.root) { | ||
this.root = amauiNode; | ||
return this; | ||
} | ||
atmNode = atmNode.left; | ||
} // Right | ||
if (amauiNode.value > atmNode.value) { | ||
if (atmNode.right === undefined) { | ||
atmNode.right = amauiNode; | ||
return this; | ||
let atmNode = this.root; | ||
while (atmNode) { | ||
if (amauiNode.value === atmNode.value) | ||
return this; | ||
// Left | ||
if (amauiNode.value < atmNode.value) { | ||
if (atmNode.left === undefined) { | ||
atmNode.left = amauiNode; | ||
return this; | ||
} | ||
atmNode = atmNode.left; | ||
} | ||
// Right | ||
if (amauiNode.value > atmNode.value) { | ||
if (atmNode.right === undefined) { | ||
atmNode.right = amauiNode; | ||
return this; | ||
} | ||
atmNode = atmNode.right; | ||
} | ||
} | ||
atmNode = atmNode.right; | ||
} | ||
} | ||
} | ||
find(value) { | ||
if (!this.root) return; | ||
let atmNode = this.root; | ||
let amauiNode; | ||
while (atmNode && !amauiNode) { | ||
if (value < atmNode.value) atmNode = atmNode.left;else if (value > atmNode.value) atmNode = atmNode.right;else amauiNode = atmNode; | ||
find(value) { | ||
if (!this.root) | ||
return; | ||
let atmNode = this.root; | ||
let amauiNode; | ||
while (atmNode && !amauiNode) { | ||
if (value < atmNode.value) | ||
atmNode = atmNode.left; | ||
else if (value > atmNode.value) | ||
atmNode = atmNode.right; | ||
else | ||
amauiNode = atmNode; | ||
} | ||
return amauiNode; | ||
} | ||
return amauiNode; | ||
} | ||
remove(value) { | ||
this.root = this.removeNode(this.root, value); | ||
} | ||
removeNode(amauiNode, value) { | ||
if (amauiNode === undefined) return; | ||
if (value === amauiNode.value) { | ||
if (amauiNode.left === undefined && amauiNode.right === undefined) return; | ||
if (amauiNode.left === undefined) return amauiNode.right; | ||
if (amauiNode.right === undefined) return amauiNode.left; | ||
const atmNode = AmauiBinaryTree.min(amauiNode.right); | ||
amauiNode.value = atmNode.value; | ||
amauiNode.right = this.removeNode(amauiNode.right, atmNode.value); | ||
return amauiNode; | ||
remove(value) { | ||
this.root = this.removeNode(this.root, value); | ||
} | ||
if (value < amauiNode.value) { | ||
amauiNode.left = this.removeNode(amauiNode.left, value); | ||
return amauiNode; | ||
removeNode(amauiNode, value) { | ||
if (amauiNode === undefined) | ||
return; | ||
if (value === amauiNode.value) { | ||
if (amauiNode.left === undefined && amauiNode.right === undefined) | ||
return; | ||
if (amauiNode.left === undefined) | ||
return amauiNode.right; | ||
if (amauiNode.right === undefined) | ||
return amauiNode.left; | ||
const atmNode = AmauiBinaryTree.min(amauiNode.right); | ||
amauiNode.value = atmNode.value; | ||
amauiNode.right = this.removeNode(amauiNode.right, atmNode.value); | ||
return amauiNode; | ||
} | ||
if (value < amauiNode.value) { | ||
amauiNode.left = this.removeNode(amauiNode.left, value); | ||
return amauiNode; | ||
} | ||
amauiNode.right = this.removeNode(amauiNode.right, value); | ||
return amauiNode; | ||
} | ||
amauiNode.right = this.removeNode(amauiNode.right, value); | ||
return amauiNode; | ||
} | ||
} | ||
exports.AmauiBinaryTree = AmauiBinaryTree; | ||
exports.AmauiBinaryTree = AmauiBinaryTree; |
@@ -1,216 +0,190 @@ | ||
import _createClass from "@babel/runtime/helpers/createClass"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import { is } from '@amaui/utils'; | ||
export var AmauiNode = /*#__PURE__*/_createClass(function AmauiNode(value, left, right) { | ||
_classCallCheck(this, AmauiNode); | ||
export class AmauiNode { | ||
constructor(value, left, right) { | ||
this.value = value; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
this.value = value; | ||
this.left = left; | ||
this.right = right; | ||
}); | ||
export var AmauiBinaryTree = /*#__PURE__*/function () { | ||
function AmauiBinaryTree() { | ||
_classCallCheck(this, AmauiBinaryTree); | ||
} | ||
export class AmauiBinaryTree { | ||
constructor() { | ||
_defineProperty(this, "root", void 0); | ||
} | ||
this.root = void 0; | ||
static make(value) { | ||
return new AmauiBinaryTree().make(value); | ||
} | ||
_createClass(AmauiBinaryTree, [{ | ||
key: "array", | ||
value: function array() { | ||
var variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'preorder'; | ||
var value = []; | ||
if (AmauiBinaryTree[variant]) AmauiBinaryTree[variant](this.root, function (amauiNode) { | ||
return value.push(amauiNode.value); | ||
}); | ||
return value; | ||
} | ||
}, { | ||
key: "build", | ||
value: function build(value) { | ||
var _this = this; | ||
static lowestCommonAncestor(value, value1, root) { | ||
let lca; | ||
if (is('array', value)) value.forEach(function (item) { | ||
return _this.add(item); | ||
}); | ||
return this; | ||
} | ||
}, { | ||
key: "add", | ||
value: function add(value) { | ||
var amauiNode = value instanceof AmauiNode ? value : new AmauiNode(value); | ||
const lowestCommonAncestorMethod = amauiNode => { | ||
if (!amauiNode) return; | ||
const mid = amauiNode.value === (value instanceof AmauiNode ? value.value : value) || amauiNode.value === (value1 instanceof AmauiNode ? value1.value : value1); | ||
const left = lowestCommonAncestorMethod(amauiNode.left); | ||
const right = lowestCommonAncestorMethod(amauiNode.right); | ||
if (mid && left || mid && right || left && right) lca = amauiNode; | ||
return left || right || mid; | ||
}; | ||
if (!this.root) { | ||
this.root = amauiNode; | ||
return this; | ||
} | ||
lowestCommonAncestorMethod(root); | ||
return lca; | ||
} | ||
var atmNode = this.root; | ||
static maxDepth(amauiNode) { | ||
const maxDepthMethod = value => { | ||
if (value === undefined) return 0; | ||
return Math.max(1 + maxDepthMethod(value.left), 1 + maxDepthMethod(value.right)); | ||
}; | ||
while (atmNode) { | ||
if (amauiNode.value === atmNode.value) return this; // Left | ||
return maxDepthMethod(amauiNode); | ||
} | ||
if (amauiNode.value < atmNode.value) { | ||
if (atmNode.left === undefined) { | ||
atmNode.left = amauiNode; | ||
return this; | ||
} | ||
static valid(value) { | ||
const isValid = amauiNode => { | ||
var _amauiNode$left, _amauiNode$right; | ||
atmNode = atmNode.left; | ||
} // Right | ||
if (amauiNode === undefined) return true; | ||
if (((_amauiNode$left = amauiNode.left) === null || _amauiNode$left === void 0 ? void 0 : _amauiNode$left.value) >= amauiNode.value) return false; | ||
if (((_amauiNode$right = amauiNode.right) === null || _amauiNode$right === void 0 ? void 0 : _amauiNode$right.value) <= amauiNode.value) return false; | ||
return isValid(amauiNode.left) && isValid(amauiNode.right); | ||
}; | ||
return isValid(value.root); | ||
} | ||
if (amauiNode.value > atmNode.value) { | ||
if (atmNode.right === undefined) { | ||
atmNode.right = amauiNode; | ||
return this; | ||
} | ||
static preorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
method(value, value.left, value.right); | ||
this.preorder(value.left, method); | ||
this.preorder(value.right, method); | ||
} | ||
} | ||
atmNode = atmNode.right; | ||
} | ||
} | ||
static inorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
this.inorder(value.left, method); | ||
method(value, value.left, value.right); | ||
this.inorder(value.right, method); | ||
} | ||
}, { | ||
key: "find", | ||
value: function find(value) { | ||
if (!this.root) return; | ||
var atmNode = this.root; | ||
var amauiNode; | ||
} | ||
while (atmNode && !amauiNode) { | ||
if (value < atmNode.value) atmNode = atmNode.left;else if (value > atmNode.value) atmNode = atmNode.right;else amauiNode = atmNode; | ||
} | ||
return amauiNode; | ||
static postorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
this.postorder(value.left, method); | ||
this.postorder(value.right, method); | ||
method(value, value.left, value.right); | ||
} | ||
}, { | ||
key: "remove", | ||
value: function remove(value) { | ||
this.root = this.removeNode(this.root, value); | ||
} | ||
}, { | ||
key: "removeNode", | ||
value: function removeNode(amauiNode, value) { | ||
if (amauiNode === undefined) return; | ||
} | ||
if (value === amauiNode.value) { | ||
if (amauiNode.left === undefined && amauiNode.right === undefined) return; | ||
if (amauiNode.left === undefined) return amauiNode.right; | ||
if (amauiNode.right === undefined) return amauiNode.left; | ||
var atmNode = AmauiBinaryTree.min(amauiNode.right); | ||
amauiNode.value = atmNode.value; | ||
amauiNode.right = this.removeNode(amauiNode.right, atmNode.value); | ||
return amauiNode; | ||
} | ||
static min(value) { | ||
let amauiNode = value; | ||
if (value < amauiNode.value) { | ||
amauiNode.left = this.removeNode(amauiNode.left, value); | ||
return amauiNode; | ||
} | ||
while (((_amauiNode = amauiNode) === null || _amauiNode === void 0 ? void 0 : _amauiNode.left) !== undefined) { | ||
var _amauiNode; | ||
amauiNode.right = this.removeNode(amauiNode.right, value); | ||
return amauiNode; | ||
amauiNode = amauiNode.left; | ||
} | ||
}], [{ | ||
key: "build", | ||
value: function build(value) { | ||
return new AmauiBinaryTree().build(value); | ||
} | ||
}, { | ||
key: "lowestCommonAncestor", | ||
value: function lowestCommonAncestor(value, value1, root) { | ||
var lca; | ||
var lowestCommonAncestorMethod = function lowestCommonAncestorMethod(amauiNode) { | ||
if (!amauiNode) return; | ||
var mid = amauiNode.value === (value instanceof AmauiNode ? value.value : value) || amauiNode.value === (value1 instanceof AmauiNode ? value1.value : value1); | ||
var left = lowestCommonAncestorMethod(amauiNode.left); | ||
var right = lowestCommonAncestorMethod(amauiNode.right); | ||
if (mid && left || mid && right || left && right) lca = amauiNode; | ||
return left || right || mid; | ||
}; | ||
return amauiNode; | ||
} | ||
lowestCommonAncestorMethod(root); | ||
return lca; | ||
static max(value) { | ||
let amauiNode = value; | ||
while (((_amauiNode2 = amauiNode) === null || _amauiNode2 === void 0 ? void 0 : _amauiNode2.right) !== undefined) { | ||
var _amauiNode2; | ||
amauiNode = amauiNode.right; | ||
} | ||
}, { | ||
key: "maxDepth", | ||
value: function maxDepth(amauiNode) { | ||
var maxDepthMethod = function maxDepthMethod(value) { | ||
if (value === undefined) return 0; | ||
return Math.max(1 + maxDepthMethod(value.left), 1 + maxDepthMethod(value.right)); | ||
}; | ||
return maxDepthMethod(amauiNode); | ||
return amauiNode; | ||
} | ||
array() { | ||
let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'preorder'; | ||
const value = []; | ||
if (AmauiBinaryTree[variant]) AmauiBinaryTree[variant](this.root, amauiNode => value.push(amauiNode.value)); | ||
return value; | ||
} | ||
make(value) { | ||
if (is('array', value)) value.forEach(item => this.add(item)); | ||
return this; | ||
} | ||
add(value) { | ||
const amauiNode = value instanceof AmauiNode ? value : new AmauiNode(value); | ||
if (!this.root) { | ||
this.root = amauiNode; | ||
return this; | ||
} | ||
}, { | ||
key: "valid", | ||
value: function valid(value) { | ||
var isValid = function isValid(amauiNode) { | ||
var _amauiNode$left, _amauiNode$right; | ||
if (amauiNode === undefined) return true; | ||
if (((_amauiNode$left = amauiNode.left) === null || _amauiNode$left === void 0 ? void 0 : _amauiNode$left.value) >= amauiNode.value) return false; | ||
if (((_amauiNode$right = amauiNode.right) === null || _amauiNode$right === void 0 ? void 0 : _amauiNode$right.value) <= amauiNode.value) return false; | ||
return isValid(amauiNode.left) && isValid(amauiNode.right); | ||
}; | ||
let atmNode = this.root; | ||
return isValid(value.root); | ||
} | ||
}, { | ||
key: "preorder", | ||
value: function preorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
method(value, value.left, value.right); | ||
this.preorder(value.left, method); | ||
this.preorder(value.right, method); | ||
while (atmNode) { | ||
if (amauiNode.value === atmNode.value) return this; // Left | ||
if (amauiNode.value < atmNode.value) { | ||
if (atmNode.left === undefined) { | ||
atmNode.left = amauiNode; | ||
return this; | ||
} | ||
atmNode = atmNode.left; | ||
} // Right | ||
if (amauiNode.value > atmNode.value) { | ||
if (atmNode.right === undefined) { | ||
atmNode.right = amauiNode; | ||
return this; | ||
} | ||
atmNode = atmNode.right; | ||
} | ||
} | ||
}, { | ||
key: "inorder", | ||
value: function inorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
this.inorder(value.left, method); | ||
method(value, value.left, value.right); | ||
this.inorder(value.right, method); | ||
} | ||
} | ||
find(value) { | ||
if (!this.root) return; | ||
let atmNode = this.root; | ||
let amauiNode; | ||
while (atmNode && !amauiNode) { | ||
if (value < atmNode.value) atmNode = atmNode.left;else if (value > atmNode.value) atmNode = atmNode.right;else amauiNode = atmNode; | ||
} | ||
}, { | ||
key: "postorder", | ||
value: function postorder(value, method) { | ||
if (value !== undefined && is('function', method)) { | ||
this.postorder(value.left, method); | ||
this.postorder(value.right, method); | ||
method(value, value.left, value.right); | ||
} | ||
} | ||
}, { | ||
key: "min", | ||
value: function min(value) { | ||
var amauiNode = value; | ||
while (((_amauiNode = amauiNode) === null || _amauiNode === void 0 ? void 0 : _amauiNode.left) !== undefined) { | ||
var _amauiNode; | ||
return amauiNode; | ||
} | ||
amauiNode = amauiNode.left; | ||
} | ||
remove(value) { | ||
this.root = this.removeNode(this.root, value); | ||
} | ||
removeNode(amauiNode, value) { | ||
if (amauiNode === undefined) return; | ||
if (value === amauiNode.value) { | ||
if (amauiNode.left === undefined && amauiNode.right === undefined) return; | ||
if (amauiNode.left === undefined) return amauiNode.right; | ||
if (amauiNode.right === undefined) return amauiNode.left; | ||
const atmNode = AmauiBinaryTree.min(amauiNode.right); | ||
amauiNode.value = atmNode.value; | ||
amauiNode.right = this.removeNode(amauiNode.right, atmNode.value); | ||
return amauiNode; | ||
} | ||
}, { | ||
key: "max", | ||
value: function max(value) { | ||
var amauiNode = value; | ||
while (((_amauiNode2 = amauiNode) === null || _amauiNode2 === void 0 ? void 0 : _amauiNode2.right) !== undefined) { | ||
var _amauiNode2; | ||
amauiNode = amauiNode.right; | ||
} | ||
if (value < amauiNode.value) { | ||
amauiNode.left = this.removeNode(amauiNode.left, value); | ||
return amauiNode; | ||
} | ||
}]); | ||
return AmauiBinaryTree; | ||
}(); | ||
amauiNode.right = this.removeNode(amauiNode.right, value); | ||
return amauiNode; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiBinaryTree v1.0.1 | ||
/** @license AmauiBinaryTree v1.0.11 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
36
index.js
@@ -1,23 +0,13 @@ | ||
/** @license AmauiBinaryTree v1.0.1 | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _amauiBinaryTree = require("./amaui-binary-tree"); | ||
Object.keys(_amauiBinaryTree).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _amauiBinaryTree[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _amauiBinaryTree[key]; | ||
} | ||
}); | ||
}); | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./amaui-binary-tree"), exports); |
{ | ||
"name": "@amaui/amaui-binary-tree", | ||
"version": "1.0.1", | ||
"version": "1.0.11", | ||
"description": "Binary tree", | ||
@@ -30,4 +30,4 @@ "repository": "https://github.com/amaui-org/amaui-binary-tree.git", | ||
"dependencies": { | ||
"@amaui/utils": "^1.0.113", | ||
"@babel/runtime": "^7.16.3" | ||
"@amaui/utils": "^1.0.1874", | ||
"@babel/runtime": "^7.18.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "publishConfig": { |
<br /> | ||
</br > | ||
</br > | ||
<p align='center'> | ||
<a target='_blank' rel='noopener noreferrer' href='#'> | ||
<img src='utils/images/logo.svg' alt='AMAUI logo' /> | ||
</a> | ||
</p> | ||
<h1 align='center'>AMAUI Binary Tree</h1> | ||
@@ -15,3 +22,3 @@ | ||
<sub>Production ready </sub> | ||
<sub>2.1kb gzipped </sub> | ||
<sub>UMD 2.2kb gzipped </sub> | ||
<sub>100% test cov </sub> | ||
@@ -54,4 +61,4 @@ <sub>Browser and Nodejs</sub> | ||
// or use a build method or a static method | ||
amauiBinaryTree.build([4, 2, 7, 14, 1, 3, 5]); | ||
// or use a make method or a static method | ||
amauiBinaryTree.make([4, 2, 7, 14, 1, 3, 5]); | ||
@@ -58,0 +65,0 @@ // Binary tree |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
108
38917
11
721
1
Updated@amaui/utils@^1.0.1874
Updated@babel/runtime@^7.18.3