UNPKG

compound-binary-file-js

Version:

This is an implementation of [Compound Binary File v.3](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b) \ Allows reading existing files, creation of the/write operation

55 lines 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var UpdateHandler = /** @class */ (function () { function UpdateHandler(tree) { this.tree = tree; } UpdateHandler.prototype.rightRotate = function (subTreeRoot, pivot) { var parent = subTreeRoot.getParent(); if (parent == null) { subTreeRoot.setLeftChild(pivot.getRightChild()); pivot.setRightChild(subTreeRoot); this.tree.setRoot(pivot); } else { var isLeftSubTree = parent.isLeftChild(subTreeRoot); subTreeRoot.setLeftChild(pivot.getRightChild()); pivot.setRightChild(subTreeRoot); if (isLeftSubTree) { parent.setLeftChild(pivot); } else { parent.setRightChild(pivot); } } this.swapColor(subTreeRoot, pivot); }; UpdateHandler.prototype.leftRotate = function (subTreeRoot, pivot) { var parent = subTreeRoot.getParent(); if (parent == null) { subTreeRoot.setRightChild(pivot.getLeftChild()); pivot.setLeftChild(subTreeRoot); this.tree.setRoot(pivot); } else { var isLeftSubTree = parent.isLeftChild(subTreeRoot); subTreeRoot.setRightChild(pivot.getLeftChild()); pivot.setLeftChild(subTreeRoot); if (isLeftSubTree) { parent.setLeftChild(pivot); } else { parent.setRightChild(pivot); } } this.swapColor(subTreeRoot, pivot); }; UpdateHandler.prototype.swapColor = function (node1, node2) { var node1Color = node1.getColor(); node1.setColor(node2.getColor()); node2.setColor(node1Color); }; return UpdateHandler; }()); exports.UpdateHandler = UpdateHandler; //# sourceMappingURL=UpdateHandler.js.map