summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js')
-rw-r--r--tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js227
1 files changed, 118 insertions, 109 deletions
diff --git a/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js b/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
index 8b828aaeec..6eaf86f4d6 100644
--- a/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
+++ b/tools/node_modules/eslint/node_modules/js-sdsl/dist/esm/container/TreeContainer/Base/TreeNode.js
@@ -1,121 +1,130 @@
-var TreeNode = /** @class */ (function () {
- function TreeNode(key, value) {
- this.color = true;
- this.key = undefined;
- this.value = undefined;
- this.left = undefined;
- this.right = undefined;
- this.parent = undefined;
- this.key = key;
- this.value = value;
- }
- /**
- * @description Get the pre node.
- * @return TreeNode about the pre node.
- */
- TreeNode.prototype.pre = function () {
- var preNode = this;
- if (preNode.color === TreeNode.RED &&
- preNode.parent.parent === preNode) {
- preNode = preNode.right;
+var __extends = this && this.t || function() {
+ var extendStatics = function(e, n) {
+ extendStatics = Object.setPrototypeOf || {
+ __proto__: []
+ } instanceof Array && function(e, n) {
+ e.__proto__ = n;
+ } || function(e, n) {
+ for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) e[i] = n[i];
+ };
+ return extendStatics(e, n);
+ };
+ return function(e, n) {
+ if (typeof n !== "function" && n !== null) throw new TypeError("Class extends value " + String(n) + " is not a constructor or null");
+ extendStatics(e, n);
+ function __() {
+ this.constructor = e;
}
- else if (preNode.left) {
- preNode = preNode.left;
- while (preNode.right) {
- preNode = preNode.right;
+ e.prototype = n === null ? Object.create(n) : (__.prototype = n.prototype, new __);
+ };
+}();
+
+var TreeNode = function() {
+ function TreeNode(e, n) {
+ this.ee = 1;
+ this.W = undefined;
+ this.L = undefined;
+ this.Y = undefined;
+ this.Z = undefined;
+ this.tt = undefined;
+ this.W = e;
+ this.L = n;
+ }
+ TreeNode.prototype.pre = function() {
+ var e = this;
+ if (e.ee === 1 && e.tt.tt === e) {
+ e = e.Z;
+ } else if (e.Y) {
+ e = e.Y;
+ while (e.Z) {
+ e = e.Z;
}
- }
- else {
- var pre = preNode.parent;
- while (pre.left === preNode) {
- preNode = pre;
- pre = preNode.parent;
+ } else {
+ var n = e.tt;
+ while (n.Y === e) {
+ e = n;
+ n = e.tt;
}
- preNode = pre;
+ e = n;
}
- return preNode;
+ return e;
};
- /**
- * @description Get the next node.
- * @return TreeNode about the next node.
- */
- TreeNode.prototype.next = function () {
- var nextNode = this;
- if (nextNode.right) {
- nextNode = nextNode.right;
- while (nextNode.left) {
- nextNode = nextNode.left;
- }
- }
- else {
- var pre = nextNode.parent;
- while (pre.right === nextNode) {
- nextNode = pre;
- pre = nextNode.parent;
+ TreeNode.prototype.next = function() {
+ var e = this;
+ if (e.Z) {
+ e = e.Z;
+ while (e.Y) {
+ e = e.Y;
}
- if (nextNode.right !== pre) {
- nextNode = pre;
+ return e;
+ } else {
+ var n = e.tt;
+ while (n.Z === e) {
+ e = n;
+ n = e.tt;
}
+ if (e.Z !== n) {
+ return n;
+ } else return e;
}
- return nextNode;
};
- /**
- * @description Rotate left.
- * @return TreeNode about moved to original position after rotation.
- */
- TreeNode.prototype.rotateLeft = function () {
- var PP = this.parent;
- var V = this.right;
- var R = V.left;
- if (PP.parent === this)
- PP.parent = V;
- else if (PP.left === this)
- PP.left = V;
- else
- PP.right = V;
- V.parent = PP;
- V.left = this;
- this.parent = V;
- this.right = R;
- if (R)
- R.parent = this;
- return V;
+ TreeNode.prototype.rotateLeft = function() {
+ var e = this.tt;
+ var n = this.Z;
+ var i = n.Y;
+ if (e.tt === this) e.tt = n; else if (e.Y === this) e.Y = n; else e.Z = n;
+ n.tt = e;
+ n.Y = this;
+ this.tt = n;
+ this.Z = i;
+ if (i) i.tt = this;
+ return n;
};
- /**
- * @description Rotate left.
- * @return TreeNode about moved to original position after rotation.
- */
- TreeNode.prototype.rotateRight = function () {
- var PP = this.parent;
- var F = this.left;
- var K = F.right;
- if (PP.parent === this)
- PP.parent = F;
- else if (PP.left === this)
- PP.left = F;
- else
- PP.right = F;
- F.parent = PP;
- F.right = this;
- this.parent = F;
- this.left = K;
- if (K)
- K.parent = this;
- return F;
+ TreeNode.prototype.rotateRight = function() {
+ var e = this.tt;
+ var n = this.Y;
+ var i = n.Z;
+ if (e.tt === this) e.tt = n; else if (e.Y === this) e.Y = n; else e.Z = n;
+ n.tt = e;
+ n.Z = this;
+ this.tt = n;
+ this.Y = i;
+ if (i) i.tt = this;
+ return n;
};
- /**
- * @description Remove this.
- */
- TreeNode.prototype.remove = function () {
- var parent = this.parent;
- if (this === parent.left) {
- parent.left = undefined;
- }
- else
- parent.right = undefined;
- };
- TreeNode.RED = true;
- TreeNode.BLACK = false;
return TreeNode;
-}());
-export default TreeNode;
+}();
+
+export { TreeNode };
+
+var TreeNodeEnableIndex = function(e) {
+ __extends(TreeNodeEnableIndex, e);
+ function TreeNodeEnableIndex() {
+ var n = e !== null && e.apply(this, arguments) || this;
+ n.Y = undefined;
+ n.Z = undefined;
+ n.tt = undefined;
+ n.rt = 1;
+ return n;
+ }
+ TreeNodeEnableIndex.prototype.rotateLeft = function() {
+ var n = e.prototype.rotateLeft.call(this);
+ this.recount();
+ n.recount();
+ return n;
+ };
+ TreeNodeEnableIndex.prototype.rotateRight = function() {
+ var n = e.prototype.rotateRight.call(this);
+ this.recount();
+ n.recount();
+ return n;
+ };
+ TreeNodeEnableIndex.prototype.recount = function() {
+ this.rt = 1;
+ if (this.Y) this.rt += this.Y.rt;
+ if (this.Z) this.rt += this.Z.rt;
+ };
+ return TreeNodeEnableIndex;
+}(TreeNode);
+
+export { TreeNodeEnableIndex }; \ No newline at end of file