include node_modules so release .zip is deployable

This commit is contained in:
2023-11-24 17:44:25 -05:00
parent 6c86cfe5d2
commit 8b11c41267
8963 changed files with 874175 additions and 1 deletions
@@ -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 {
}
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ILinearContainerBase.js.map
+50
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IListAlgorithm.js.map
+100
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -0,0 +1,10 @@
/**
* @packageDocumentation
* @module std.internal
*/
export interface IClear {
/**
* Clear elements.
*/
clear(): void;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IClear.js.map
+11
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IDeque.js.map
+10
View File
@@ -0,0 +1,10 @@
/**
* @packageDocumentation
* @module std.internal
*/
export interface IEmpty {
/**
* Test whether container is empty.
*/
empty(): boolean;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IEmpty.js.map
+18
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IFront.js.map
+9
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IInsert.js.map
+13
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IPush.js.map
+16
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IPushBack.js.map
+12
View File
@@ -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
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IPushFront.js.map
+10
View File
@@ -0,0 +1,10 @@
/**
* @packageDocumentation
* @module std.internal
*/
export interface ISize {
/**
* Number of elements in the container.
*/
size(): number;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ISize.js.map