UNPKG

aux-dbf

Version:

DBF for price PSM

63 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var NodeIndex_1 = require("./NodeIndex"); var BTree = /** @class */ (function () { function BTree() { this.root = null; } BTree.prototype.search = function (key) { return this._search(key, this.root); }; BTree.prototype.insert = function (key, adress, leaf) { if (!leaf) { if (this.root) { this.insert(key, adress, this.root); } else { this.root = new NodeIndex_1.NodeIndex(); this.root.value = key; this.root.Adress = adress; this.root.left = null; this.root.right = null; } return; } if (key < leaf.value) { if (leaf.left != null) { this.insert(key, adress, leaf.left); } else { leaf.left = new NodeIndex_1.NodeIndex(); leaf.left.value = key; leaf.left.Adress = adress; leaf.left.left = null; leaf.left.right = null; } } else if (key >= leaf.value) { if (leaf.right != null) { this.insert(key, adress, leaf.right); } else { leaf.right = new NodeIndex_1.NodeIndex(); leaf.right.value = key; leaf.right.Adress = adress; leaf.right.right = null; leaf.right.left = null; } } }; BTree.prototype._search = function (key, leaf) { if (leaf == null) return null; if (key == leaf.value) return leaf; if (key < leaf.value) return this._search(key, leaf.left); else return this._search(key, leaf.right); }; return BTree; }()); exports.BTree = BTree; //# sourceMappingURL=BTree.js.map