include node_modules so release .zip is deployable
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports._Get_root = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var node_1 = require("../utility/node");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function _Get_root() {
|
||||
if (__s_pRoot === null) {
|
||||
__s_pRoot = ((0, node_1.is_node)() ? global : self);
|
||||
if (__s_pRoot.__s_iUID === undefined)
|
||||
__s_pRoot.__s_iUID = 0;
|
||||
}
|
||||
return __s_pRoot;
|
||||
}
|
||||
exports._Get_root = _Get_root;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
var __s_pRoot = null;
|
||||
//# sourceMappingURL=Global.js.map
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
/**
|
||||
* Common interface for associative containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IAssociativeContainer<Key, T extends Elem, SourceT extends IAssociativeContainer<Key, T, SourceT, IteratorT, ReverseIteratorT, Elem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, ReverseIteratorT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, Elem> extends IContainer<T, SourceT, IteratorT, ReverseIteratorT, Elem> {
|
||||
/**
|
||||
* Get iterator to element.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return An iterator to the element, if the specified key is found, otherwise `this.end()`.
|
||||
*/
|
||||
find(key: Key): IteratorT;
|
||||
/**
|
||||
* Test whether a key exists.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Whether the specified key exists.
|
||||
*/
|
||||
has(key: Key): boolean;
|
||||
/**
|
||||
* Count elements with a specified key.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Number of elements with the specified key.
|
||||
*/
|
||||
count(key: Key): number;
|
||||
/**
|
||||
* Erase elements with a specified key.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Number of erased elements.
|
||||
*/
|
||||
erase(key: Key): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(pos: IteratorT): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(first: IteratorT, last: IteratorT): IteratorT;
|
||||
}
|
||||
export declare namespace IAssociativeContainer {
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IAssociativeContainer = void 0;
|
||||
var IAssociativeContainer;
|
||||
(function (IAssociativeContainer) {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function construct(source) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
var ramda;
|
||||
var tail;
|
||||
if (args.length >= 1 && args[0] instanceof Array) {
|
||||
// INITIALIZER LIST CONSTRUCTOR
|
||||
ramda = function () {
|
||||
var items = args[0];
|
||||
source.push.apply(source, __spreadArray([], __read(items), false));
|
||||
};
|
||||
tail = args.slice(1);
|
||||
}
|
||||
else if (args.length >= 2 &&
|
||||
args[0].next instanceof Function &&
|
||||
args[1].next instanceof Function) {
|
||||
// RANGE CONSTRUCTOR
|
||||
ramda = function () {
|
||||
var first = args[0];
|
||||
var last = args[1];
|
||||
source.assign(first, last);
|
||||
};
|
||||
tail = args.slice(2);
|
||||
}
|
||||
else {
|
||||
// DEFAULT CONSTRUCTOR
|
||||
ramda = null;
|
||||
tail = args;
|
||||
}
|
||||
return { ramda: ramda, tail: tail };
|
||||
}
|
||||
IAssociativeContainer.construct = construct;
|
||||
})(IAssociativeContainer = exports.IAssociativeContainer || (exports.IAssociativeContainer = {}));
|
||||
//# sourceMappingURL=IAssociativeContainer.js.map
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IAssociativeContainer } from "./IAssociativeContainer";
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { Hasher } from "../../functional/Hasher";
|
||||
import { BinaryPredicator } from "../../functional/BinaryPredicator";
|
||||
/**
|
||||
* Common interface for hash containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface IHashContainer<Key, T extends Elem, SourceT extends IHashContainer<Key, T, SourceT, IteratorT, ReverseIteratorT, Elem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, ReverseIteratorT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, Elem> extends IAssociativeContainer<Key, T, SourceT, IteratorT, ReverseIteratorT, Elem> {
|
||||
/**
|
||||
* Get hash function.
|
||||
*
|
||||
* @return The hash function.
|
||||
*/
|
||||
hash_function(): Hasher<Key>;
|
||||
/**
|
||||
* Get key equality predicator.
|
||||
*
|
||||
* @return The key equality predicator.
|
||||
*/
|
||||
key_eq(): BinaryPredicator<Key>;
|
||||
/**
|
||||
* Compute bucket index for the *key*.
|
||||
*
|
||||
* @param key Target key.
|
||||
* @return Index number.
|
||||
*/
|
||||
bucket(key: Key): number;
|
||||
/**
|
||||
* Get number of buckets.
|
||||
*/
|
||||
bucket_count(): number;
|
||||
/**
|
||||
* Get size of a specific bucket.
|
||||
*
|
||||
* @param index Specific position.
|
||||
* @return Size of the specific bucket.
|
||||
*/
|
||||
bucket_size(index: number): number;
|
||||
/**
|
||||
* Compute load factor.
|
||||
*
|
||||
* @return `this.size() / this.bucket_count()`
|
||||
*/
|
||||
load_factor(): number;
|
||||
/**
|
||||
* Get maximum load factor that allowable.
|
||||
*
|
||||
* @return The maximum load factor.
|
||||
*/
|
||||
max_load_factor(): number;
|
||||
/**
|
||||
* Set maximum load factor.
|
||||
*
|
||||
* @param z The new value to change.
|
||||
*/
|
||||
max_load_factor(z: number): void;
|
||||
/**
|
||||
* Reserve buckets enable to store *n* elements.
|
||||
*
|
||||
* @param n The capacity to reserve.
|
||||
*/
|
||||
reserve(n: number): void;
|
||||
/**
|
||||
* Change of bucktes.
|
||||
*
|
||||
* @param n The number to change.
|
||||
*/
|
||||
rehash(n: number): void;
|
||||
}
|
||||
export declare namespace IHashContainer {
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IHashContainer = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var IAssociativeContainer_1 = require("./IAssociativeContainer");
|
||||
var hash_1 = require("../../../functional/hash");
|
||||
var comparators_1 = require("../../../functional/comparators");
|
||||
var IHashContainer;
|
||||
(function (IHashContainer) {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function construct(source, Source, bucketFactory) {
|
||||
var args = [];
|
||||
for (var _i = 3; _i < arguments.length; _i++) {
|
||||
args[_i - 3] = arguments[_i];
|
||||
}
|
||||
// DECLARE MEMBERS
|
||||
var post_process = null;
|
||||
var hash_function = hash_1.hash;
|
||||
var key_eq = comparators_1.equal_to;
|
||||
//----
|
||||
// INITIALIZE MEMBERS AND POST-PROCESS
|
||||
//----
|
||||
// BRANCH - METHOD OVERLOADINGS
|
||||
if (args.length === 1 && args[0] instanceof Source) {
|
||||
// PARAMETERS
|
||||
var container_1 = args[0];
|
||||
hash_function = container_1.hash_function();
|
||||
key_eq = container_1.key_eq();
|
||||
// COPY CONSTRUCTOR
|
||||
post_process = function () {
|
||||
var first = container_1.begin();
|
||||
var last = container_1.end();
|
||||
source.assign(first, last);
|
||||
};
|
||||
}
|
||||
else {
|
||||
var tuple = IAssociativeContainer_1.IAssociativeContainer.construct.apply(IAssociativeContainer_1.IAssociativeContainer, __spreadArray([source], __read(args), false));
|
||||
post_process = tuple.ramda;
|
||||
if (tuple.tail.length >= 1)
|
||||
hash_function = tuple.tail[0];
|
||||
if (tuple.tail.length >= 2)
|
||||
key_eq = tuple.tail[1];
|
||||
}
|
||||
//----
|
||||
// DO PROCESS
|
||||
//----
|
||||
// CONSTRUCT BUCKET
|
||||
bucketFactory(hash_function, key_eq);
|
||||
// ACT POST-PROCESS
|
||||
if (post_process !== null)
|
||||
post_process();
|
||||
}
|
||||
IHashContainer.construct = construct;
|
||||
})(IHashContainer = exports.IHashContainer || (exports.IHashContainer = {}));
|
||||
//# sourceMappingURL=IHashContainer.js.map
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IAssociativeContainer } from "./IAssociativeContainer";
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
import { Pair } from "../../../utility/Pair";
|
||||
/**
|
||||
* Common interface for tree containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export interface ITreeContainer<Key, T extends Elem, SourceT extends ITreeContainer<Key, T, SourceT, IteratorT, ReverseIteratorT, Elem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, ReverseIteratorT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, Elem> extends IAssociativeContainer<Key, T, SourceT, IteratorT, ReverseIteratorT, Elem> {
|
||||
/**
|
||||
* Get key comparison function.
|
||||
*
|
||||
* @return The key comparison function.
|
||||
*/
|
||||
key_comp(): Comparator<Key>;
|
||||
/**
|
||||
* Get value comparison function.
|
||||
*
|
||||
* @return The value comparison function.
|
||||
*/
|
||||
value_comp(): Comparator<Elem>;
|
||||
/**
|
||||
* Get iterator to lower bound.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Iterator to the first element equal or after to the key.
|
||||
*/
|
||||
lower_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* Get iterator to upper bound.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Iterator to the first element after the key.
|
||||
*/
|
||||
upper_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* Get range of equal elements.
|
||||
*
|
||||
* @param key Key to search for.
|
||||
* @return Pair of {@link lower_bound} and {@link upper_bound}.
|
||||
*/
|
||||
equal_range(key: Key): Pair<IteratorT, IteratorT>;
|
||||
}
|
||||
export declare namespace ITreeContainer {
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ITreeContainer = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var IAssociativeContainer_1 = require("./IAssociativeContainer");
|
||||
var comparators_1 = require("../../../functional/comparators");
|
||||
var ITreeContainer;
|
||||
(function (ITreeContainer) {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function construct(source, Source, treeFactory) {
|
||||
var args = [];
|
||||
for (var _i = 3; _i < arguments.length; _i++) {
|
||||
args[_i - 3] = arguments[_i];
|
||||
}
|
||||
// DECLARE MEMBERS
|
||||
var post_process = null;
|
||||
var comp = comparators_1.less;
|
||||
//----
|
||||
// INITIALIZE MEMBERS AND POST-PROCESS
|
||||
//----
|
||||
// BRANCH - METHOD OVERLOADINGS
|
||||
if (args.length === 1 && args[0] instanceof Source) {
|
||||
// PARAMETERS
|
||||
var container_1 = args[0];
|
||||
comp = container_1.key_comp();
|
||||
// COPY CONSTRUCTOR
|
||||
post_process = function () {
|
||||
var first = container_1.begin();
|
||||
var last = container_1.end();
|
||||
source.assign(first, last);
|
||||
};
|
||||
}
|
||||
else {
|
||||
var tuple = IAssociativeContainer_1.IAssociativeContainer.construct.apply(IAssociativeContainer_1.IAssociativeContainer, __spreadArray([source], __read(args), false));
|
||||
post_process = tuple.ramda;
|
||||
if (tuple.tail.length >= 1)
|
||||
comp = tuple.tail[0];
|
||||
}
|
||||
//----
|
||||
// DO PROCESS
|
||||
//----
|
||||
// CONSTRUCT TREE
|
||||
treeFactory(comp);
|
||||
// ACT POST-PROCESS
|
||||
if (post_process !== null)
|
||||
post_process();
|
||||
}
|
||||
ITreeContainer.construct = construct;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function emplacable(source, hint, elem) {
|
||||
var prev = hint.prev();
|
||||
var meet = prev.equals(source.end()) || source.value_comp()(prev.value, elem);
|
||||
meet =
|
||||
meet &&
|
||||
(hint.equals(source.end()) ||
|
||||
source.value_comp()(elem, hint.value));
|
||||
return meet;
|
||||
}
|
||||
ITreeContainer.emplacable = emplacable;
|
||||
})(ITreeContainer = exports.ITreeContainer || (exports.ITreeContainer = {}));
|
||||
//# sourceMappingURL=ITreeContainer.js.map
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { ListContainer } from "../linear/ListContainer";
|
||||
import { ListIterator } from "../../iterator/ListIterator";
|
||||
import { ReverseIterator as _ReverseIterator } from "../../iterator/ReverseIterator";
|
||||
import { MapContainer } from "../../../base/container/MapContainer";
|
||||
import { IPair } from "../../../utility/IPair";
|
||||
import { Entry } from "../../../utility/Entry";
|
||||
/**
|
||||
* Doubly Linked List storing map elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class MapElementList<Key, T, Unique extends boolean, Source extends MapContainer<Key, T, Unique, Source, MapElementList.Iterator<Key, T, Unique, Source>, MapElementList.ReverseIterator<Key, T, Unique, Source>>> extends ListContainer<Entry<Key, T>, Source, MapElementList.Iterator<Key, T, Unique, Source>, MapElementList.ReverseIterator<Key, T, Unique, Source>> {
|
||||
private associative_;
|
||||
constructor(associative: Source);
|
||||
protected _Create_iterator(prev: MapElementList.Iterator<Key, T, Unique, Source>, next: MapElementList.Iterator<Key, T, Unique, Source>, val: Entry<Key, T>): MapElementList.Iterator<Key, T, Unique, Source>;
|
||||
associative(): Source;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare namespace MapElementList {
|
||||
/**
|
||||
* Iterator of map container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class Iterator<Key, T, Unique extends boolean, Source extends MapContainer<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>>> extends ListIterator<Entry<Key, T>, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>, IPair<Key, T>> implements MapContainer.Iterator<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>> {
|
||||
private list_;
|
||||
private constructor();
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
reverse(): ReverseIterator<Key, T, Unique, Source>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
source(): Source;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get first(): Key;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get second(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set second(val: T);
|
||||
}
|
||||
/**
|
||||
* Reverse iterator of map container storing elements a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class ReverseIterator<Key, T, Unique extends boolean, Source extends MapContainer<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>>> extends _ReverseIterator<Entry<Key, T>, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>, IPair<Key, T>> implements MapContainer.ReverseIterator<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>> {
|
||||
protected _Create_neighbor(base: Iterator<Key, T, Unique, Source>): ReverseIterator<Key, T, Unique, Source>;
|
||||
/**
|
||||
* Get the first, key element.
|
||||
*
|
||||
* @return The first element.
|
||||
*/
|
||||
get first(): Key;
|
||||
/**
|
||||
* Get the second, stored element.
|
||||
*
|
||||
* @return The second element.
|
||||
*/
|
||||
get second(): T;
|
||||
/**
|
||||
* Set the second, stored element.
|
||||
*
|
||||
* @param val The value to set.
|
||||
*/
|
||||
set second(val: T);
|
||||
}
|
||||
}
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
"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.MapElementList = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var ListContainer_1 = require("../linear/ListContainer");
|
||||
var ListIterator_1 = require("../../iterator/ListIterator");
|
||||
var ReverseIterator_1 = require("../../iterator/ReverseIterator");
|
||||
/**
|
||||
* Doubly Linked List storing map elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MapElementList = /** @class */ (function (_super) {
|
||||
__extends(MapElementList, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function MapElementList(associative) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.associative_ = associative;
|
||||
return _this;
|
||||
}
|
||||
MapElementList.prototype._Create_iterator = function (prev, next, val) {
|
||||
return MapElementList.Iterator.create(this, prev, next, val);
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
MapElementList._Swap_associative = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.associative_, x.associative_], 2), x.associative_ = _a[0], y.associative_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
MapElementList.prototype.associative = function () {
|
||||
return this.associative_;
|
||||
};
|
||||
return MapElementList;
|
||||
}(ListContainer_1.ListContainer));
|
||||
exports.MapElementList = MapElementList;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
(function (MapElementList) {
|
||||
/**
|
||||
* Iterator of map container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var Iterator = /** @class */ (function (_super) {
|
||||
__extends(Iterator, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function Iterator(list, prev, next, val) {
|
||||
var _this = _super.call(this, prev, next, val) || this;
|
||||
_this.list_ = list;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
Iterator.create = function (list, prev, next, val) {
|
||||
return new Iterator(list, prev, next, val);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.reverse = function () {
|
||||
return new ReverseIterator(this);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.source = function () {
|
||||
return this.list_.associative();
|
||||
};
|
||||
Object.defineProperty(Iterator.prototype, "first", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.first;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Iterator.prototype, "second", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.second;
|
||||
},
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.value.second = val;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Iterator;
|
||||
}(ListIterator_1.ListIterator));
|
||||
MapElementList.Iterator = Iterator;
|
||||
/**
|
||||
* Reverse iterator of map container storing elements a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ReverseIterator = /** @class */ (function (_super) {
|
||||
__extends(ReverseIterator, _super);
|
||||
function ReverseIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
ReverseIterator.prototype._Create_neighbor = function (base) {
|
||||
return new ReverseIterator(base);
|
||||
};
|
||||
Object.defineProperty(ReverseIterator.prototype, "first", {
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Get the first, key element.
|
||||
*
|
||||
* @return The first element.
|
||||
*/
|
||||
get: function () {
|
||||
return this.base_.first;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ReverseIterator.prototype, "second", {
|
||||
/**
|
||||
* Get the second, stored element.
|
||||
*
|
||||
* @return The second element.
|
||||
*/
|
||||
get: function () {
|
||||
return this.base_.second;
|
||||
},
|
||||
/**
|
||||
* Set the second, stored element.
|
||||
*
|
||||
* @param val The value to set.
|
||||
*/
|
||||
set: function (val) {
|
||||
this.base_.second = val;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return ReverseIterator;
|
||||
}(ReverseIterator_1.ReverseIterator));
|
||||
MapElementList.ReverseIterator = ReverseIterator;
|
||||
})(MapElementList = exports.MapElementList || (exports.MapElementList = {}));
|
||||
exports.MapElementList = MapElementList;
|
||||
//# sourceMappingURL=MapElementList.js.map
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { VectorContainer } from "../linear/VectorContainer";
|
||||
import { ArrayIteratorBase } from "../../iterator/ArrayIteratorBase";
|
||||
import { ArrayReverseIteratorBase } from "../../iterator/ArrayReverseIteratorBase";
|
||||
import { ITreeMap } from "../../../base/container/ITreeMap";
|
||||
import { IPair } from "../../../utility/IPair";
|
||||
import { Entry } from "../../../utility/Entry";
|
||||
/**
|
||||
* Vector storing map elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class MapElementVector<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, MapElementVector.Iterator<Key, T, Unique, Source>, MapElementVector.ReverseIterator<Key, T, Unique, Source>>> extends VectorContainer<Entry<Key, T>, Source, MapElementVector<Key, T, Unique, Source>, MapElementVector.Iterator<Key, T, Unique, Source>, MapElementVector.ReverseIterator<Key, T, Unique, Source>> {
|
||||
private associative_;
|
||||
constructor(associative: Source);
|
||||
nth(index: number): MapElementVector.Iterator<Key, T, Unique, Source>;
|
||||
source(): Source;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare namespace MapElementVector {
|
||||
/**
|
||||
* Iterator of map container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class Iterator<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>>> extends ArrayIteratorBase<Entry<Key, T>, Source, MapElementVector<Key, T, Unique, Source>, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>, IPair<Key, T>> implements ITreeMap.Iterator<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
source(): Source;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
reverse(): ReverseIterator<Key, T, Unique, Source>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get first(): Key;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get second(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set second(val: T);
|
||||
}
|
||||
/**
|
||||
* Reverse iterator of map container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class ReverseIterator<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>>> extends ArrayReverseIteratorBase<Entry<Key, T>, Source, MapElementVector<Key, T, Unique, Source>, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>, IPair<Key, T>> implements ITreeMap.ReverseIterator<Key, T, Unique, Source, Iterator<Key, T, Unique, Source>, ReverseIterator<Key, T, Unique, Source>> {
|
||||
protected _Create_neighbor(base: Iterator<Key, T, Unique, Source>): ReverseIterator<Key, T, Unique, Source>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get first(): Key;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get second(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set second(val: T);
|
||||
}
|
||||
}
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
"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.MapElementVector = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var VectorContainer_1 = require("../linear/VectorContainer");
|
||||
var ArrayIteratorBase_1 = require("../../iterator/ArrayIteratorBase");
|
||||
var ArrayReverseIteratorBase_1 = require("../../iterator/ArrayReverseIteratorBase");
|
||||
/**
|
||||
* Vector storing map elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MapElementVector = /** @class */ (function (_super) {
|
||||
__extends(MapElementVector, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function MapElementVector(associative) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.data_ = [];
|
||||
_this.associative_ = associative;
|
||||
return _this;
|
||||
}
|
||||
MapElementVector.prototype.nth = function (index) {
|
||||
return new MapElementVector.Iterator(this, index);
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
MapElementVector._Swap_associative = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.associative_, x.associative_], 2), x.associative_ = _a[0], y.associative_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
MapElementVector.prototype.source = function () {
|
||||
return this.associative_;
|
||||
};
|
||||
return MapElementVector;
|
||||
}(VectorContainer_1.VectorContainer));
|
||||
exports.MapElementVector = MapElementVector;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
(function (MapElementVector) {
|
||||
/**
|
||||
* Iterator of map container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var Iterator = /** @class */ (function (_super) {
|
||||
__extends(Iterator, _super);
|
||||
function Iterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.source = function () {
|
||||
return this._Get_array().source();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.reverse = function () {
|
||||
return new ReverseIterator(this);
|
||||
};
|
||||
Object.defineProperty(Iterator.prototype, "first", {
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.first;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(Iterator.prototype, "second", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.second;
|
||||
},
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.value.second = val;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Iterator;
|
||||
}(ArrayIteratorBase_1.ArrayIteratorBase));
|
||||
MapElementVector.Iterator = Iterator;
|
||||
/**
|
||||
* Reverse iterator of map container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ReverseIterator = /** @class */ (function (_super) {
|
||||
__extends(ReverseIterator, _super);
|
||||
function ReverseIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
ReverseIterator.prototype._Create_neighbor = function (base) {
|
||||
return new ReverseIterator(base);
|
||||
};
|
||||
Object.defineProperty(ReverseIterator.prototype, "first", {
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.first;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ReverseIterator.prototype, "second", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.value.second;
|
||||
},
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.value.second = val;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return ReverseIterator;
|
||||
}(ArrayReverseIteratorBase_1.ArrayReverseIteratorBase));
|
||||
MapElementVector.ReverseIterator = ReverseIterator;
|
||||
})(MapElementVector = exports.MapElementVector || (exports.MapElementVector = {}));
|
||||
exports.MapElementVector = MapElementVector;
|
||||
//# sourceMappingURL=MapElementVector.js.map
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { MultiMap } from "../../../base/container/MultiMap";
|
||||
import { ITreeContainer } from "./ITreeContainer";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { IPair } from "../../../utility/IPair";
|
||||
import { Entry } from "../../../utility/Entry";
|
||||
import { Pair } from "../../../utility/Pair";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
/**
|
||||
* Basic tree map allowing duplicated keys.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link MultiTreeMap}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class MultiTreeMap<Key, T, Source extends MultiTreeMap<Key, T, Source, IteratorT, ReverseT>, IteratorT extends MultiMap.Iterator<Key, T, Source, IteratorT, ReverseT>, ReverseT extends MultiMap.ReverseIterator<Key, T, Source, IteratorT, ReverseT>> extends MultiMap<Key, T, Source, IteratorT, ReverseT> implements ITreeContainer<Key, Entry<Key, T>, Source, IteratorT, ReverseT, IPair<Key, T>> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
find(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
count(key: Key): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract lower_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract upper_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equal_range(key: Key): Pair<IteratorT, IteratorT>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract key_comp(): Comparator<Key>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
value_comp(): Comparator<IPair<Key, T>>;
|
||||
protected _Key_eq(x: Key, y: Key): boolean;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
emplace(key: Key, val: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
emplace_hint(hint: IteratorT, key: Key, val: T): IteratorT;
|
||||
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
"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.MultiTreeMap = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var MultiMap_1 = require("../../../base/container/MultiMap");
|
||||
var ITreeContainer_1 = require("./ITreeContainer");
|
||||
var Entry_1 = require("../../../utility/Entry");
|
||||
var Pair_1 = require("../../../utility/Pair");
|
||||
/**
|
||||
* Basic tree map allowing duplicated keys.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link MultiTreeMap}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MultiTreeMap = /** @class */ (function (_super) {
|
||||
__extends(MultiTreeMap, _super);
|
||||
function MultiTreeMap() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.find = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(key, it.first))
|
||||
return it;
|
||||
else
|
||||
return this.end();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.count = function (key) {
|
||||
var it = this.find(key);
|
||||
var ret = 0;
|
||||
for (; !it.equals(this.end()) && this._Key_eq(it.first, key); it = it.next())
|
||||
++ret;
|
||||
return ret;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.equal_range = function (key) {
|
||||
return new Pair_1.Pair(this.lower_bound(key), this.upper_bound(key));
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.value_comp = function () {
|
||||
var _this = this;
|
||||
return function (x, y) { return _this.key_comp()(x.first, y.first); };
|
||||
};
|
||||
MultiTreeMap.prototype._Key_eq = function (x, y) {
|
||||
return !this.key_comp()(x, y) && !this.key_comp()(y, x);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.emplace = function (key, val) {
|
||||
// FIND POSITION TO INSERT
|
||||
var it = this.upper_bound(key);
|
||||
// ITERATOR TO RETURN
|
||||
it = this.data_.insert(it, new Entry_1.Entry(key, val));
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeMap.prototype.emplace_hint = function (hint, key, val) {
|
||||
var elem = new Entry_1.Entry(key, val);
|
||||
var validate = ITreeContainer_1.ITreeContainer.emplacable(this, hint, elem);
|
||||
if (validate) {
|
||||
var it = this.data_.insert(hint, elem);
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
}
|
||||
else
|
||||
return this.emplace(key, val);
|
||||
};
|
||||
MultiTreeMap.prototype._Insert_by_range = function (first, last) {
|
||||
for (var it = first; !it.equals(last); it = it.next())
|
||||
this.emplace(it.value.first, it.value.second);
|
||||
};
|
||||
return MultiTreeMap;
|
||||
}(MultiMap_1.MultiMap));
|
||||
exports.MultiTreeMap = MultiTreeMap;
|
||||
//# sourceMappingURL=MultiTreeMap.js.map
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { MultiSet } from "../../../base/container/MultiSet";
|
||||
import { ITreeContainer } from "./ITreeContainer";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { Pair } from "../../../utility/Pair";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
/**
|
||||
* Basic tree set allowing duplicated keys.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link MultiTreeSet}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class MultiTreeSet<Key, Source extends MultiTreeSet<Key, Source, IteratorT, ReverseT>, IteratorT extends MultiSet.Iterator<Key, Source, IteratorT, ReverseT>, ReverseT extends MultiSet.ReverseIterator<Key, Source, IteratorT, ReverseT>> extends MultiSet<Key, Source, IteratorT, ReverseT> implements ITreeContainer<Key, Key, Source, IteratorT, ReverseT, Key> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
find(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
count(key: Key): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract lower_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract upper_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equal_range(key: Key): Pair<IteratorT, IteratorT>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract key_comp(): Comparator<Key>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
value_comp(): Comparator<Key>;
|
||||
protected _Key_eq(x: Key, y: Key): boolean;
|
||||
protected _Insert_by_key(key: Key): IteratorT;
|
||||
protected _Insert_by_hint(hint: IteratorT, key: Key): IteratorT;
|
||||
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
"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.MultiTreeSet = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var MultiSet_1 = require("../../../base/container/MultiSet");
|
||||
var ITreeContainer_1 = require("./ITreeContainer");
|
||||
var Pair_1 = require("../../../utility/Pair");
|
||||
/**
|
||||
* Basic tree set allowing duplicated keys.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link MultiTreeSet}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MultiTreeSet = /** @class */ (function (_super) {
|
||||
__extends(MultiTreeSet, _super);
|
||||
function MultiTreeSet() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeSet.prototype.find = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(key, it.value))
|
||||
return it;
|
||||
else
|
||||
return this.end();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeSet.prototype.count = function (key) {
|
||||
var it = this.find(key);
|
||||
var ret = 0;
|
||||
for (; !it.equals(this.end()) && this._Key_eq(it.value, key); it = it.next())
|
||||
++ret;
|
||||
return ret;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeSet.prototype.equal_range = function (key) {
|
||||
return new Pair_1.Pair(this.lower_bound(key), this.upper_bound(key));
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
MultiTreeSet.prototype.value_comp = function () {
|
||||
return this.key_comp();
|
||||
};
|
||||
MultiTreeSet.prototype._Key_eq = function (x, y) {
|
||||
return !this.key_comp()(x, y) && !this.key_comp()(y, x);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
MultiTreeSet.prototype._Insert_by_key = function (key) {
|
||||
// FIND POSITION TO INSERT
|
||||
var it = this.upper_bound(key);
|
||||
// ITERATOR TO RETURN
|
||||
it = this.data_.insert(it, key);
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
};
|
||||
MultiTreeSet.prototype._Insert_by_hint = function (hint, key) {
|
||||
var validate = ITreeContainer_1.ITreeContainer.emplacable(this, hint, key);
|
||||
if (validate) {
|
||||
var it = this.data_.insert(hint, key);
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
}
|
||||
else
|
||||
return this._Insert_by_key(key);
|
||||
};
|
||||
MultiTreeSet.prototype._Insert_by_range = function (first, last) {
|
||||
for (var it = first; !it.equals(last); it = it.next())
|
||||
this._Insert_by_key(it.value);
|
||||
};
|
||||
return MultiTreeSet;
|
||||
}(MultiSet_1.MultiSet));
|
||||
exports.MultiTreeSet = MultiTreeSet;
|
||||
//# sourceMappingURL=MultiTreeSet.js.map
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { ListContainer } from "../linear/ListContainer";
|
||||
import { ListIterator } from "../../iterator/ListIterator";
|
||||
import { ReverseIterator as _ReverseIterator } from "../../iterator/ReverseIterator";
|
||||
import { SetContainer } from "../../../base/container/SetContainer";
|
||||
/**
|
||||
* Doubly Linked List storing set elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class SetElementList<Key, Unique extends boolean, Source extends SetContainer<Key, Unique, Source, SetElementList.Iterator<Key, Unique, Source>, SetElementList.ReverseIterator<Key, Unique, Source>>> extends ListContainer<Key, Source, SetElementList.Iterator<Key, Unique, Source>, SetElementList.ReverseIterator<Key, Unique, Source>> {
|
||||
private associative_;
|
||||
constructor(associative: Source);
|
||||
protected _Create_iterator(prev: SetElementList.Iterator<Key, Unique, Source>, next: SetElementList.Iterator<Key, Unique, Source>, val: Key): SetElementList.Iterator<Key, Unique, Source>;
|
||||
associative(): Source;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare namespace SetElementList {
|
||||
/**
|
||||
* Iterator of set container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class Iterator<Key, Unique extends boolean, Source extends SetContainer<Key, Unique, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>>> extends ListIterator<Key, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>, Key> implements SetContainer.Iterator<Key, Unique, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>> {
|
||||
private source_;
|
||||
private constructor();
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
reverse(): ReverseIterator<Key, Unique, Source>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
source(): Source;
|
||||
}
|
||||
/**
|
||||
* Reverser iterator of set container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class ReverseIterator<Key, Unique extends boolean, Source extends SetContainer<Key, Unique, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>>> extends _ReverseIterator<Key, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>, Key> implements SetContainer.ReverseIterator<Key, Unique, Source, Iterator<Key, Unique, Source>, ReverseIterator<Key, Unique, Source>> {
|
||||
protected _Create_neighbor(base: Iterator<Key, Unique, Source>): ReverseIterator<Key, Unique, Source>;
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
"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.SetElementList = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var ListContainer_1 = require("../linear/ListContainer");
|
||||
var ListIterator_1 = require("../../iterator/ListIterator");
|
||||
var ReverseIterator_1 = require("../../iterator/ReverseIterator");
|
||||
/**
|
||||
* Doubly Linked List storing set elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var SetElementList = /** @class */ (function (_super) {
|
||||
__extends(SetElementList, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function SetElementList(associative) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.associative_ = associative;
|
||||
return _this;
|
||||
}
|
||||
SetElementList.prototype._Create_iterator = function (prev, next, val) {
|
||||
return SetElementList.Iterator.create(this, prev, next, val);
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
SetElementList._Swap_associative = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.associative_, x.associative_], 2), x.associative_ = _a[0], y.associative_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
SetElementList.prototype.associative = function () {
|
||||
return this.associative_;
|
||||
};
|
||||
return SetElementList;
|
||||
}(ListContainer_1.ListContainer));
|
||||
exports.SetElementList = SetElementList;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
(function (SetElementList) {
|
||||
/**
|
||||
* Iterator of set container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var Iterator = /** @class */ (function (_super) {
|
||||
__extends(Iterator, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function Iterator(list, prev, next, val) {
|
||||
var _this = _super.call(this, prev, next, val) || this;
|
||||
_this.source_ = list;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
Iterator.create = function (list, prev, next, val) {
|
||||
return new Iterator(list, prev, next, val);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.reverse = function () {
|
||||
return new ReverseIterator(this);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.source = function () {
|
||||
return this.source_.associative();
|
||||
};
|
||||
return Iterator;
|
||||
}(ListIterator_1.ListIterator));
|
||||
SetElementList.Iterator = Iterator;
|
||||
/**
|
||||
* Reverser iterator of set container storing elements in a list.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ReverseIterator = /** @class */ (function (_super) {
|
||||
__extends(ReverseIterator, _super);
|
||||
function ReverseIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ReverseIterator.prototype._Create_neighbor = function (base) {
|
||||
return new ReverseIterator(base);
|
||||
};
|
||||
return ReverseIterator;
|
||||
}(ReverseIterator_1.ReverseIterator));
|
||||
SetElementList.ReverseIterator = ReverseIterator;
|
||||
})(SetElementList = exports.SetElementList || (exports.SetElementList = {}));
|
||||
exports.SetElementList = SetElementList;
|
||||
//# sourceMappingURL=SetElementList.js.map
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { VectorContainer } from "../linear/VectorContainer";
|
||||
import { ArrayIteratorBase } from "../../iterator/ArrayIteratorBase";
|
||||
import { ArrayReverseIteratorBase } from "../../iterator/ArrayReverseIteratorBase";
|
||||
import { ITreeSet } from "../../../base/container/ITreeSet";
|
||||
/**
|
||||
* Vector storing set elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class SetElementVector<Key, Unique extends boolean, Source extends ITreeSet<Key, Unique, Source, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>>> extends VectorContainer<Key, Source, SetElementVector<Key, Unique, Source>, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>> {
|
||||
private associative_;
|
||||
constructor(associative: Source);
|
||||
nth(index: number): SetElementVector.Iterator<Key, Unique, Source>;
|
||||
source(): Source;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export declare namespace SetElementVector {
|
||||
/**
|
||||
* Iterator of set container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class Iterator<Key, Unique extends boolean, Source extends ITreeSet<Key, Unique, Source, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>>> extends ArrayIteratorBase<Key, Source, SetElementVector<Key, Unique, Source>, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>, Key> implements ITreeSet.Iterator<Key, Unique, Source, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
source(): Source;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
reverse(): ReverseIterator<Key, Unique, Source>;
|
||||
}
|
||||
/**
|
||||
* Reverse iterator of set container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
class ReverseIterator<Key, Unique extends boolean, Source extends ITreeSet<Key, Unique, Source, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>>> extends ArrayReverseIteratorBase<Key, Source, SetElementVector<Key, Unique, Source>, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>, Key> implements ITreeSet.ReverseIterator<Key, Unique, Source, SetElementVector.Iterator<Key, Unique, Source>, SetElementVector.ReverseIterator<Key, Unique, Source>> {
|
||||
protected _Create_neighbor(base: Iterator<Key, Unique, Source>): ReverseIterator<Key, Unique, Source>;
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
"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.SetElementVector = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var VectorContainer_1 = require("../linear/VectorContainer");
|
||||
var ArrayIteratorBase_1 = require("../../iterator/ArrayIteratorBase");
|
||||
var ArrayReverseIteratorBase_1 = require("../../iterator/ArrayReverseIteratorBase");
|
||||
/**
|
||||
* Vector storing set elements.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var SetElementVector = /** @class */ (function (_super) {
|
||||
__extends(SetElementVector, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function SetElementVector(associative) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.data_ = [];
|
||||
_this.associative_ = associative;
|
||||
return _this;
|
||||
}
|
||||
SetElementVector.prototype.nth = function (index) {
|
||||
return new SetElementVector.Iterator(this, index);
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
SetElementVector._Swap_associative = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.associative_, x.associative_], 2), x.associative_ = _a[0], y.associative_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
SetElementVector.prototype.source = function () {
|
||||
return this.associative_;
|
||||
};
|
||||
return SetElementVector;
|
||||
}(VectorContainer_1.VectorContainer));
|
||||
exports.SetElementVector = SetElementVector;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
(function (SetElementVector) {
|
||||
/**
|
||||
* Iterator of set container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var Iterator = /** @class */ (function (_super) {
|
||||
__extends(Iterator, _super);
|
||||
function Iterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.source = function () {
|
||||
return this._Get_array().source();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
Iterator.prototype.reverse = function () {
|
||||
return new ReverseIterator(this);
|
||||
};
|
||||
return Iterator;
|
||||
}(ArrayIteratorBase_1.ArrayIteratorBase));
|
||||
SetElementVector.Iterator = Iterator;
|
||||
/**
|
||||
* Reverse iterator of set container storing elements in a vector.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Unique Whether duplicated key is blocked or not
|
||||
* @template Source Source container type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ReverseIterator = /** @class */ (function (_super) {
|
||||
__extends(ReverseIterator, _super);
|
||||
function ReverseIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ReverseIterator.prototype._Create_neighbor = function (base) {
|
||||
return new ReverseIterator(base);
|
||||
};
|
||||
return ReverseIterator;
|
||||
}(ArrayReverseIteratorBase_1.ArrayReverseIteratorBase));
|
||||
SetElementVector.ReverseIterator = ReverseIterator;
|
||||
})(SetElementVector = exports.SetElementVector || (exports.SetElementVector = {}));
|
||||
exports.SetElementVector = SetElementVector;
|
||||
//# sourceMappingURL=SetElementVector.js.map
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { UniqueMap } from "../../../base/container/UniqueMap";
|
||||
import { ITreeContainer } from "./ITreeContainer";
|
||||
import { IPair } from "../../../utility/IPair";
|
||||
import { Entry } from "../../../utility/Entry";
|
||||
import { Pair } from "../../../utility/Pair";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
/**
|
||||
* Basic tree map blocking duplicated key.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link UniqueTreeMap}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class UniqueTreeMap<Key, T, Source extends UniqueTreeMap<Key, T, Source, IteratorT, ReverseT>, IteratorT extends UniqueMap.Iterator<Key, T, Source, IteratorT, ReverseT>, ReverseT extends UniqueMap.ReverseIterator<Key, T, Source, IteratorT, ReverseT>> extends UniqueMap<Key, T, Source, IteratorT, ReverseT> implements ITreeContainer<Key, Entry<Key, T>, Source, IteratorT, ReverseT, IPair<Key, T>> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
find(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract lower_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract upper_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equal_range(key: Key): Pair<IteratorT, IteratorT>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract key_comp(): Comparator<Key>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
value_comp(): Comparator<IPair<Key, T>>;
|
||||
protected _Key_eq(x: Key, y: Key): boolean;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
emplace(key: Key, val: T): Pair<IteratorT, boolean>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
emplace_hint(hint: IteratorT, key: Key, val: T): IteratorT;
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
"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.UniqueTreeMap = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var UniqueMap_1 = require("../../../base/container/UniqueMap");
|
||||
var ITreeContainer_1 = require("./ITreeContainer");
|
||||
var Entry_1 = require("../../../utility/Entry");
|
||||
var Pair_1 = require("../../../utility/Pair");
|
||||
/**
|
||||
* Basic tree map blocking duplicated key.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template T Mapped type
|
||||
* @template Source Derived type extending this {@link UniqueTreeMap}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var UniqueTreeMap = /** @class */ (function (_super) {
|
||||
__extends(UniqueTreeMap, _super);
|
||||
function UniqueTreeMap() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeMap.prototype.find = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(key, it.first))
|
||||
return it;
|
||||
else
|
||||
return this.end();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeMap.prototype.equal_range = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
return new Pair_1.Pair(it, !it.equals(this.end()) && this._Key_eq(key, it.first)
|
||||
? it.next()
|
||||
: it);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeMap.prototype.value_comp = function () {
|
||||
var _this = this;
|
||||
return function (x, y) { return _this.key_comp()(x.first, y.first); };
|
||||
};
|
||||
UniqueTreeMap.prototype._Key_eq = function (x, y) {
|
||||
return !this.key_comp()(x, y) && !this.key_comp()(y, x);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeMap.prototype.emplace = function (key, val) {
|
||||
// FIND POSITION TO INSERT
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(it.first, key))
|
||||
return new Pair_1.Pair(it, false);
|
||||
// ITERATOR TO RETURN
|
||||
it = this.data_.insert(it, new Entry_1.Entry(key, val));
|
||||
this._Handle_insert(it, it.next());
|
||||
return new Pair_1.Pair(it, true);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeMap.prototype.emplace_hint = function (hint, key, val) {
|
||||
var elem = new Entry_1.Entry(key, val);
|
||||
var validate = ITreeContainer_1.ITreeContainer.emplacable(this, hint, elem);
|
||||
if (validate) {
|
||||
var it = this.data_.insert(hint, elem);
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
}
|
||||
else
|
||||
return this.emplace(key, val).first;
|
||||
};
|
||||
return UniqueTreeMap;
|
||||
}(UniqueMap_1.UniqueMap));
|
||||
exports.UniqueTreeMap = UniqueTreeMap;
|
||||
//# sourceMappingURL=UniqueTreeMap.js.map
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { UniqueSet } from "../../../base/container/UniqueSet";
|
||||
import { ITreeContainer } from "./ITreeContainer";
|
||||
import { Pair } from "../../../utility/Pair";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
/**
|
||||
* Basic tree set blocking duplicated key.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Source Derived type extending this {@link UniqueTreeSet}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class UniqueTreeSet<Key, Source extends UniqueTreeSet<Key, Source, IteratorT, ReverseT>, IteratorT extends UniqueSet.Iterator<Key, Source, IteratorT, ReverseT>, ReverseT extends UniqueSet.ReverseIterator<Key, Source, IteratorT, ReverseT>> extends UniqueSet<Key, Source, IteratorT, ReverseT> implements ITreeContainer<Key, Key, Source, IteratorT, ReverseT, Key> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
find(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract lower_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract upper_bound(key: Key): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equal_range(key: Key): Pair<IteratorT, IteratorT>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract key_comp(): Comparator<Key>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
value_comp(): Comparator<Key>;
|
||||
protected _Key_eq(x: Key, y: Key): boolean;
|
||||
protected _Insert_by_key(key: Key): Pair<IteratorT, boolean>;
|
||||
protected _Insert_by_hint(hint: IteratorT, key: Key): IteratorT;
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
"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.UniqueTreeSet = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var UniqueSet_1 = require("../../../base/container/UniqueSet");
|
||||
var ITreeContainer_1 = require("./ITreeContainer");
|
||||
var Pair_1 = require("../../../utility/Pair");
|
||||
/**
|
||||
* Basic tree set blocking duplicated key.
|
||||
*
|
||||
* @template Key Key type
|
||||
* @template Source Derived type extending this {@link UniqueTreeSet}
|
||||
* @template IteratorT Iterator type
|
||||
* @template ReverseT Reverse iterator type
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var UniqueTreeSet = /** @class */ (function (_super) {
|
||||
__extends(UniqueTreeSet, _super);
|
||||
function UniqueTreeSet() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeSet.prototype.find = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(key, it.value))
|
||||
return it;
|
||||
else
|
||||
return this.end();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeSet.prototype.equal_range = function (key) {
|
||||
var it = this.lower_bound(key);
|
||||
return new Pair_1.Pair(it, !it.equals(this.end()) && this._Key_eq(key, it.value)
|
||||
? it.next()
|
||||
: it);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
UniqueTreeSet.prototype.value_comp = function () {
|
||||
return this.key_comp();
|
||||
};
|
||||
UniqueTreeSet.prototype._Key_eq = function (x, y) {
|
||||
return !this.key_comp()(x, y) && !this.key_comp()(y, x);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
UniqueTreeSet.prototype._Insert_by_key = function (key) {
|
||||
// FIND POSITION TO INSERT
|
||||
var it = this.lower_bound(key);
|
||||
if (!it.equals(this.end()) && this._Key_eq(it.value, key))
|
||||
return new Pair_1.Pair(it, false);
|
||||
// ITERATOR TO RETURN
|
||||
it = this.data_.insert(it, key);
|
||||
this._Handle_insert(it, it.next());
|
||||
return new Pair_1.Pair(it, true);
|
||||
};
|
||||
UniqueTreeSet.prototype._Insert_by_hint = function (hint, key) {
|
||||
var validate = ITreeContainer_1.ITreeContainer.emplacable(this, hint, key);
|
||||
if (validate) {
|
||||
var it = this.data_.insert(hint, key);
|
||||
this._Handle_insert(it, it.next());
|
||||
return it;
|
||||
}
|
||||
else
|
||||
return this._Insert_by_key(key).first;
|
||||
};
|
||||
return UniqueTreeSet;
|
||||
}(UniqueSet_1.UniqueSet));
|
||||
exports.UniqueTreeSet = UniqueTreeSet;
|
||||
//# sourceMappingURL=UniqueTreeSet.js.map
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IEmpty } from "../partial/IEmpty";
|
||||
import { IPush } from "../partial/IPush";
|
||||
import { ISize } from "../partial/ISize";
|
||||
/**
|
||||
* Base class for Adaptor Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class AdaptorContainer<T, Source extends IEmpty & ISize & IPush<T>, This extends AdaptorContainer<T, Source, This>> implements IEmpty, ISize, IPush<T> {
|
||||
protected source_: Source;
|
||||
protected constructor(source: Source);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
size(): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
empty(): boolean;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push(...elems: T[]): number;
|
||||
/**
|
||||
* Remove element.
|
||||
*/
|
||||
abstract pop(): void;
|
||||
/**
|
||||
* Swap elements.
|
||||
*
|
||||
* @param obj Target container to swap.
|
||||
*/
|
||||
swap(obj: This): void;
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
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;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdaptorContainer = void 0;
|
||||
/**
|
||||
* Base class for Adaptor Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var AdaptorContainer = /** @class */ (function () {
|
||||
function AdaptorContainer(source) {
|
||||
this.source_ = source;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
AdaptorContainer.prototype.size = function () {
|
||||
return this.source_.size();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
AdaptorContainer.prototype.empty = function () {
|
||||
return this.source_.empty();
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ELEMENTS I/O
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
AdaptorContainer.prototype.push = function () {
|
||||
var _a;
|
||||
var elems = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
elems[_i] = arguments[_i];
|
||||
}
|
||||
return (_a = this.source_).push.apply(_a, __spreadArray([], __read(elems), false));
|
||||
};
|
||||
/**
|
||||
* Swap elements.
|
||||
*
|
||||
* @param obj Target container to swap.
|
||||
*/
|
||||
AdaptorContainer.prototype.swap = function (obj) {
|
||||
var _a;
|
||||
_a = __read([obj.source_, this.source_], 2), this.source_ = _a[0], obj.source_ = _a[1];
|
||||
};
|
||||
return AdaptorContainer;
|
||||
}());
|
||||
exports.AdaptorContainer = AdaptorContainer;
|
||||
//# sourceMappingURL=AdaptorContainer.js.map
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { ILinearContainerBase } from "./ILinearContainerBase";
|
||||
import { Container } from "../../../base/container/Container";
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { ArrayIteratorBase } from "../../iterator/ArrayIteratorBase";
|
||||
import { ArrayReverseIteratorBase } from "../../iterator/ArrayReverseIteratorBase";
|
||||
/**
|
||||
* Base array container.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ArrayContainer<T extends ElemT, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, ElemT>, ArrayT extends ArrayContainer<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, IteratorT extends ArrayIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ReverseT extends ArrayReverseIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ElemT> extends Container<T, SourceT, IteratorT, ReverseT, ElemT> implements ILinearContainerBase<T, SourceT, IteratorT, ReverseT, ElemT> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract resize(n: number): void;
|
||||
protected abstract source(): SourceT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
begin(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
end(): IteratorT;
|
||||
abstract nth(index: number): IteratorT;
|
||||
/**
|
||||
* Get element at specific position.
|
||||
*
|
||||
* @param index Specific position.
|
||||
* @return The element at the *index*.
|
||||
*/
|
||||
at(index: number): T;
|
||||
protected abstract _At(index: number): T;
|
||||
/**
|
||||
* Change element at specific position.
|
||||
*
|
||||
* @param index Specific position.
|
||||
* @param val The new value to change.
|
||||
*/
|
||||
set(index: number, val: T): void;
|
||||
protected abstract _Set(index: number, val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
front(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
front(val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
back(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
back(val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract push_back(val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert(pos: IteratorT, val: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert(pos: IteratorT, n: number, val: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(pos: IteratorT, first: InputIterator, last: InputIterator): IteratorT;
|
||||
protected _Insert_by_repeating_val(position: IteratorT, n: number, val: T): IteratorT;
|
||||
protected abstract _Insert_by_range<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(pos: IteratorT, first: InputIterator, last: InputIterator): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
pop_back(): void;
|
||||
protected abstract _Pop_back(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(it: IteratorT): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(first: IteratorT, last: IteratorT): IteratorT;
|
||||
protected abstract _Erase_by_range(first: IteratorT, last: IteratorT): IteratorT;
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
"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.ArrayContainer = void 0;
|
||||
var Container_1 = require("../../../base/container/Container");
|
||||
var ErrorGenerator_1 = require("../../exception/ErrorGenerator");
|
||||
var RangeError_1 = require("../../../exception/RangeError");
|
||||
var Repeater_1 = require("../../iterator/disposable/Repeater");
|
||||
/**
|
||||
* Base array container.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ArrayContainer = /** @class */ (function (_super) {
|
||||
__extends(ArrayContainer, _super);
|
||||
function ArrayContainer() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* =========================================================
|
||||
ACCESSORS
|
||||
- ITERATORS
|
||||
- INDEXES
|
||||
============================================================
|
||||
ITERATORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayContainer.prototype.begin = function () {
|
||||
return this.nth(0);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayContainer.prototype.end = function () {
|
||||
return this.nth(this.size());
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INDEXES
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Get element at specific position.
|
||||
*
|
||||
* @param index Specific position.
|
||||
* @return The element at the *index*.
|
||||
*/
|
||||
ArrayContainer.prototype.at = function (index) {
|
||||
return this._At(index);
|
||||
};
|
||||
/**
|
||||
* Change element at specific position.
|
||||
*
|
||||
* @param index Specific position.
|
||||
* @param val The new value to change.
|
||||
*/
|
||||
ArrayContainer.prototype.set = function (index, val) {
|
||||
if (index < 0)
|
||||
throw ErrorGenerator_1.ErrorGenerator.negative_index(this.source(), "at", index);
|
||||
else if (index >= this.size())
|
||||
throw ErrorGenerator_1.ErrorGenerator.excessive_index(this.source(), "at", index, this.size());
|
||||
this._Set(index, val);
|
||||
};
|
||||
ArrayContainer.prototype.front = function (val) {
|
||||
if (arguments.length === 0)
|
||||
return this.at(0);
|
||||
else
|
||||
this.set(0, val);
|
||||
};
|
||||
ArrayContainer.prototype.back = function (val) {
|
||||
var index = this.size() - 1;
|
||||
if (arguments.length === 0)
|
||||
return this.at(index);
|
||||
else
|
||||
this.set(index, val);
|
||||
};
|
||||
ArrayContainer.prototype.insert = function (pos) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
// VALIDATION
|
||||
if (pos._Get_array() !== this)
|
||||
throw ErrorGenerator_1.ErrorGenerator.not_my_iterator(this.source(), "insert");
|
||||
else if (pos.index() < 0)
|
||||
throw ErrorGenerator_1.ErrorGenerator.negative_iterator(this.source(), "insert", pos.index());
|
||||
else if (pos.index() > this.size())
|
||||
pos = this.end();
|
||||
// BRANCHES
|
||||
if (args.length === 1)
|
||||
return this._Insert_by_repeating_val(pos, 1, args[0]);
|
||||
else if (args.length === 2 && typeof args[0] === "number")
|
||||
return this._Insert_by_repeating_val(pos, args[0], args[1]);
|
||||
else
|
||||
return this._Insert_by_range(pos, args[0], args[1]);
|
||||
};
|
||||
ArrayContainer.prototype._Insert_by_repeating_val = function (position, n, val) {
|
||||
var first = new Repeater_1.Repeater(0, val);
|
||||
var last = new Repeater_1.Repeater(n);
|
||||
return this._Insert_by_range(position, first, last);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ERASE
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayContainer.prototype.pop_back = function () {
|
||||
if (this.empty() === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.empty(this.source(), "pop_back");
|
||||
this._Pop_back();
|
||||
};
|
||||
ArrayContainer.prototype.erase = function (first, last) {
|
||||
if (last === void 0) { last = first.next(); }
|
||||
// VALIDATION
|
||||
if (first._Get_array() !== this || last._Get_array() !== this)
|
||||
throw ErrorGenerator_1.ErrorGenerator.not_my_iterator(this.source(), "erase");
|
||||
else if (first.index() < 0)
|
||||
throw ErrorGenerator_1.ErrorGenerator.negative_iterator(this.source(), "erase", first.index());
|
||||
else if (first.index() > last.index())
|
||||
throw new RangeError_1.RangeError("Error on ".concat(ErrorGenerator_1.ErrorGenerator.get_class_name(this.source()), ".erase(): first iterator has greater index than last -> (first = ").concat(first.index(), ", last = ").concat(last.index(), ")."));
|
||||
// ADJUSTMENT
|
||||
if (first.index() >= this.size())
|
||||
return this.end();
|
||||
// ERASE ELEMENTS
|
||||
return this._Erase_by_range(first, last);
|
||||
};
|
||||
return ArrayContainer;
|
||||
}(Container_1.Container));
|
||||
exports.ArrayContainer = ArrayContainer;
|
||||
//# sourceMappingURL=ArrayContainer.js.map
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { IPushBack } from "../partial/IPushBack";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
export interface ILinearContainerBase<T extends ElemT, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> extends IContainer<T, SourceT, IteratorT, ReverseT, ElemT>, IPushBack<T> {
|
||||
/**
|
||||
* Fill Assigner.
|
||||
*
|
||||
* @param n Initial size.
|
||||
* @param val Value to fill.
|
||||
*/
|
||||
assign(n: number, val: T): void;
|
||||
/**
|
||||
* Range Assigner.
|
||||
*
|
||||
* @param first Input iterator of the first position.
|
||||
* @param last Input iterator of the last position.
|
||||
*/
|
||||
assign<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(first: InputIterator, last: InputIterator): void;
|
||||
/**
|
||||
* Resize this {@link Vector} forcibly.
|
||||
*
|
||||
* @param n New container size.
|
||||
*/
|
||||
resize(n: number): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push_back(val: T): void;
|
||||
/**
|
||||
* Erase the last element.
|
||||
*/
|
||||
pop_back(): void;
|
||||
/**
|
||||
* Insert a single element.
|
||||
*
|
||||
* @param pos Position to insert.
|
||||
* @param val Value to insert.
|
||||
* @return An iterator to the newly inserted element.
|
||||
*/
|
||||
insert(pos: IteratorT, val: T): IteratorT;
|
||||
/**
|
||||
* Insert repeated elements.
|
||||
*
|
||||
* @param pos Position to insert.
|
||||
* @param n Number of elements to insert.
|
||||
* @param val Value to insert repeatedly.
|
||||
* @return An iterator to the first of the newly inserted elements.
|
||||
*/
|
||||
insert(pos: IteratorT, n: number, val: T): IteratorT;
|
||||
/**
|
||||
* Insert range elements.
|
||||
*
|
||||
* @param pos Position to insert.
|
||||
* @param first Input iterator of the first position.
|
||||
* @param last Input iteartor of the last position.
|
||||
* @return An iterator to the first of the newly inserted elements.
|
||||
*/
|
||||
insert<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(pos: IteratorT, first: InputIterator, last: InputIterator): IteratorT;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=ILinearContainerBase.js.map
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { BinaryPredicator } from "../../functional/BinaryPredicator";
|
||||
import { Comparator } from "../../functional/Comparator";
|
||||
import { UnaryPredicator } from "../../functional/UnaryPredicator";
|
||||
export interface IListAlgorithm<T, Source> {
|
||||
/**
|
||||
* Remove duplicated elements.
|
||||
*
|
||||
* @param binary_pred A binary function predicates two arguments are equal. Default is {@link equal_to}.
|
||||
*/
|
||||
unique(binary_pred?: BinaryPredicator<T>): void;
|
||||
/**
|
||||
* Remove elements with specific value.
|
||||
*
|
||||
* @param val The value to remove.
|
||||
*/
|
||||
remove(val: T): void;
|
||||
/**
|
||||
* Remove elements with specific function.
|
||||
*
|
||||
* @param pred A unary function determines whether remove or not.
|
||||
*/
|
||||
remove_if(pred: UnaryPredicator<T>): void;
|
||||
/**
|
||||
* Merge two *sorted* containers.
|
||||
*
|
||||
* @param source Source container to transfer.
|
||||
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
|
||||
*/
|
||||
merge(from: Source, comp?: Comparator<T>): void;
|
||||
/**
|
||||
* Sort elements.
|
||||
*
|
||||
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Default is {@link less}.
|
||||
*/
|
||||
sort(comp?: Comparator<T>): void;
|
||||
/**
|
||||
* Reverse elements.
|
||||
*/
|
||||
reverse(): void;
|
||||
/**
|
||||
* Swap elements.
|
||||
*
|
||||
* @param obj Target container to swap.
|
||||
*/
|
||||
swap(obj: Source): void;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IListAlgorithm.js.map
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { ILinearContainerBase } from "./ILinearContainerBase";
|
||||
import { Container } from "../../../base/container/Container";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { ReverseIterator } from "../../iterator/ReverseIterator";
|
||||
import { ListIterator } from "../../iterator/ListIterator";
|
||||
/**
|
||||
* Basic List Container.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ListContainer<T, SourceT extends IContainer<T, SourceT, IteratorT, ReverseIteratorT, T>, IteratorT extends ListIterator<T, SourceT, IteratorT, ReverseIteratorT, T>, ReverseIteratorT extends ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, T>> extends Container<T, SourceT, IteratorT, ReverseIteratorT, T> implements ILinearContainerBase<T, SourceT, IteratorT, ReverseIteratorT, T> {
|
||||
private size_;
|
||||
protected begin_: IteratorT;
|
||||
protected end_: IteratorT;
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
protected constructor();
|
||||
protected abstract _Create_iterator(prev: IteratorT, next: IteratorT, val?: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
assign(n: number, val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
assign<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(first: InputIterator, last: InputIterator): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
resize(n: number): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
begin(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
end(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
size(): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push_front(val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push_back(val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
pop_front(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
pop_back(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push(...items: T[]): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert(position: IteratorT, val: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert(position: IteratorT, size: number, val: T): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
insert<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(position: IteratorT, begin: InputIterator, end: InputIterator): IteratorT;
|
||||
private _Insert_by_repeating_val;
|
||||
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(position: IteratorT, begin: InputIterator, end: InputIterator): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(position: IteratorT): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
erase(first: IteratorT, last: IteratorT): IteratorT;
|
||||
protected _Erase_by_range(first: IteratorT, last: IteratorT): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
swap(obj: SourceT): void;
|
||||
}
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
"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.ListContainer = void 0;
|
||||
var Container_1 = require("../../../base/container/Container");
|
||||
var ListIterator_1 = require("../../iterator/ListIterator");
|
||||
var Repeater_1 = require("../../iterator/disposable/Repeater");
|
||||
var NativeArrayIterator_1 = require("../../iterator/disposable/NativeArrayIterator");
|
||||
var global_1 = require("../../../iterator/global");
|
||||
var ErrorGenerator_1 = require("../../exception/ErrorGenerator");
|
||||
/**
|
||||
* Basic List Container.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ListContainer = /** @class */ (function (_super) {
|
||||
__extends(ListContainer, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
function ListContainer() {
|
||||
var _this = _super.call(this) || this;
|
||||
// INIT MEMBERS
|
||||
_this.end_ = _this._Create_iterator(null, null);
|
||||
_this.clear();
|
||||
return _this;
|
||||
}
|
||||
ListContainer.prototype.assign = function (par1, par2) {
|
||||
this.clear();
|
||||
this.insert(this.end(), par1, par2);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.clear = function () {
|
||||
// DISCONNECT NODES
|
||||
ListIterator_1.ListIterator._Set_prev(this.end_, this.end_);
|
||||
ListIterator_1.ListIterator._Set_next(this.end_, this.end_);
|
||||
// RE-SIZE -> 0
|
||||
this.begin_ = this.end_;
|
||||
this.size_ = 0;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.resize = function (n) {
|
||||
var expansion = n - this.size();
|
||||
if (expansion > 0)
|
||||
this.insert(this.end(), expansion, undefined);
|
||||
else if (expansion < 0)
|
||||
this.erase((0, global_1.advance)(this.end(), -expansion), this.end());
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.begin = function () {
|
||||
return this.begin_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.end = function () {
|
||||
return this.end_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.size = function () {
|
||||
return this.size_;
|
||||
};
|
||||
/* =========================================================
|
||||
ELEMENTS I/O
|
||||
- PUSH & POP
|
||||
- INSERT
|
||||
- ERASE
|
||||
- POST-PROCESS
|
||||
============================================================
|
||||
PUSH & POP
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.push_front = function (val) {
|
||||
this.insert(this.begin_, val);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.push_back = function (val) {
|
||||
this.insert(this.end_, val);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.pop_front = function () {
|
||||
if (this.empty() === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.empty(this.end_.source().constructor.name, "pop_front");
|
||||
this.erase(this.begin_);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.pop_back = function () {
|
||||
if (this.empty() === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.empty(this.end_.source().constructor.name, "pop_back");
|
||||
this.erase(this.end_.prev());
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.push = function () {
|
||||
var items = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
items[_i] = arguments[_i];
|
||||
}
|
||||
if (items.length === 0)
|
||||
return this.size();
|
||||
// INSERT BY RANGE
|
||||
var first = new NativeArrayIterator_1.NativeArrayIterator(items, 0);
|
||||
var last = new NativeArrayIterator_1.NativeArrayIterator(items, items.length);
|
||||
this._Insert_by_range(this.end(), first, last);
|
||||
// RETURN SIZE
|
||||
return this.size();
|
||||
};
|
||||
ListContainer.prototype.insert = function (pos) {
|
||||
var args = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
// VALIDATION
|
||||
if (pos.source() !== this.end_.source())
|
||||
throw ErrorGenerator_1.ErrorGenerator.not_my_iterator(this.end_.source(), "insert");
|
||||
else if (pos.erased_ === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.erased_iterator(this.end_.source(), "insert");
|
||||
// BRANCHES
|
||||
if (args.length === 1)
|
||||
return this._Insert_by_repeating_val(pos, 1, args[0]);
|
||||
else if (args.length === 2 && typeof args[0] === "number")
|
||||
return this._Insert_by_repeating_val(pos, args[0], args[1]);
|
||||
else
|
||||
return this._Insert_by_range(pos, args[0], args[1]);
|
||||
};
|
||||
ListContainer.prototype._Insert_by_repeating_val = function (position, n, val) {
|
||||
var first = new Repeater_1.Repeater(0, val);
|
||||
var last = new Repeater_1.Repeater(n);
|
||||
return this._Insert_by_range(position, first, last);
|
||||
};
|
||||
ListContainer.prototype._Insert_by_range = function (position, begin, end) {
|
||||
var prev = position.prev();
|
||||
var first = null;
|
||||
var size = 0;
|
||||
for (var it = begin; it.equals(end) === false; it = it.next()) {
|
||||
// CONSTRUCT ITEM, THE NEW ELEMENT
|
||||
var item = this._Create_iterator(prev, null, it.value);
|
||||
if (size === 0)
|
||||
first = item;
|
||||
// PLACE ITEM ON THE NEXT OF "PREV"
|
||||
ListIterator_1.ListIterator._Set_next(prev, item);
|
||||
// SHIFT CURRENT ITEM TO PREVIOUS
|
||||
prev = item;
|
||||
++size;
|
||||
}
|
||||
// WILL FIRST BE THE BEGIN?
|
||||
if (position.equals(this.begin()) === true)
|
||||
this.begin_ = first;
|
||||
// CONNECT BETWEEN LAST AND POSITION
|
||||
ListIterator_1.ListIterator._Set_next(prev, position);
|
||||
ListIterator_1.ListIterator._Set_prev(position, prev);
|
||||
this.size_ += size;
|
||||
return first;
|
||||
};
|
||||
ListContainer.prototype.erase = function (first, last) {
|
||||
if (last === void 0) { last = first.next(); }
|
||||
return this._Erase_by_range(first, last);
|
||||
};
|
||||
ListContainer.prototype._Erase_by_range = function (first, last) {
|
||||
// VALIDATION
|
||||
if (first.source() !== this.end_.source())
|
||||
throw ErrorGenerator_1.ErrorGenerator.not_my_iterator(this.end_.source(), "insert");
|
||||
else if (first.erased_ === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.erased_iterator(this.end_.source(), "insert");
|
||||
else if (first.equals(this.end_))
|
||||
return this.end_;
|
||||
// FIND PREV AND NEXT
|
||||
var prev = first.prev();
|
||||
// SHRINK
|
||||
ListIterator_1.ListIterator._Set_next(prev, last);
|
||||
ListIterator_1.ListIterator._Set_prev(last, prev);
|
||||
for (var it = first; !it.equals(last); it = it.next()) {
|
||||
it.erased_ = true;
|
||||
--this.size_;
|
||||
}
|
||||
if (first.equals(this.begin_))
|
||||
this.begin_ = last;
|
||||
return last;
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
SWAP
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListContainer.prototype.swap = function (obj) {
|
||||
var _a, _b, _c;
|
||||
_a = __read([obj.begin_, this.begin_], 2), this.begin_ = _a[0], obj.begin_ = _a[1];
|
||||
_b = __read([obj.end_, this.end_], 2), this.end_ = _b[0], obj.end_ = _b[1];
|
||||
_c = __read([obj.size_, this.size_], 2), this.size_ = _c[0], obj.size_ = _c[1];
|
||||
};
|
||||
return ListContainer;
|
||||
}(Container_1.Container));
|
||||
exports.ListContainer = ListContainer;
|
||||
//# sourceMappingURL=ListContainer.js.map
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { ArrayContainer } from "./ArrayContainer";
|
||||
import { IContainer } from "../../../base/container/IContainer";
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { ArrayIteratorBase } from "../../iterator/ArrayIteratorBase";
|
||||
import { ArrayReverseIteratorBase } from "../../iterator/ArrayReverseIteratorBase";
|
||||
export declare abstract class VectorContainer<T, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, T>, ArrayT extends VectorContainer<T, SourceT, ArrayT, IteratorT, ReverseT>, IteratorT extends ArrayIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, T>, ReverseT extends ArrayReverseIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, T>> extends ArrayContainer<T, SourceT, ArrayT, IteratorT, ReverseT, T> {
|
||||
protected data_: T[];
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
protected constructor();
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
assign(n: number, val: T): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
assign<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(begin: InputIterator, end: InputIterator): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
resize(n: number): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
size(): number;
|
||||
protected _At(index: number): T;
|
||||
protected _Set(index: number, val: T): void;
|
||||
/**
|
||||
* Access data.
|
||||
*
|
||||
* @return An array capsuled by this {@link Vector}.
|
||||
*/
|
||||
data(): Array<T>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push(...items: T[]): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
push_back(val: T): void;
|
||||
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(position: IteratorT, first: InputIterator, last: InputIterator): IteratorT;
|
||||
protected _Pop_back(): void;
|
||||
protected _Erase_by_range(first: IteratorT, last: IteratorT): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: SourceT): boolean;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
swap(obj: SourceT): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
toJSON(): Array<T>;
|
||||
}
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
"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;
|
||||
};
|
||||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
||||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
||||
if (ar || !(i in from)) {
|
||||
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
||||
ar[i] = from[i];
|
||||
}
|
||||
}
|
||||
return to.concat(ar || Array.prototype.slice.call(from));
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VectorContainer = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var ArrayContainer_1 = require("./ArrayContainer");
|
||||
var VectorContainer = /** @class */ (function (_super) {
|
||||
__extends(VectorContainer, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
function VectorContainer() {
|
||||
return _super.call(this) || this;
|
||||
}
|
||||
VectorContainer.prototype.assign = function (first, second) {
|
||||
this.clear();
|
||||
this.insert(this.end(), first, second);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.clear = function () {
|
||||
this.data_.splice(0, this.data_.length);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.resize = function (n) {
|
||||
this.data_.length = n;
|
||||
};
|
||||
/* =========================================================
|
||||
ACCESSORS
|
||||
========================================================= */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.size = function () {
|
||||
return this.data_.length;
|
||||
};
|
||||
VectorContainer.prototype._At = function (index) {
|
||||
return this.data_[index];
|
||||
};
|
||||
VectorContainer.prototype._Set = function (index, val) {
|
||||
this.data_[index] = val;
|
||||
};
|
||||
/**
|
||||
* Access data.
|
||||
*
|
||||
* @return An array capsuled by this {@link Vector}.
|
||||
*/
|
||||
VectorContainer.prototype.data = function () {
|
||||
return this.data_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype[Symbol.iterator] = function () {
|
||||
return this.data_[Symbol.iterator]();
|
||||
};
|
||||
/* =========================================================
|
||||
ELEMENTS I/O
|
||||
- INSERT
|
||||
- ERASE
|
||||
============================================================
|
||||
INSERT
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.push = function () {
|
||||
var _a;
|
||||
var items = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
items[_i] = arguments[_i];
|
||||
}
|
||||
return (_a = this.data_).push.apply(_a, __spreadArray([], __read(items), false));
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.push_back = function (val) {
|
||||
this.data_.push(val);
|
||||
};
|
||||
VectorContainer.prototype._Insert_by_range = function (position, first, last) {
|
||||
var _a;
|
||||
if (position.index() >= this.size()) {
|
||||
// WHEN INSERT TO THE LAST
|
||||
var prev_size = this.size();
|
||||
for (; !first.equals(last); first = first.next())
|
||||
this.data_.push(first.value);
|
||||
return this.nth(prev_size);
|
||||
}
|
||||
else {
|
||||
//----
|
||||
// INSERT TO THE MIDDLE POSITION
|
||||
//----
|
||||
// CUT RIGHT SIDE
|
||||
var spliced_array = this.data_.splice(position.index());
|
||||
// INSERT ELEMENTS
|
||||
for (; !first.equals(last); first = first.next())
|
||||
this.data_.push(first.value);
|
||||
(_a = this.data_).push.apply(_a, __spreadArray([], __read(spliced_array), false)); // CONCAT THE SPLICEDS
|
||||
return position;
|
||||
}
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ERASE
|
||||
--------------------------------------------------------- */
|
||||
VectorContainer.prototype._Pop_back = function () {
|
||||
this.data_.pop();
|
||||
};
|
||||
VectorContainer.prototype._Erase_by_range = function (first, last) {
|
||||
if (first.index() >= this.size())
|
||||
return first;
|
||||
// ERASE ELEMENTS
|
||||
if (last.index() >= this.size()) {
|
||||
this.data_.splice(first.index());
|
||||
return this.end();
|
||||
}
|
||||
else
|
||||
this.data_.splice(first.index(), last.index() - first.index());
|
||||
return first;
|
||||
};
|
||||
/* ---------------------------------------------------------------
|
||||
UTILITIES
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.equals = function (obj) {
|
||||
return this.data_ === obj.data_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.swap = function (obj) {
|
||||
var _a;
|
||||
_a = __read([
|
||||
obj.data_,
|
||||
this.data_,
|
||||
], 2), this.data_ = _a[0], obj.data_ = _a[1];
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
VectorContainer.prototype.toJSON = function () {
|
||||
return this.data_;
|
||||
};
|
||||
return VectorContainer;
|
||||
}(ArrayContainer_1.ArrayContainer));
|
||||
exports.VectorContainer = VectorContainer;
|
||||
//# sourceMappingURL=VectorContainer.js.map
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IClear {
|
||||
/**
|
||||
* Clear elements.
|
||||
*/
|
||||
clear(): void;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IClear.js.map
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IPushFront } from "./IPushFront";
|
||||
export interface IDeque<T> extends IPushFront<T> {
|
||||
/**
|
||||
* Erase the first element.
|
||||
*/
|
||||
pop_front(): void;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IDeque.js.map
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IEmpty {
|
||||
/**
|
||||
* Test whether container is empty.
|
||||
*/
|
||||
empty(): boolean;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IEmpty.js.map
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IFront<T> {
|
||||
/**
|
||||
* Get the first element.
|
||||
*
|
||||
* @return The first element.
|
||||
*/
|
||||
front(): T;
|
||||
/**
|
||||
* Change the first element.
|
||||
*
|
||||
* @param val The value to change.
|
||||
*/
|
||||
front(val: T): void;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IFront.js.map
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
import { IPointer } from "../../../functional/IPointer";
|
||||
export interface IInsert<Iterator extends IForwardIterator<IPointer.ValueType<Iterator>, Iterator>> {
|
||||
insert(it: Iterator, value: IPointer.ValueType<Iterator>): Iterator;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IInsert.js.map
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IPush<T> {
|
||||
/**
|
||||
* Insert items at the end.
|
||||
*
|
||||
* @param items Items to insert.
|
||||
* @return Number of elements in the container after insertion.
|
||||
*/
|
||||
push(...items: T[]): number;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IPush.js.map
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IPushBack<T> {
|
||||
/**
|
||||
* Insert an element at the end.
|
||||
*
|
||||
* @param val Value to insert.
|
||||
*/
|
||||
push_back(val: T): void;
|
||||
}
|
||||
export declare namespace IPushBack {
|
||||
type ContainerType<Range extends IPushBack<any>> = Range extends IPushBack<any> ? Range : unknown;
|
||||
type IteratorType<Range extends IPushBack<any>> = Range extends IPushBack<infer Iterator> ? Iterator : unknown;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IPushBack.js.map
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface IPushFront<T> {
|
||||
/**
|
||||
* Insert an element at the first.
|
||||
*
|
||||
* @param val Value to insert.
|
||||
*/
|
||||
push_front(val: T): void;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IPushFront.js.map
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export interface ISize {
|
||||
/**
|
||||
* Number of elements in the container.
|
||||
*/
|
||||
size(): number;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=ISize.js.map
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { InvalidArgument } from "../../exception/InvalidArgument";
|
||||
import { OutOfRange } from "../../exception/OutOfRange";
|
||||
export declare namespace ErrorGenerator {
|
||||
function get_class_name(instance: string | Instance): string;
|
||||
function empty(instance: Instance, method: string): OutOfRange;
|
||||
function negative_index(instance: Instance, method: string, index: number): OutOfRange;
|
||||
function excessive_index(instance: Instance, method: string, index: number, size: number): OutOfRange;
|
||||
function not_my_iterator(instance: Instance, method: string): InvalidArgument;
|
||||
function erased_iterator(instance: Instance, method: string): InvalidArgument;
|
||||
function negative_iterator(instance: Instance, method: string, index: number): OutOfRange;
|
||||
function iterator_end_value(instance: Instance, method?: string): OutOfRange;
|
||||
function key_nout_found<Key>(instance: Instance, method: string, key: Key): OutOfRange;
|
||||
}
|
||||
interface Instance {
|
||||
constructor: {
|
||||
name: string;
|
||||
__MODULE?: string;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ErrorGenerator = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
var OutOfRange_1 = require("../../exception/OutOfRange");
|
||||
var ErrorGenerator;
|
||||
(function (ErrorGenerator) {
|
||||
/* ---------------------------------------------------------
|
||||
COMMON
|
||||
--------------------------------------------------------- */
|
||||
function get_class_name(instance) {
|
||||
if (typeof instance === "string")
|
||||
return instance;
|
||||
var ret = instance.constructor.name;
|
||||
if (instance.constructor.__MODULE)
|
||||
ret = "".concat(instance.constructor.__MODULE, ".").concat(ret);
|
||||
return "std.".concat(ret);
|
||||
}
|
||||
ErrorGenerator.get_class_name = get_class_name;
|
||||
/* ---------------------------------------------------------
|
||||
CONTAINERS
|
||||
--------------------------------------------------------- */
|
||||
function empty(instance, method) {
|
||||
return new OutOfRange_1.OutOfRange("Error on ".concat(get_class_name(instance), ".").concat(method, "(): it's empty container."));
|
||||
}
|
||||
ErrorGenerator.empty = empty;
|
||||
function negative_index(instance, method, index) {
|
||||
return new OutOfRange_1.OutOfRange("Error on ".concat(get_class_name(instance), ".").concat(method, "(): parametric index is negative -> (index = ").concat(index, ")."));
|
||||
}
|
||||
ErrorGenerator.negative_index = negative_index;
|
||||
function excessive_index(instance, method, index, size) {
|
||||
return new OutOfRange_1.OutOfRange("Error on ".concat(get_class_name(instance), ".").concat(method, "(): parametric index is equal or greater than size -> (index = ").concat(index, ", size: ").concat(size, ")."));
|
||||
}
|
||||
ErrorGenerator.excessive_index = excessive_index;
|
||||
function not_my_iterator(instance, method) {
|
||||
return new InvalidArgument_1.InvalidArgument("Error on ".concat(get_class_name(instance), ".").concat(method, "(): parametric iterator is not this container's own."));
|
||||
}
|
||||
ErrorGenerator.not_my_iterator = not_my_iterator;
|
||||
function erased_iterator(instance, method) {
|
||||
return new InvalidArgument_1.InvalidArgument("Error on ".concat(get_class_name(instance), ".").concat(method, "(): parametric iterator, it already has been erased."));
|
||||
}
|
||||
ErrorGenerator.erased_iterator = erased_iterator;
|
||||
function negative_iterator(instance, method, index) {
|
||||
return new OutOfRange_1.OutOfRange("Error on ".concat(get_class_name(instance), ".").concat(method, "(): parametric iterator is directing negative position -> (index = ").concat(index, ")."));
|
||||
}
|
||||
ErrorGenerator.negative_iterator = negative_iterator;
|
||||
function iterator_end_value(instance, method) {
|
||||
if (method === void 0) { method = "end"; }
|
||||
var className = get_class_name(instance);
|
||||
return new OutOfRange_1.OutOfRange("Error on ".concat(className, ".Iterator.value: cannot access to the ").concat(className, ".").concat(method, "().value."));
|
||||
}
|
||||
ErrorGenerator.iterator_end_value = iterator_end_value;
|
||||
function key_nout_found(instance, method, key) {
|
||||
throw new OutOfRange_1.OutOfRange("Error on ".concat(get_class_name(instance), ".").concat(method, "(): unable to find the matched key -> ").concat(key));
|
||||
}
|
||||
ErrorGenerator.key_nout_found = key_nout_found;
|
||||
})(ErrorGenerator = exports.ErrorGenerator || (exports.ErrorGenerator = {}));
|
||||
//# sourceMappingURL=ErrorGenerator.js.map
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { ErrorCategory } from "../../exception/ErrorCategory";
|
||||
/**
|
||||
* Base class for error instances.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ErrorInstance {
|
||||
protected category_: ErrorCategory;
|
||||
protected value_: number;
|
||||
/**
|
||||
* Default Constructor.
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param val Identifier of an error instance.
|
||||
* @param category An error category instance.
|
||||
*/
|
||||
constructor(val: number, category: ErrorCategory);
|
||||
/**
|
||||
* Assign content.
|
||||
*
|
||||
* @param val Identifier of an error condition.
|
||||
* @param category An error category instance.
|
||||
*/
|
||||
assign(val: number, category: ErrorCategory): void;
|
||||
/**
|
||||
* Clear content.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Get category.
|
||||
*
|
||||
* @return The category object.
|
||||
*/
|
||||
category(): ErrorCategory;
|
||||
/**
|
||||
* Get value, the identifier.
|
||||
*
|
||||
* @return The value, identifier of this object.
|
||||
*/
|
||||
value(): number;
|
||||
/**
|
||||
* Get message.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
message(): string;
|
||||
/**
|
||||
* Covert bo bool.
|
||||
*
|
||||
* @return Whether the {@link value} is not zero.
|
||||
*/
|
||||
to_bool(): boolean;
|
||||
toJSON(): object;
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ErrorInstance = void 0;
|
||||
/**
|
||||
* Base class for error instances.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ErrorInstance = /** @class */ (function () {
|
||||
function ErrorInstance(val, category) {
|
||||
if (val === void 0) { val = 0; }
|
||||
if (category === void 0) { category = null; }
|
||||
this.assign(val, category);
|
||||
}
|
||||
/**
|
||||
* Assign content.
|
||||
*
|
||||
* @param val Identifier of an error condition.
|
||||
* @param category An error category instance.
|
||||
*/
|
||||
ErrorInstance.prototype.assign = function (val, category) {
|
||||
this.category_ = category;
|
||||
this.value_ = val;
|
||||
};
|
||||
/**
|
||||
* Clear content.
|
||||
*/
|
||||
ErrorInstance.prototype.clear = function () {
|
||||
this.value_ = 0;
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Get category.
|
||||
*
|
||||
* @return The category object.
|
||||
*/
|
||||
ErrorInstance.prototype.category = function () {
|
||||
return this.category_;
|
||||
};
|
||||
/**
|
||||
* Get value, the identifier.
|
||||
*
|
||||
* @return The value, identifier of this object.
|
||||
*/
|
||||
ErrorInstance.prototype.value = function () {
|
||||
return this.value_;
|
||||
};
|
||||
/**
|
||||
* Get message.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
ErrorInstance.prototype.message = function () {
|
||||
return this.category_.message(this.value_);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
OPERATORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Covert bo bool.
|
||||
*
|
||||
* @return Whether the {@link value} is not zero.
|
||||
*/
|
||||
ErrorInstance.prototype.to_bool = function () {
|
||||
return this.value_ !== 0;
|
||||
};
|
||||
ErrorInstance.prototype.toJSON = function () {
|
||||
if (this.category_ === null)
|
||||
return {};
|
||||
else
|
||||
return {
|
||||
cateogory: this.category_.name(),
|
||||
value: this.value(),
|
||||
message: this.message(),
|
||||
};
|
||||
};
|
||||
return ErrorInstance;
|
||||
}());
|
||||
exports.ErrorInstance = ErrorInstance;
|
||||
//# sourceMappingURL=ErrorInstance.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type BinaryPredicator<X, Y = X> = (x: X, y: Y) => boolean;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=BinaryPredicator.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type Comparator<X, Y = X> = (x: X, y: Y) => boolean;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Comparator.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type General<T> = T;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=General.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type Hasher<Key> = (key: Key) => number;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Hasher.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type Temporary = any;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Temporary.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type UnaryPredicator<T> = (val: T) => boolean;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=UnaryPredicator.js.map
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
export declare type Writeonly<T> = T;
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Writeonly.js.map
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class HashBuckets<Key, Elem> {
|
||||
private readonly fetcher_;
|
||||
private readonly hasher_;
|
||||
private max_load_factor_;
|
||||
private data_;
|
||||
private size_;
|
||||
constructor(fetcher: Fetcher<Key, Elem>, hasher: Hasher<Key>);
|
||||
clear(): void;
|
||||
rehash(length: number): void;
|
||||
reserve(length: number): void;
|
||||
private initialize;
|
||||
length(): number;
|
||||
capacity(): number;
|
||||
at(index: number): Elem[];
|
||||
load_factor(): number;
|
||||
max_load_factor(): number;
|
||||
max_load_factor(z: number): void;
|
||||
hash_function(): Hasher<Key>;
|
||||
private index;
|
||||
insert(val: Elem): void;
|
||||
erase(val: Elem): void;
|
||||
}
|
||||
declare type Fetcher<Key, Elem> = (elem: Elem) => Key;
|
||||
export {};
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HashBuckets = void 0;
|
||||
/**
|
||||
* Hash buckets
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var HashBuckets = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function HashBuckets(fetcher, hasher) {
|
||||
this.fetcher_ = fetcher;
|
||||
this.hasher_ = hasher;
|
||||
this.max_load_factor_ = DEFAULT_MAX_FACTOR;
|
||||
this.data_ = [];
|
||||
this.size_ = 0;
|
||||
this.initialize();
|
||||
}
|
||||
HashBuckets.prototype.clear = function () {
|
||||
this.data_ = [];
|
||||
this.size_ = 0;
|
||||
this.initialize();
|
||||
};
|
||||
HashBuckets.prototype.rehash = function (length) {
|
||||
var e_1, _a, e_2, _b;
|
||||
length = Math.max(length, MIN_BUCKET_COUNT);
|
||||
var data = [];
|
||||
for (var i = 0; i < length; ++i)
|
||||
data.push([]);
|
||||
try {
|
||||
for (var _c = __values(this.data_), _d = _c.next(); !_d.done; _d = _c.next()) {
|
||||
var row = _d.value;
|
||||
try {
|
||||
for (var row_1 = (e_2 = void 0, __values(row)), row_1_1 = row_1.next(); !row_1_1.done; row_1_1 = row_1.next()) {
|
||||
var elem = row_1_1.value;
|
||||
var index = this.hasher_(this.fetcher_(elem)) % data.length;
|
||||
data[index].push(elem);
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (row_1_1 && !row_1_1.done && (_b = row_1.return)) _b.call(row_1);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
this.data_ = data;
|
||||
};
|
||||
HashBuckets.prototype.reserve = function (length) {
|
||||
if (length > this.capacity()) {
|
||||
length = Math.floor(length / this.max_load_factor_);
|
||||
this.rehash(length);
|
||||
}
|
||||
};
|
||||
HashBuckets.prototype.initialize = function () {
|
||||
for (var i = 0; i < MIN_BUCKET_COUNT; ++i)
|
||||
this.data_.push([]);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
HashBuckets.prototype.length = function () {
|
||||
return this.data_.length;
|
||||
};
|
||||
HashBuckets.prototype.capacity = function () {
|
||||
return this.data_.length * this.max_load_factor_;
|
||||
};
|
||||
HashBuckets.prototype.at = function (index) {
|
||||
return this.data_[index];
|
||||
};
|
||||
HashBuckets.prototype.load_factor = function () {
|
||||
return this.size_ / this.length();
|
||||
};
|
||||
HashBuckets.prototype.max_load_factor = function (z) {
|
||||
if (z === void 0) { z = null; }
|
||||
if (z === null)
|
||||
return this.max_load_factor_;
|
||||
else
|
||||
this.max_load_factor_ = z;
|
||||
};
|
||||
HashBuckets.prototype.hash_function = function () {
|
||||
return this.hasher_;
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ELEMENTS I/O
|
||||
--------------------------------------------------------- */
|
||||
HashBuckets.prototype.index = function (elem) {
|
||||
return this.hasher_(this.fetcher_(elem)) % this.length();
|
||||
};
|
||||
HashBuckets.prototype.insert = function (val) {
|
||||
var capacity = this.capacity();
|
||||
if (++this.size_ > capacity)
|
||||
this.reserve(capacity * 2);
|
||||
var index = this.index(val);
|
||||
this.data_[index].push(val);
|
||||
};
|
||||
HashBuckets.prototype.erase = function (val) {
|
||||
var index = this.index(val);
|
||||
var bucket = this.data_[index];
|
||||
for (var i = 0; i < bucket.length; ++i)
|
||||
if (bucket[i] === val) {
|
||||
bucket.splice(i, 1);
|
||||
--this.size_;
|
||||
break;
|
||||
}
|
||||
};
|
||||
return HashBuckets;
|
||||
}());
|
||||
exports.HashBuckets = HashBuckets;
|
||||
var MIN_BUCKET_COUNT = 10;
|
||||
var DEFAULT_MAX_FACTOR = 1.0;
|
||||
//# sourceMappingURL=HashBuckets.js.map
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { HashBuckets } from "./HashBuckets";
|
||||
import { IHashMap } from "../../base/container/IHashMap";
|
||||
import { Comparator } from "../functional/Comparator";
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets for map containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class MapHashBuckets<Key, T, Unique extends boolean, Source extends IHashMap<Key, T, Unique, Source>> extends HashBuckets<Key, IHashMap.Iterator<Key, T, Unique, Source>> {
|
||||
private source_;
|
||||
private readonly key_eq_;
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source map container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
constructor(source: Source, hasher: Hasher<Key>, pred: Comparator<Key>);
|
||||
key_eq(): Comparator<Key>;
|
||||
find(key: Key): IHashMap.Iterator<Key, T, Unique, Source>;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"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;
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MapHashBuckets = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var HashBuckets_1 = require("./HashBuckets");
|
||||
/**
|
||||
* Hash buckets for map containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MapHashBuckets = /** @class */ (function (_super) {
|
||||
__extends(MapHashBuckets, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source map container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
function MapHashBuckets(source, hasher, pred) {
|
||||
var _this = _super.call(this, fetcher, hasher) || this;
|
||||
_this.source_ = source;
|
||||
_this.key_eq_ = pred;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
MapHashBuckets._Swap_source = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
FINDERS
|
||||
--------------------------------------------------------- */
|
||||
MapHashBuckets.prototype.key_eq = function () {
|
||||
return this.key_eq_;
|
||||
};
|
||||
MapHashBuckets.prototype.find = function (key) {
|
||||
var e_1, _a;
|
||||
var index = this.hash_function()(key) % this.length();
|
||||
var bucket = this.at(index);
|
||||
try {
|
||||
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
|
||||
var it = bucket_1_1.value;
|
||||
if (this.key_eq_(it.first, key))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return this.source_.end();
|
||||
};
|
||||
return MapHashBuckets;
|
||||
}(HashBuckets_1.HashBuckets));
|
||||
exports.MapHashBuckets = MapHashBuckets;
|
||||
function fetcher(elem) {
|
||||
return elem.first;
|
||||
}
|
||||
//# sourceMappingURL=MapHashBuckets.js.map
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { HashBuckets } from "./HashBuckets";
|
||||
import { IHashSet } from "../../base/container/IHashSet";
|
||||
import { Comparator } from "../functional/Comparator";
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets for set containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class SetHashBuckets<Key, Unique extends boolean, Source extends IHashSet<Key, Unique, Source>> extends HashBuckets<Key, IHashSet.Iterator<Key, Unique, Source>> {
|
||||
private source_;
|
||||
private readonly key_eq_;
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source set container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
constructor(source: IHashSet<Key, Unique, Source>, hasher: Hasher<Key>, pred: Comparator<Key>);
|
||||
key_eq(): Comparator<Key>;
|
||||
find(val: Key): IHashSet.Iterator<Key, Unique, Source>;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"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;
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SetHashBuckets = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var HashBuckets_1 = require("./HashBuckets");
|
||||
/**
|
||||
* Hash buckets for set containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var SetHashBuckets = /** @class */ (function (_super) {
|
||||
__extends(SetHashBuckets, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source set container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
function SetHashBuckets(source, hasher, pred) {
|
||||
var _this = _super.call(this, fetcher, hasher) || this;
|
||||
_this.source_ = source;
|
||||
_this.key_eq_ = pred;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
SetHashBuckets._Swap_source = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
FINDERS
|
||||
--------------------------------------------------------- */
|
||||
SetHashBuckets.prototype.key_eq = function () {
|
||||
return this.key_eq_;
|
||||
};
|
||||
SetHashBuckets.prototype.find = function (val) {
|
||||
var e_1, _a;
|
||||
var index = this.hash_function()(val) % this.length();
|
||||
var bucket = this.at(index);
|
||||
try {
|
||||
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
|
||||
var it = bucket_1_1.value;
|
||||
if (this.key_eq_(it.value, val))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return this.source_.end();
|
||||
};
|
||||
return SetHashBuckets;
|
||||
}(HashBuckets_1.HashBuckets));
|
||||
exports.SetHashBuckets = SetHashBuckets;
|
||||
function fetcher(elem) {
|
||||
return elem.value;
|
||||
}
|
||||
//# sourceMappingURL=SetHashBuckets.js.map
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IArrayContainer } from "../../base/container/IArrayContainer";
|
||||
import { ArrayIteratorBase } from "./ArrayIteratorBase";
|
||||
import { ArrayContainer } from "../container/linear/ArrayContainer";
|
||||
import { ArrayReverseIterator } from "./ArrayReverseIterator";
|
||||
export declare class ArrayIterator<T, SourceT extends ArrayContainer<T, SourceT, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>, T>> extends ArrayIteratorBase<T, SourceT, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>, T> implements IArrayContainer.Iterator<T, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
reverse(): ArrayReverseIterator<T, SourceT>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
source(): SourceT;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
"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.ArrayIterator = void 0;
|
||||
var ArrayIteratorBase_1 = require("./ArrayIteratorBase");
|
||||
var ArrayReverseIterator_1 = require("./ArrayReverseIterator");
|
||||
var ArrayIterator = /** @class */ (function (_super) {
|
||||
__extends(ArrayIterator, _super);
|
||||
function ArrayIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIterator.prototype.reverse = function () {
|
||||
return new ArrayReverseIterator_1.ArrayReverseIterator(this);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIterator.prototype.source = function () {
|
||||
return this._Get_array();
|
||||
};
|
||||
return ArrayIterator;
|
||||
}(ArrayIteratorBase_1.ArrayIteratorBase));
|
||||
exports.ArrayIterator = ArrayIterator;
|
||||
//# sourceMappingURL=ArrayIterator.js.map
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IContainer } from "../../base/container/IContainer";
|
||||
import { IRandomAccessIterator } from "../../iterator/IRandomAccessIterator";
|
||||
import { ArrayContainer } from "../container/linear/ArrayContainer";
|
||||
import { ArrayReverseIteratorBase } from "./ArrayReverseIteratorBase";
|
||||
/**
|
||||
* Iterator of Array Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ArrayIteratorBase<T extends ElemT, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, ElemT>, ArrayT extends ArrayContainer<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, IteratorT extends ArrayIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ReverseT extends ArrayReverseIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ElemT> implements IContainer.Iterator<T, SourceT, IteratorT, ReverseT, ElemT>, IRandomAccessIterator<T, IteratorT> {
|
||||
private array_;
|
||||
private index_;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source Source container.
|
||||
* @param index Index number.
|
||||
*/
|
||||
constructor(array: ArrayT, index: number);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract reverse(): ReverseT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract source(): SourceT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
index(): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get value(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set value(val: T);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
prev(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
next(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
advance(n: number): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: IteratorT): boolean;
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ArrayIteratorBase = void 0;
|
||||
var comparators_1 = require("../../functional/comparators");
|
||||
/**
|
||||
* Iterator of Array Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ArrayIteratorBase = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param source Source container.
|
||||
* @param index Index number.
|
||||
*/
|
||||
function ArrayIteratorBase(array, index) {
|
||||
this.array_ = array;
|
||||
this.index_ = index;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
ArrayIteratorBase.prototype._Get_array = function () {
|
||||
return this.array_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIteratorBase.prototype.index = function () {
|
||||
return this.index_;
|
||||
};
|
||||
Object.defineProperty(ArrayIteratorBase.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.array_.at(this.index_);
|
||||
},
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.array_.set(this.index_, val);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/* ---------------------------------------------------------
|
||||
MOVERS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIteratorBase.prototype.prev = function () {
|
||||
return this.advance(-1);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIteratorBase.prototype.next = function () {
|
||||
return this.advance(1);
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIteratorBase.prototype.advance = function (n) {
|
||||
return this.array_.nth(this.index_ + n);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
COMPARES
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayIteratorBase.prototype.equals = function (obj) {
|
||||
return (0, comparators_1.equal_to)(this.array_, obj.array_) && this.index_ === obj.index_;
|
||||
};
|
||||
return ArrayIteratorBase;
|
||||
}());
|
||||
exports.ArrayIteratorBase = ArrayIteratorBase;
|
||||
//# sourceMappingURL=ArrayIteratorBase.js.map
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IArrayContainer } from "../../base/container/IArrayContainer";
|
||||
import { ArrayReverseIteratorBase } from "./ArrayReverseIteratorBase";
|
||||
import { ArrayContainer } from "../container/linear/ArrayContainer";
|
||||
import { ArrayIterator } from "./ArrayIterator";
|
||||
export declare class ArrayReverseIterator<T, SourceT extends ArrayContainer<T, SourceT, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>, T>> extends ArrayReverseIteratorBase<T, SourceT, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>, T> implements IArrayContainer.ReverseIterator<T, SourceT, ArrayIterator<T, SourceT>, ArrayReverseIterator<T, SourceT>> {
|
||||
protected _Create_neighbor(base: ArrayIterator<T, SourceT>): ArrayReverseIterator<T, SourceT>;
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"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.ArrayReverseIterator = void 0;
|
||||
var ArrayReverseIteratorBase_1 = require("./ArrayReverseIteratorBase");
|
||||
var ArrayReverseIterator = /** @class */ (function (_super) {
|
||||
__extends(ArrayReverseIterator, _super);
|
||||
function ArrayReverseIterator() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ArrayReverseIterator.prototype._Create_neighbor = function (base) {
|
||||
return new ArrayReverseIterator(base);
|
||||
};
|
||||
return ArrayReverseIterator;
|
||||
}(ArrayReverseIteratorBase_1.ArrayReverseIteratorBase));
|
||||
exports.ArrayReverseIterator = ArrayReverseIterator;
|
||||
//# sourceMappingURL=ArrayReverseIterator.js.map
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IRandomAccessIterator } from "../../iterator/IRandomAccessIterator";
|
||||
import { ReverseIterator } from "./ReverseIterator";
|
||||
import { IContainer } from "../../base/container/IContainer";
|
||||
import { ArrayContainer } from "../container/linear/ArrayContainer";
|
||||
import { ArrayIteratorBase } from "./ArrayIteratorBase";
|
||||
/**
|
||||
* Reverse iterator of Array Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ArrayReverseIteratorBase<T extends ElemT, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, ElemT>, ArrayT extends ArrayContainer<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, IteratorT extends ArrayIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ReverseT extends ArrayReverseIteratorBase<T, SourceT, ArrayT, IteratorT, ReverseT, ElemT>, ElemT> extends ReverseIterator<T, SourceT, IteratorT, ReverseT, ElemT> implements IRandomAccessIterator<T, ReverseT> {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
advance(n: number): ReverseT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
index(): number;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get value(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set value(val: T);
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
"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.ArrayReverseIteratorBase = void 0;
|
||||
var ReverseIterator_1 = require("./ReverseIterator");
|
||||
/**
|
||||
* Reverse iterator of Array Containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ArrayReverseIteratorBase = /** @class */ (function (_super) {
|
||||
__extends(ArrayReverseIteratorBase, _super);
|
||||
function ArrayReverseIteratorBase() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayReverseIteratorBase.prototype.advance = function (n) {
|
||||
return this._Create_neighbor(this.base().advance(-n));
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ArrayReverseIteratorBase.prototype.index = function () {
|
||||
return this.base_.index();
|
||||
};
|
||||
Object.defineProperty(ArrayReverseIteratorBase.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.base_.value;
|
||||
},
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
set: function (val) {
|
||||
this.base_.value = val;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return ArrayReverseIteratorBase;
|
||||
}(ReverseIterator_1.ReverseIterator));
|
||||
exports.ArrayReverseIteratorBase = ArrayReverseIteratorBase;
|
||||
//# sourceMappingURL=ArrayReverseIteratorBase.js.map
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IForwardIterator } from "../../iterator/IForwardIterator";
|
||||
import { Writeonly } from "../functional/Writeonly";
|
||||
export declare abstract class InsertIteratorBase<T, This extends InsertIteratorBase<T, This>> implements Writeonly<IForwardIterator<T, This>> {
|
||||
/**
|
||||
* Set value.
|
||||
*
|
||||
* @param val The value to set.
|
||||
*/
|
||||
abstract set value(val: T);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
next(): This;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract equals(obj: This): boolean;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InsertIteratorBase = void 0;
|
||||
var InsertIteratorBase = /** @class */ (function () {
|
||||
function InsertIteratorBase() {
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
InsertIteratorBase.prototype.next = function () {
|
||||
return this;
|
||||
};
|
||||
return InsertIteratorBase;
|
||||
}());
|
||||
exports.InsertIteratorBase = InsertIteratorBase;
|
||||
//# sourceMappingURL=InsertIteratorBase.js.map
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IContainer } from "../../base/container/IContainer";
|
||||
import { ReverseIterator } from "./ReverseIterator";
|
||||
/**
|
||||
* Basic List Iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ListIterator<T extends Elem, SourceT extends IContainer<T, SourceT, IteratorT, ReverseIteratorT, Elem>, IteratorT extends ListIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, ReverseIteratorT extends ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, Elem> implements Readonly<IContainer.Iterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>> {
|
||||
private prev_;
|
||||
private next_;
|
||||
protected value_: T;
|
||||
protected constructor(prev: IteratorT, next: IteratorT, value: T);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract reverse(): ReverseIteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
abstract source(): SourceT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
prev(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
next(): IteratorT;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get value(): T;
|
||||
protected _Try_value(): void;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: IteratorT): boolean;
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ListIterator = void 0;
|
||||
var ErrorGenerator_1 = require("../exception/ErrorGenerator");
|
||||
/**
|
||||
* Basic List Iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ListIterator = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------------- */
|
||||
function ListIterator(prev, next, value) {
|
||||
this.prev_ = prev;
|
||||
this.next_ = next;
|
||||
this.value_ = value;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
ListIterator._Set_prev = function (it, prev) {
|
||||
it.prev_ = prev;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
ListIterator._Set_next = function (it, next) {
|
||||
it.next_ = next;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListIterator.prototype.prev = function () {
|
||||
return this.prev_;
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListIterator.prototype.next = function () {
|
||||
return this.next_;
|
||||
};
|
||||
Object.defineProperty(ListIterator.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
this._Try_value();
|
||||
return this.value_;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
ListIterator.prototype._Try_value = function () {
|
||||
if (this.value_ === undefined &&
|
||||
this.equals(this.source().end()) === true)
|
||||
throw ErrorGenerator_1.ErrorGenerator.iterator_end_value(this.source());
|
||||
};
|
||||
/* ---------------------------------------------------------------
|
||||
COMPARISON
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ListIterator.prototype.equals = function (obj) {
|
||||
return this === obj;
|
||||
};
|
||||
return ListIterator;
|
||||
}());
|
||||
exports.ListIterator = ListIterator;
|
||||
//# sourceMappingURL=ListIterator.js.map
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.base
|
||||
*/
|
||||
import { IContainer } from "../../base/container/IContainer";
|
||||
/**
|
||||
* Basic reverse iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare abstract class ReverseIterator<T extends PElem, Source extends IContainer<T, Source, Base, This, PElem>, Base extends IContainer.Iterator<T, Source, Base, This, PElem>, This extends ReverseIterator<T, Source, Base, This, PElem>, PElem = T> implements IContainer.ReverseIterator<T, Source, Base, This, PElem> {
|
||||
protected base_: Base;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param base The base iterator.
|
||||
*/
|
||||
constructor(base: Base);
|
||||
protected abstract _Create_neighbor(base: Base): This;
|
||||
/**
|
||||
* Get source container.
|
||||
*
|
||||
* @return The source container.
|
||||
*/
|
||||
source(): Source;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
base(): Base;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get value(): T;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
prev(): This;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
next(): This;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
equals(obj: This): boolean;
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ReverseIterator = void 0;
|
||||
/**
|
||||
* Basic reverse iterator.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ReverseIterator = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param base The base iterator.
|
||||
*/
|
||||
function ReverseIterator(base) {
|
||||
this.base_ = base.prev();
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Get source container.
|
||||
*
|
||||
* @return The source container.
|
||||
*/
|
||||
ReverseIterator.prototype.source = function () {
|
||||
return this.base_.source();
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ReverseIterator.prototype.base = function () {
|
||||
return this.base_.next();
|
||||
};
|
||||
Object.defineProperty(ReverseIterator.prototype, "value", {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
get: function () {
|
||||
return this.base_.value;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/* ---------------------------------------------------------
|
||||
MOVERS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ReverseIterator.prototype.prev = function () {
|
||||
// this.base().next()
|
||||
return this._Create_neighbor(this.base().next());
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ReverseIterator.prototype.next = function () {
|
||||
// this.base().prev()
|
||||
return this._Create_neighbor(this.base_);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
COMPARES
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ReverseIterator.prototype.equals = function (obj) {
|
||||
return this.base_.equals(obj.base_);
|
||||
};
|
||||
return ReverseIterator;
|
||||
}());
|
||||
exports.ReverseIterator = ReverseIterator;
|
||||
//# sourceMappingURL=ReverseIterator.js.map
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
/**
|
||||
* Adaptor for `for ... of` iteration.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class ForOfAdaptor<T, InputIterator extends Readonly<IForwardIterator<T, InputIterator>>> implements IterableIterator<T> {
|
||||
private it_;
|
||||
private last_;
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param first Input iteartor of the first position.
|
||||
* @param last Input iterator of the last position.
|
||||
*/
|
||||
constructor(first: InputIterator, last: InputIterator);
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
next(): IteratorResult<T>;
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
[Symbol.iterator](): IterableIterator<T>;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ForOfAdaptor = void 0;
|
||||
/**
|
||||
* Adaptor for `for ... of` iteration.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var ForOfAdaptor = /** @class */ (function () {
|
||||
/**
|
||||
* Initializer Constructor.
|
||||
*
|
||||
* @param first Input iteartor of the first position.
|
||||
* @param last Input iterator of the last position.
|
||||
*/
|
||||
function ForOfAdaptor(first, last) {
|
||||
this.it_ = first;
|
||||
this.last_ = last;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ForOfAdaptor.prototype.next = function () {
|
||||
if (this.it_.equals(this.last_))
|
||||
return {
|
||||
done: true,
|
||||
value: undefined,
|
||||
};
|
||||
else {
|
||||
var it = this.it_;
|
||||
this.it_ = this.it_.next();
|
||||
return {
|
||||
done: false,
|
||||
value: it.value,
|
||||
};
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ForOfAdaptor.prototype[Symbol.iterator] = function () {
|
||||
return this;
|
||||
};
|
||||
return ForOfAdaptor;
|
||||
}());
|
||||
exports.ForOfAdaptor = ForOfAdaptor;
|
||||
//# sourceMappingURL=ForOfAdaptor.js.map
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
export declare class NativeArrayIterator<T> implements Readonly<IForwardIterator<T, NativeArrayIterator<T>>> {
|
||||
private data_;
|
||||
private index_;
|
||||
constructor(data: Array<T>, index: number);
|
||||
index(): number;
|
||||
get value(): T;
|
||||
prev(): NativeArrayIterator<T>;
|
||||
next(): NativeArrayIterator<T>;
|
||||
advance(n: number): NativeArrayIterator<T>;
|
||||
equals(obj: NativeArrayIterator<T>): boolean;
|
||||
swap(obj: NativeArrayIterator<T>): void;
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
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.NativeArrayIterator = void 0;
|
||||
var NativeArrayIterator = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function NativeArrayIterator(data, index) {
|
||||
this.data_ = data;
|
||||
this.index_ = index;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
NativeArrayIterator.prototype.index = function () {
|
||||
return this.index_;
|
||||
};
|
||||
Object.defineProperty(NativeArrayIterator.prototype, "value", {
|
||||
get: function () {
|
||||
return this.data_[this.index_];
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/* ---------------------------------------------------------
|
||||
MOVERS
|
||||
--------------------------------------------------------- */
|
||||
NativeArrayIterator.prototype.prev = function () {
|
||||
--this.index_;
|
||||
return this;
|
||||
};
|
||||
NativeArrayIterator.prototype.next = function () {
|
||||
++this.index_;
|
||||
return this;
|
||||
};
|
||||
NativeArrayIterator.prototype.advance = function (n) {
|
||||
this.index_ += n;
|
||||
return this;
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
COMPARES
|
||||
--------------------------------------------------------- */
|
||||
NativeArrayIterator.prototype.equals = function (obj) {
|
||||
return this.data_ === obj.data_ && this.index_ === obj.index_;
|
||||
};
|
||||
NativeArrayIterator.prototype.swap = function (obj) {
|
||||
var _a, _b;
|
||||
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
|
||||
_b = __read([obj.index_, this.index_], 2), this.index_ = _b[0], obj.index_ = _b[1];
|
||||
};
|
||||
return NativeArrayIterator;
|
||||
}());
|
||||
exports.NativeArrayIterator = NativeArrayIterator;
|
||||
//# sourceMappingURL=NativeArrayIterator.js.map
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { IForwardIterator } from "../../../iterator/IForwardIterator";
|
||||
export declare class Repeater<T> implements Readonly<IForwardIterator<T, Repeater<T>>> {
|
||||
private index_;
|
||||
private value_;
|
||||
constructor(index: number, value?: T);
|
||||
index(): number;
|
||||
get value(): T;
|
||||
next(): Repeater<T>;
|
||||
equals(obj: Repeater<T>): boolean;
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Repeater = void 0;
|
||||
var Repeater = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function Repeater(index, value) {
|
||||
this.index_ = index;
|
||||
this.value_ = value;
|
||||
}
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
Repeater.prototype.index = function () {
|
||||
return this.index_;
|
||||
};
|
||||
Object.defineProperty(Repeater.prototype, "value", {
|
||||
get: function () {
|
||||
return this.value_;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
/* ---------------------------------------------------------
|
||||
MOVERS & COMPARE
|
||||
--------------------------------------------------------- */
|
||||
Repeater.prototype.next = function () {
|
||||
++this.index_;
|
||||
return this;
|
||||
};
|
||||
Repeater.prototype.equals = function (obj) {
|
||||
return this.index_ === obj.index_;
|
||||
};
|
||||
return Repeater;
|
||||
}());
|
||||
exports.Repeater = Repeater;
|
||||
//# sourceMappingURL=Repeater.js.map
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export declare namespace Carlson {
|
||||
function rf(x: number, y: number, z: number): number;
|
||||
function rj(x: number, y: number, z: number, p: number): number;
|
||||
function rc(x: number, y: number): number;
|
||||
function rd(x: number, y: number, z: number): number;
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Carlson = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var MathUtil_1 = require("./MathUtil");
|
||||
var Carlson;
|
||||
(function (Carlson) {
|
||||
var INFINITY = 100 * 1000;
|
||||
var SECTION = INFINITY;
|
||||
function rf(x, y, z) {
|
||||
return (MathUtil_1.MathUtil.integral(function (t) {
|
||||
var ret = t + x;
|
||||
ret *= t + y;
|
||||
ret *= t + z;
|
||||
return 1 / Math.sqrt(ret);
|
||||
}, 0, INFINITY, SECTION) / 2);
|
||||
}
|
||||
Carlson.rf = rf;
|
||||
function rj(x, y, z, p) {
|
||||
return (MathUtil_1.MathUtil.integral(function (t) {
|
||||
var ret = t + x;
|
||||
ret *= t + y;
|
||||
ret *= t + z;
|
||||
ret = (t + p) * Math.sqrt(ret);
|
||||
return 1 / ret;
|
||||
}, 0, INFINITY, SECTION) * 1.5);
|
||||
}
|
||||
Carlson.rj = rj;
|
||||
function rc(x, y) {
|
||||
return rf(x, y, y);
|
||||
}
|
||||
Carlson.rc = rc;
|
||||
function rd(x, y, z) {
|
||||
return rj(x, y, z, z);
|
||||
}
|
||||
Carlson.rd = rd;
|
||||
})(Carlson = exports.Carlson || (exports.Carlson = {}));
|
||||
//# sourceMappingURL=Carlson.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user