remove node_modules and .gitignore them

This commit is contained in:
2023-11-24 14:40:32 -05:00
parent 5f6e638903
commit a74d7b91b8
8963 changed files with 1 additions and 874175 deletions
-8
View File
@@ -1,8 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
export declare const enum Color {
BLACK = 0,
RED = 1
}
-3
View File
@@ -1,3 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Color.js.map
-27
View File
@@ -1,27 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { XTree } from "./XTree";
import { XTreeNode } from "./XTreeNode";
import { ITreeMap } from "../../base/container/ITreeMap";
import { MapElementList } from "../container/associative/MapElementList";
import { IPair } from "../../utility/IPair";
import { Pair } from "../../utility/Pair";
import { Comparator } from "../functional/Comparator";
export declare abstract class MapTree<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, MapElementList.Iterator<Key, T, Unique, Source>, MapElementList.ReverseIterator<Key, T, Unique, Source>>> extends XTree<MapElementList.Iterator<Key, T, Unique, Source>> {
private source_;
private key_compare_;
private key_eq_;
private value_compare_;
constructor(source: Source, comp: Comparator<Key>, it_comp: Comparator<MapElementList.Iterator<Key, T, Unique, Source>>);
get_by_key(key: Key): XTreeNode<MapElementList.Iterator<Key, T, Unique, Source>> | null;
abstract nearest_by_key(key: Key): XTreeNode<MapElementList.Iterator<Key, T, Unique, Source>> | null;
lower_bound(key: Key): MapElementList.Iterator<Key, T, Unique, Source>;
abstract upper_bound(key: Key): MapElementList.Iterator<Key, T, Unique, Source>;
equal_range(key: Key): Pair<MapElementList.Iterator<Key, T, Unique, Source>, MapElementList.Iterator<Key, T, Unique, Source>>;
source(): Source;
key_comp(): Comparator<Key>;
key_eq(): Comparator<Key>;
value_comp(): Comparator<IPair<Key, T>>;
}
-108
View File
@@ -1,108 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var XTree_1 = require("./XTree");
var Pair_1 = require("../../utility/Pair");
var MapTree = /** @class */ (function (_super) {
__extends(MapTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function MapTree(source, comp, it_comp) {
var _this = _super.call(this, it_comp) || this;
_this.source_ = source;
_this.key_compare_ = comp;
_this.key_eq_ = function (x, y) {
return !comp(x, y) && !comp(y, x);
};
_this.value_compare_ = function (x, y) {
return comp(x.first, y.first);
};
return _this;
}
/**
* @internal
*/
MapTree._Swap_source = function (x, y) {
var _a;
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
};
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
MapTree.prototype.get_by_key = function (key) {
var ret = this.nearest_by_key(key);
if (ret === null || !this.key_eq_(key, ret.value.first))
return null;
else
return ret;
};
MapTree.prototype.lower_bound = function (key) {
var node = this.nearest_by_key(key);
if (node === null)
return this.source().end();
else if (this.key_comp()(node.value.first, key))
// it < key
return node.value.next();
else
return node.value;
};
MapTree.prototype.equal_range = function (key) {
return new Pair_1.Pair(this.lower_bound(key), this.upper_bound(key));
};
/* ---------------------------------------------------------
ACCECSSORS
--------------------------------------------------------- */
MapTree.prototype.source = function () {
return this.source_;
};
MapTree.prototype.key_comp = function () {
return this.key_compare_;
};
MapTree.prototype.key_eq = function () {
return this.key_eq_;
};
MapTree.prototype.value_comp = function () {
return this.value_compare_;
};
return MapTree;
}(XTree_1.XTree));
exports.MapTree = MapTree;
//# sourceMappingURL=MapTree.js.map
-16
View File
@@ -1,16 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { MapTree } from "./MapTree";
import { XTreeNode } from "./XTreeNode";
import { MultiTreeMap } from "../container/associative/MultiTreeMap";
import { MapElementList } from "../container/associative/MapElementList";
import { Comparator } from "../functional/Comparator";
export declare class MultiMapTree<Key, T, Source extends MultiTreeMap<Key, T, Source, MapElementList.Iterator<Key, T, false, Source>, MapElementList.ReverseIterator<Key, T, false, Source>>> extends MapTree<Key, T, false, Source> {
constructor(source: Source, comp: Comparator<Key>);
insert(val: MapElementList.Iterator<Key, T, false, Source>): void;
private _Nearest_by_key;
nearest_by_key(key: Key): XTreeNode<MapElementList.Iterator<Key, T, false, Source>> | null;
upper_bound(key: Key): MapElementList.Iterator<Key, T, false, Source>;
}
-103
View File
@@ -1,103 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiMapTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var MapTree_1 = require("./MapTree");
var uid_1 = require("../../functional/uid");
var MultiMapTree = /** @class */ (function (_super) {
__extends(MultiMapTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function MultiMapTree(source, comp) {
return _super.call(this, source, comp, function (x, y) {
var ret = comp(x.first, y.first);
if (!ret && !comp(y.first, x.first))
return (0, uid_1.get_uid)(x) < (0, uid_1.get_uid)(y);
else
return ret;
}) || this;
}
MultiMapTree.prototype.insert = function (val) {
// ISSUE UID BEFORE INSERTION
(0, uid_1.get_uid)(val);
_super.prototype.insert.call(this, val);
};
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
MultiMapTree.prototype._Nearest_by_key = function (key, equal_mover) {
// NEED NOT TO ITERATE
if (this.root_ === null)
return null;
//----
// ITERATE
//----
var ret = this.root_;
var matched = null;
while (true) {
var it = ret.value;
var my_node = null;
// COMPARE
if (this.key_comp()(key, it.first))
my_node = ret.left;
else if (this.key_comp()(it.first, key))
my_node = ret.right;
else {
// EQUAL, RESERVE THAT POINT
matched = ret;
my_node = equal_mover(ret);
}
// ULTIL CHILD NODE EXISTS
if (my_node === null)
break;
else
ret = my_node;
}
// RETURNS -> MATCHED OR NOT
return matched !== null ? matched : ret;
};
MultiMapTree.prototype.nearest_by_key = function (key) {
return this._Nearest_by_key(key, function (node) {
return node.left;
});
};
MultiMapTree.prototype.upper_bound = function (key) {
// FIND MATCHED NODE
var node = this._Nearest_by_key(key, function (node) {
return node.right;
});
if (node === null)
// NOTHING
return this.source().end();
// MUST BE it.first > key
var it = node.value;
if (this.key_comp()(key, it.first))
return it;
else
return it.next();
};
return MultiMapTree;
}(MapTree_1.MapTree));
exports.MultiMapTree = MultiMapTree;
//# sourceMappingURL=MultiMapTree.js.map
-16
View File
@@ -1,16 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { SetTree } from "./SetTree";
import { XTreeNode } from "./XTreeNode";
import { MultiTreeSet } from "../container/associative/MultiTreeSet";
import { SetElementList } from "../container/associative/SetElementList";
import { Comparator } from "../functional/Comparator";
export declare class MultiSetTree<Key, Source extends MultiTreeSet<Key, Source, SetElementList.Iterator<Key, false, Source>, SetElementList.ReverseIterator<Key, false, Source>>> extends SetTree<Key, false, Source> {
constructor(source: Source, comp: Comparator<Key>);
insert(val: SetElementList.Iterator<Key, false, Source>): void;
private _Nearest_by_key;
nearest_by_key(val: Key): XTreeNode<SetElementList.Iterator<Key, false, Source>> | null;
upper_bound(val: Key): SetElementList.Iterator<Key, false, Source>;
}
-103
View File
@@ -1,103 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiSetTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var SetTree_1 = require("./SetTree");
var uid_1 = require("../../functional/uid");
var MultiSetTree = /** @class */ (function (_super) {
__extends(MultiSetTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function MultiSetTree(source, comp) {
return _super.call(this, source, comp, function (x, y) {
var ret = comp(x.value, y.value);
if (!ret && !comp(y.value, x.value))
return (0, uid_1.get_uid)(x) < (0, uid_1.get_uid)(y);
else
return ret;
}) || this;
}
MultiSetTree.prototype.insert = function (val) {
// ISSUE UID BEFORE INSERTION
(0, uid_1.get_uid)(val);
_super.prototype.insert.call(this, val);
};
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
MultiSetTree.prototype._Nearest_by_key = function (key, equal_mover) {
// NEED NOT TO ITERATE
if (this.root_ === null)
return null;
//----
// ITERATE
//----
var ret = this.root_;
var matched = null;
while (true) {
var candidate = ret.value;
var node = null;
// COMPARE
if (this.key_comp()(key, candidate.value))
node = ret.left;
else if (this.key_comp()(candidate.value, key))
node = ret.right;
else {
// EQUAL, RESERVE THAT POINT
matched = ret;
node = equal_mover(ret);
}
// ULTIL CHILD NODE EXISTS
if (node === null)
break;
else
ret = node;
}
// RETURNS -> MATCHED OR NOT
return matched !== null ? matched : ret;
};
MultiSetTree.prototype.nearest_by_key = function (val) {
return this._Nearest_by_key(val, function (node) {
return node.left;
});
};
MultiSetTree.prototype.upper_bound = function (val) {
// FIND MATCHED NODE
var node = this._Nearest_by_key(val, function (node) {
return node.right;
});
if (node === null)
// NOTHING
return this.source().end();
// MUST BE it.first > key
var it = node.value;
if (this.key_comp()(val, it.value))
return it;
else
return it.next();
};
return MultiSetTree;
}(SetTree_1.SetTree));
exports.MultiSetTree = MultiSetTree;
//# sourceMappingURL=MultiSetTree.js.map
-25
View File
@@ -1,25 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { XTree } from "./XTree";
import { ITreeSet } from "../../base/container/ITreeSet";
import { SetElementList } from "../container/associative/SetElementList";
import { XTreeNode } from "./XTreeNode";
import { Pair } from "../../utility/Pair";
import { Comparator } from "../functional/Comparator";
export declare abstract class SetTree<Key, Unique extends boolean, Source extends ITreeSet<Key, Unique, Source, SetElementList.Iterator<Key, Unique, Source>, SetElementList.ReverseIterator<Key, Unique, Source>>> extends XTree<SetElementList.Iterator<Key, Unique, Source>> {
private source_;
private key_comp_;
private key_eq_;
constructor(set: Source, comp: Comparator<Key>, it_comp: Comparator<SetElementList.Iterator<Key, Unique, Source>>);
get_by_key(val: Key): XTreeNode<SetElementList.Iterator<Key, Unique, Source>> | null;
abstract nearest_by_key(val: Key): XTreeNode<SetElementList.Iterator<Key, Unique, Source>> | null;
lower_bound(val: Key): SetElementList.Iterator<Key, Unique, Source>;
abstract upper_bound(val: Key): SetElementList.Iterator<Key, Unique, Source>;
equal_range(val: Key): Pair<SetElementList.Iterator<Key, Unique, Source>, SetElementList.Iterator<Key, Unique, Source>>;
source(): Source;
key_comp(): Comparator<Key>;
key_eq(): Comparator<Key>;
value_comp(): Comparator<Key>;
}
-103
View File
@@ -1,103 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var XTree_1 = require("./XTree");
var Pair_1 = require("../../utility/Pair");
var SetTree = /** @class */ (function (_super) {
__extends(SetTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function SetTree(set, comp, it_comp) {
var _this = _super.call(this, it_comp) || this;
_this.source_ = set;
_this.key_comp_ = comp;
_this.key_eq_ = function (x, y) { return !comp(x, y) && !comp(y, x); };
return _this;
}
/**
* @internal
*/
SetTree._Swap_source = function (x, y) {
var _a;
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
};
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
SetTree.prototype.get_by_key = function (val) {
var ret = this.nearest_by_key(val);
if (ret === null || !this.key_eq_(val, ret.value.value))
return null;
else
return ret;
};
SetTree.prototype.lower_bound = function (val) {
var node = this.nearest_by_key(val);
if (node === null)
return this.source_.end();
else if (this.key_comp_(node.value.value, val))
// it < key
return node.value.next();
else
return node.value;
};
SetTree.prototype.equal_range = function (val) {
return new Pair_1.Pair(this.lower_bound(val), this.upper_bound(val));
};
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
SetTree.prototype.source = function () {
return this.source_;
};
SetTree.prototype.key_comp = function () {
return this.key_comp_;
};
SetTree.prototype.key_eq = function () {
return this.key_eq_;
};
SetTree.prototype.value_comp = function () {
return this.key_comp_;
};
return SetTree;
}(XTree_1.XTree));
exports.SetTree = SetTree;
//# sourceMappingURL=SetTree.js.map
-14
View File
@@ -1,14 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { MapTree } from "./MapTree";
import { XTreeNode } from "./XTreeNode";
import { UniqueTreeMap } from "../container/associative/UniqueTreeMap";
import { MapElementList } from "../container/associative/MapElementList";
import { Comparator } from "../functional/Comparator";
export declare class UniqueMapTree<Key, T, Source extends UniqueTreeMap<Key, T, Source, MapElementList.Iterator<Key, T, true, Source>, MapElementList.ReverseIterator<Key, T, true, Source>>> extends MapTree<Key, T, true, Source> {
constructor(source: Source, comp: Comparator<Key>);
nearest_by_key(key: Key): XTreeNode<MapElementList.Iterator<Key, T, true, Source>> | null;
upper_bound(key: Key): MapElementList.Iterator<Key, T, true, Source>;
}
-79
View File
@@ -1,79 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UniqueMapTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var MapTree_1 = require("./MapTree");
var UniqueMapTree = /** @class */ (function (_super) {
__extends(UniqueMapTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function UniqueMapTree(source, comp) {
return _super.call(this, source, comp, function (x, y) { return comp(x.first, y.first); }) || this;
}
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
UniqueMapTree.prototype.nearest_by_key = function (key) {
// NEED NOT TO ITERATE
if (this.root_ === null)
return null;
//----
// ITERATE
//----
var ret = this.root_;
while (true) {
// UNTIL MEET THE MATCHED VALUE OR FINAL BRANCH
var it = ret.value;
var my_node = null;
// COMPARE
if (this.key_comp()(key, it.first))
my_node = ret.left;
else if (this.key_comp()(it.first, key))
my_node = ret.right;
else
return ret; // MATCHED VALUE
// FINAL BRANCH? OR KEEP GOING
if (my_node === null)
break;
else
ret = my_node;
}
return ret; // DIFFERENT NODE
};
UniqueMapTree.prototype.upper_bound = function (key) {
// FIND MATCHED NODE
var node = this.nearest_by_key(key);
if (node === null)
return this.source().end();
// MUST BE it.first > key
var it = node.value;
if (this.key_comp()(key, it.first))
return it;
else
return it.next();
};
return UniqueMapTree;
}(MapTree_1.MapTree));
exports.UniqueMapTree = UniqueMapTree;
//# sourceMappingURL=UniqueMapTree.js.map
-14
View File
@@ -1,14 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { SetTree } from "./SetTree";
import { XTreeNode } from "./XTreeNode";
import { UniqueTreeSet } from "../container/associative/UniqueTreeSet";
import { SetElementList } from "../container/associative/SetElementList";
import { Comparator } from "../functional/Comparator";
export declare class UniqueSetTree<Key, Source extends UniqueTreeSet<Key, Source, SetElementList.Iterator<Key, true, Source>, SetElementList.ReverseIterator<Key, true, Source>>> extends SetTree<Key, true, Source> {
constructor(source: Source, comp: Comparator<Key>);
nearest_by_key(val: Key): XTreeNode<SetElementList.Iterator<Key, true, Source>> | null;
upper_bound(val: Key): SetElementList.Iterator<Key, true, Source>;
}
-84
View File
@@ -1,84 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UniqueSetTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var SetTree_1 = require("./SetTree");
var UniqueSetTree = /** @class */ (function (_super) {
__extends(UniqueSetTree, _super);
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function UniqueSetTree(source, comp) {
return _super.call(this, source, comp, function (x, y) { return comp(x.value, y.value); }) || this;
}
/* ---------------------------------------------------------
FINDERS
--------------------------------------------------------- */
UniqueSetTree.prototype.nearest_by_key = function (val) {
// NEED NOT TO ITERATE
if (this.root_ === null)
return null;
//----
// ITERATE
//----
var ret = this.root_;
while (true) {
// UNTIL MEET THE MATCHED VALUE OR FINAL BRANCH
var it = ret.value;
var my_node = null;
// COMPARE
if (this.key_comp()(val, it.value))
my_node = ret.left;
else if (this.key_comp()(it.value, val))
my_node = ret.right;
else
return ret; // MATCHED VALUE
// FINAL BRANCH? OR KEEP GOING
if (my_node === null)
break;
else
ret = my_node;
}
return ret; // DIFFERENT NODE
};
UniqueSetTree.prototype.upper_bound = function (val) {
//--------
// FIND MATCHED NODE
//--------
var node = this.nearest_by_key(val);
if (node === null)
return this.source().end();
//--------
// RETURN BRANCH
//--------
var it = node.value;
// MUST BE it.value > key
if (this.key_comp()(val, it.value))
return it;
else
return it.next();
};
return UniqueSetTree;
}(SetTree_1.SetTree));
exports.UniqueSetTree = UniqueSetTree;
//# sourceMappingURL=UniqueSetTree.js.map
-41
View File
@@ -1,41 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { XTreeNode } from "./XTreeNode";
import { Comparator } from "../functional/Comparator";
/**
* Red-Black Tree
*
* @reference https://en.wikipedia.org/w/index.php?title=Red%E2%80%93black_tree
* @inventor Rudolf Bayer
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class XTree<T> {
protected root_: XTreeNode<T> | null;
private comp_;
private equal_;
protected constructor(comp: Comparator<T>);
clear(): void;
root(): XTreeNode<T> | null;
get(val: T): XTreeNode<T> | null;
nearest(val: T): XTreeNode<T> | null;
private _Fetch_maximum;
insert(val: T): void;
private _Insert_case1;
private _Insert_case2;
private _Insert_case3;
private _Insert_case4;
private _Insert_case5;
erase(val: T): void;
private _Erase_case1;
private _Erase_case2;
private _Erase_case3;
private _Erase_case4;
private _Erase_case5;
private _Erase_case6;
private _Rotate_left;
private _Rotate_right;
private _Replace_node;
private _Fetch_color;
}
-283
View File
@@ -1,283 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XTree = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.internal
*/
//================================================================
var XTreeNode_1 = require("./XTreeNode");
/**
* Red-Black Tree
*
* @reference https://en.wikipedia.org/w/index.php?title=Red%E2%80%93black_tree
* @inventor Rudolf Bayer
* @author Jeongho Nam - https://github.com/samchon
*/
var XTree = /** @class */ (function () {
/* ---------------------------------------------------------
CONSTRUCTOR
--------------------------------------------------------- */
function XTree(comp) {
this.root_ = null;
this.comp_ = comp;
this.equal_ = function (x, y) {
return !comp(x, y) && !comp(y, x);
};
}
XTree.prototype.clear = function () {
this.root_ = null;
};
/* =========================================================
ACCESSORS
- GETTERS
- COMPARISON
============================================================
GETTERS
--------------------------------------------------------- */
XTree.prototype.root = function () {
return this.root_;
};
XTree.prototype.get = function (val) {
var ret = this.nearest(val);
if (ret === null || !this.equal_(val, ret.value))
return null;
else
return ret;
};
XTree.prototype.nearest = function (val) {
// NEED NOT TO ITERATE
if (this.root_ === null)
return null;
//----
// ITERATE
//----
var ret = this.root_;
while (true) {
// UNTIL MEET THE MATCHED VALUE OR FINAL BRANCH
var my_node = null;
// COMPARE
if (this.comp_(val, ret.value))
my_node = ret.left;
else if (this.comp_(ret.value, val))
my_node = ret.right;
else
return ret; // MATCHED VALUE
// FINAL BRANCH? OR KEEP GOING
if (my_node !== null)
ret = my_node;
else
break;
}
return ret; // DIFFERENT NODE
};
XTree.prototype._Fetch_maximum = function (node) {
while (node.right !== null)
node = node.right;
return node;
};
/* =========================================================
ELEMENTS I/O
- INSERT
- ERASE
- COLOR
- ROTATION
============================================================
INSERT
--------------------------------------------------------- */
XTree.prototype.insert = function (val) {
var parent = this.nearest(val);
var node = new XTreeNode_1.XTreeNode(val, 1 /* Color.RED */);
if (parent === null)
this.root_ = node;
else {
node.parent = parent;
if (this.comp_(node.value, parent.value))
parent.left = node;
else
parent.right = node;
}
this._Insert_case1(node);
};
XTree.prototype._Insert_case1 = function (n) {
if (n.parent === null)
n.color = 0 /* Color.BLACK */;
else
this._Insert_case2(n);
};
XTree.prototype._Insert_case2 = function (n) {
if (this._Fetch_color(n.parent) === 0 /* Color.BLACK */)
return;
else
this._Insert_case3(n);
};
XTree.prototype._Insert_case3 = function (n) {
if (this._Fetch_color(n.uncle) === 1 /* Color.RED */) {
n.parent.color = 0 /* Color.BLACK */;
n.uncle.color = 0 /* Color.BLACK */;
n.grand.color = 1 /* Color.RED */;
this._Insert_case1(n.grand);
}
else
this._Insert_case4(n);
};
XTree.prototype._Insert_case4 = function (n) {
if (n === n.parent.right && n.parent === n.grand.left) {
this._Rotate_left(n.parent);
n = n.left;
}
else if (n === n.parent.left && n.parent === n.grand.right) {
this._Rotate_right(n.parent);
n = n.right;
}
this._Insert_case5(n);
};
XTree.prototype._Insert_case5 = function (n) {
n.parent.color = 0 /* Color.BLACK */;
n.grand.color = 1 /* Color.RED */;
if (n === n.parent.left && n.parent === n.grand.left)
this._Rotate_right(n.grand);
else
this._Rotate_left(n.grand);
};
/* ---------------------------------------------------------
ERASE
--------------------------------------------------------- */
XTree.prototype.erase = function (val) {
var node = this.get(val);
if (node === null)
return; // UNABLE TO FIND THE MATCHED NODE
if (node.left !== null && node.right !== null) {
var pred = this._Fetch_maximum(node.left);
node.value = pred.value;
node = pred;
}
var child = node.right === null ? node.left : node.right;
if (this._Fetch_color(node) === 0 /* Color.BLACK */) {
node.color = this._Fetch_color(child);
this._Erase_case1(node);
}
this._Replace_node(node, child);
if (this._Fetch_color(this.root_) === 1 /* Color.RED */)
this.root_.color = 0 /* Color.BLACK */;
};
XTree.prototype._Erase_case1 = function (n) {
if (n.parent === null)
return;
else
this._Erase_case2(n);
};
XTree.prototype._Erase_case2 = function (n) {
if (this._Fetch_color(n.sibling) === 1 /* Color.RED */) {
n.parent.color = 1 /* Color.RED */;
n.sibling.color = 0 /* Color.BLACK */;
if (n === n.parent.left)
this._Rotate_left(n.parent);
else
this._Rotate_right(n.parent);
}
this._Erase_case3(n);
};
XTree.prototype._Erase_case3 = function (n) {
if (this._Fetch_color(n.parent) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling.left) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling.right) === 0 /* Color.BLACK */) {
n.sibling.color = 1 /* Color.RED */;
this._Erase_case1(n.parent);
}
else
this._Erase_case4(n);
};
XTree.prototype._Erase_case4 = function (N) {
if (this._Fetch_color(N.parent) === 1 /* Color.RED */ &&
N.sibling !== null &&
this._Fetch_color(N.sibling) === 0 /* Color.BLACK */ &&
this._Fetch_color(N.sibling.left) === 0 /* Color.BLACK */ &&
this._Fetch_color(N.sibling.right) === 0 /* Color.BLACK */) {
N.sibling.color = 1 /* Color.RED */;
N.parent.color = 0 /* Color.BLACK */;
}
else
this._Erase_case5(N);
};
XTree.prototype._Erase_case5 = function (n) {
if (n === n.parent.left &&
n.sibling !== null &&
this._Fetch_color(n.sibling) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling.left) === 1 /* Color.RED */ &&
this._Fetch_color(n.sibling.right) === 0 /* Color.BLACK */) {
n.sibling.color = 1 /* Color.RED */;
n.sibling.left.color = 0 /* Color.BLACK */;
this._Rotate_right(n.sibling);
}
else if (n === n.parent.right &&
n.sibling !== null &&
this._Fetch_color(n.sibling) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling.left) === 0 /* Color.BLACK */ &&
this._Fetch_color(n.sibling.right) === 1 /* Color.RED */) {
n.sibling.color = 1 /* Color.RED */;
n.sibling.right.color = 0 /* Color.BLACK */;
this._Rotate_left(n.sibling);
}
this._Erase_case6(n);
};
XTree.prototype._Erase_case6 = function (n) {
n.sibling.color = this._Fetch_color(n.parent);
n.parent.color = 0 /* Color.BLACK */;
if (n === n.parent.left) {
n.sibling.right.color = 0 /* Color.BLACK */;
this._Rotate_left(n.parent);
}
else {
n.sibling.left.color = 0 /* Color.BLACK */;
this._Rotate_right(n.parent);
}
};
/* ---------------------------------------------------------
ROTATION
--------------------------------------------------------- */
XTree.prototype._Rotate_left = function (node) {
var right = node.right;
this._Replace_node(node, right);
node.right = right.left;
if (right.left !== null)
right.left.parent = node;
right.left = node;
node.parent = right;
};
XTree.prototype._Rotate_right = function (node) {
var left = node.left;
this._Replace_node(node, left);
node.left = left.right;
if (left.right !== null)
left.right.parent = node;
left.right = node;
node.parent = left;
};
XTree.prototype._Replace_node = function (oldNode, newNode) {
if (oldNode.parent === null)
this.root_ = newNode;
else {
if (oldNode === oldNode.parent.left)
oldNode.parent.left = newNode;
else
oldNode.parent.right = newNode;
}
if (newNode !== null)
newNode.parent = oldNode.parent;
};
/* ---------------------------------------------------------
COLOR
--------------------------------------------------------- */
XTree.prototype._Fetch_color = function (node) {
if (node === null)
return 0 /* Color.BLACK */;
else
return node.color;
};
return XTree;
}());
exports.XTree = XTree;
//# sourceMappingURL=XTree.js.map
-21
View File
@@ -1,21 +0,0 @@
/**
* @packageDocumentation
* @module std.internal
*/
import { Color } from "./Color";
/**
* Node of {@link XTree}
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class XTreeNode<T> {
parent: XTreeNode<T> | null;
left: XTreeNode<T> | null;
right: XTreeNode<T> | null;
value: T;
color: Color;
constructor(value: T, color: Color);
get grand(): XTreeNode<T> | null;
get sibling(): XTreeNode<T> | null;
get uncle(): XTreeNode<T> | null;
}
-47
View File
@@ -1,47 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.XTreeNode = void 0;
/**
* Node of {@link XTree}
*
* @author Jeongho Nam - https://github.com/samchon
*/
var XTreeNode = /** @class */ (function () {
/* ---------------------------------------------------------
CONSTRUCTORS
--------------------------------------------------------- */
function XTreeNode(value, color) {
this.value = value;
this.color = color;
this.parent = null;
this.left = null;
this.right = null;
}
Object.defineProperty(XTreeNode.prototype, "grand", {
get: function () {
return this.parent.parent;
},
enumerable: false,
configurable: true
});
Object.defineProperty(XTreeNode.prototype, "sibling", {
get: function () {
if (this === this.parent.left)
return this.parent.right;
else
return this.parent.left;
},
enumerable: false,
configurable: true
});
Object.defineProperty(XTreeNode.prototype, "uncle", {
get: function () {
return this.parent.sibling;
},
enumerable: false,
configurable: true
});
return XTreeNode;
}());
exports.XTreeNode = XTreeNode;
//# sourceMappingURL=XTreeNode.js.map