working rss feed to nostr publish

This commit is contained in:
2023-11-24 00:43:28 -05:00
parent 06edcb57ae
commit 88d2f9cfec
8396 changed files with 783105 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IContainer } from "./IContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
/**
* Basic container.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link Container}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class Container<T extends PElem, SourceT extends Container<T, SourceT, IteratorT, ReverseT, PElem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseT, PElem>, ReverseT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, PElem>, PElem = T> implements IContainer<T, SourceT, IteratorT, ReverseT, PElem> {
/**
* @inheritDoc
*/
abstract assign<InputIterator extends Readonly<IForwardIterator<PElem, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
abstract clear(): void;
/**
* @inheritDoc
*/
abstract size(): number;
/**
* @inheritDoc
*/
empty(): boolean;
/**
* @inheritDoc
*/
abstract begin(): IteratorT;
/**
* @inheritDoc
*/
abstract end(): IteratorT;
/**
* @inheritDoc
*/
rbegin(): ReverseT;
/**
* @inheritDoc
*/
rend(): ReverseT;
/**
* @inheritDoc
*/
[Symbol.iterator](): IterableIterator<T>;
/**
* @inheritDoc
*/
abstract push(...items: PElem[]): number;
/**
* @inheritDoc
*/
abstract erase(pos: IteratorT): IteratorT;
/**
* @inheritDoc
*/
abstract erase(first: IteratorT, last: IteratorT): IteratorT;
/**
* @inheritDoc
*/
abstract swap(obj: SourceT): void;
/**
* @inheritDoc
*/
toJSON(): Array<T>;
}
+78
View File
@@ -0,0 +1,78 @@
"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
var ForOfAdaptor_1 = require("../../internal/iterator/disposable/ForOfAdaptor");
/**
* Basic container.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link Container}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Container = /** @class */ (function () {
function Container() {
}
/**
* @inheritDoc
*/
Container.prototype.empty = function () {
return this.size() === 0;
};
/**
* @inheritDoc
*/
Container.prototype.rbegin = function () {
return this.end().reverse();
};
/**
* @inheritDoc
*/
Container.prototype.rend = function () {
return this.begin().reverse();
};
/**
* @inheritDoc
*/
Container.prototype[Symbol.iterator] = function () {
return new ForOfAdaptor_1.ForOfAdaptor(this.begin(), this.end());
};
/**
* @inheritDoc
*/
Container.prototype.toJSON = function () {
var e_1, _a;
var ret = [];
try {
for (var _b = __values(this), _c = _b.next(); !_c.done; _c = _b.next()) {
var elem = _c.value;
ret.push(elem);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return ret;
};
return Container;
}());
exports.Container = Container;
//# sourceMappingURL=Container.js.map
+54
View File
@@ -0,0 +1,54 @@
/**
* @packageDocumentation
* @module std.base
*/
import { ILinearContainer } from "./ILinearContainer";
import { IRandomAccessIterator } from "../../iterator/IRandomAccessIterator";
/**
* Common interface for array containers.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link IArrayContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IArrayContainer<T extends PElem, SourceT extends IArrayContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IArrayContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IArrayContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, PElem = T> extends ILinearContainer<T, SourceT, IteratorT, ReverseT, PElem> {
/**
* Get iterator at specific position.
*
* @param index Specific position.
* @return The iterator at the *index*.
*/
nth(index: number): IteratorT;
/**
* Get element at specific position.
*
* @param index Specific position.
* @return The element at the *index*.
*/
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;
}
export declare namespace IArrayContainer {
/**
* Iterator of {@link IArrayContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<T extends ElemT, SourceT extends IArrayContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IArrayContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IArrayContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = ILinearContainer.Iterator<T, SourceT, IteratorT, ReverseT, ElemT> & IRandomAccessIterator<T, IteratorT>;
/**
* Reverse iterator of {@link IArrayContainer}
*
* @author Jeongho Nam - https://github.com/samchon
*/
type ReverseIterator<T extends ElemT, SourceT extends IArrayContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IArrayContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IArrayContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = ILinearContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, ElemT> & IRandomAccessIterator<T, ReverseT>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IArrayContainer.js.map
+123
View File
@@ -0,0 +1,123 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IBidirectionalContainer } from "../../ranges/container/IBidirectionalContainer";
import { IEmpty } from "../../internal/container/partial/IEmpty";
import { ISize } from "../../internal/container/partial/ISize";
import { IPush } from "../../internal/container/partial/IPush";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IReverseIterator } from "../../iterator/IReverseIterator";
import { IReversableIterator } from "../../iterator/IReversableIterator";
/**
* Common interface for containers.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link IContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IContainer<T extends PElem, SourceT extends IContainer<T, SourceT, IteratorT, ReverseT, PElem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseT, PElem>, ReverseT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, PElem>, PElem = T> extends IBidirectionalContainer<IContainer.Iterator<T, SourceT, IteratorT, ReverseT, PElem>, ReverseT>, Iterable<T>, IEmpty, ISize, IPush<PElem> {
/**
* Range Assigner.
*
* @param first Input iteartor of the first position.
* @param last Input iterator of the last position.
*/
assign<InputIterator extends Readonly<IForwardIterator<PElem, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
size(): number;
/**
* @inheritDoc
*/
empty(): boolean;
/**
* @inheritDoc
*/
begin(): IteratorT;
/**
* @inheritDoc
*/
end(): IteratorT;
/**
* @inheritDoc
*/
rbegin(): ReverseT;
/**
* @inheritDoc
*/
rend(): ReverseT;
/**
* @inheritDoc
*/
[Symbol.iterator](): IterableIterator<T>;
push(...items: PElem[]): number;
/**
* Erase an element.
*
* @param pos Position to erase.
* @return Iterator following the *pos*, strained by the erasing.
*/
erase(pos: IteratorT): IteratorT;
/**
* Erase elements in range.
*
* @param first Range of the first position to erase.
* @param last Rangee of the last position to erase.
* @return Iterator following the last removed element, strained by the erasing.
*/
erase(first: IteratorT, last: IteratorT): IteratorT;
/**
* Swap elements.
*
* @param obj Target container to swap.
*/
swap(obj: SourceT): void;
/**
* Native function for `JSON.stringify()`.
*
* @return An array containing children elements.
*/
toJSON(): Array<T>;
}
export declare namespace IContainer {
/**
* Iterator of {@link IContainer}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
interface Iterator<T extends Elem, SourceT extends IContainer<T, SourceT, IteratorT, ReverseIteratorT, Elem>, IteratorT extends Iterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, ReverseIteratorT extends ReverseIterator<T, SourceT, IteratorT, ReverseIteratorT, Elem>, Elem = T> extends Readonly<IReversableIterator<T, IteratorT, ReverseIteratorT>> {
/**
* Get source container.
*
* @return The source container.
*/
source(): SourceT;
/**
* @inheritDoc
*/
reverse(): ReverseIteratorT;
}
/**
* Reverse iterator of {@link IContainer}
*
* @author Jeongho Nam - https://github.com/samchon
*/
interface ReverseIterator<T extends Elem, Source extends IContainer<T, Source, IteratorT, ReverseT, Elem>, IteratorT extends Iterator<T, Source, IteratorT, ReverseT, Elem>, ReverseT extends ReverseIterator<T, Source, IteratorT, ReverseT, Elem>, Elem = T> extends Readonly<IReverseIterator<T, IteratorT, ReverseT>> {
/**
* Get source container.
*
* @return The source container.
*/
source(): Source;
}
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IContainer.js.map
+34
View File
@@ -0,0 +1,34 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IContainer } from "./IContainer";
import { IDeque } from "../../internal/container/partial/IDeque";
import { ILinearContainer } from "./ILinearContainer";
/**
* Common interface for deque containers.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link IDequeContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IDequeContainer<T extends PElem, SourceT extends IDequeContainer<T, SourceT, IteratorT, ReverseT, PElem>, IteratorT extends IContainer.Iterator<T, SourceT, IteratorT, ReverseT, PElem>, ReverseT extends IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, PElem>, PElem = T> extends IDeque<T>, ILinearContainer<T, SourceT, IteratorT, ReverseT, PElem> {
}
export declare namespace IDequeContainer {
/**
* Iterator of {@link IDequeContainer}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
type Iterator<T extends ElemT, SourceT extends IDequeContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IDequeContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IDequeContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = ILinearContainer.Iterator<T, SourceT, IteratorT, ReverseT, ElemT>;
/**
* Reverse iterator of {@link IDequeContainer}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
type ReverseIterator<T extends ElemT, SourceT extends IDequeContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends IDequeContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends IDequeContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = ILinearContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, ElemT>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IDequeContainer.js.map
+57
View File
@@ -0,0 +1,57 @@
/**
* @packageDocumentation
* @module std.base
*/
import { MapContainer } from "./MapContainer";
import { IHashContainer } from "../../internal/container/associative/IHashContainer";
import { IPair } from "../../utility/IPair";
import { Entry } from "../../utility/Entry";
import { MapElementList } from "../../internal/container/associative/MapElementList";
/**
* Common interface for hash maps.
*
* @template Key Key type
* @template T Mapped type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link IHashMap}
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IHashMap<Key, T, Unique extends boolean, Source extends IHashMap<Key, T, Unique, Source>> extends MapContainer<Key, T, Unique, Source, IHashMap.Iterator<Key, T, Unique, Source>, IHashMap.ReverseIterator<Key, T, Unique, Source>>, IHashContainer<Key, Entry<Key, T>, Source, IHashMap.Iterator<Key, T, Unique, Source>, IHashMap.ReverseIterator<Key, T, Unique, Source>, IPair<Key, T>> {
/**
* @inheritDoc
*/
begin(): IHashMap.Iterator<Key, T, Unique, Source>;
/**
* Iterator to the first element in a specific bucket.
*
* @param index Index number of the specific bucket.
* @return Iterator from the specific bucket.
*/
begin(index: number): IHashMap.Iterator<Key, T, Unique, Source>;
/**
* @inheritDoc
*/
end(): IHashMap.Iterator<Key, T, Unique, Source>;
/**
* Iterator to the end in a specific bucket.
*
* @param index Index number of the specific bucket.
* @return Iterator from the specific bucket.
*/
end(index: number): IHashMap.Iterator<Key, T, Unique, Source>;
}
export declare namespace IHashMap {
/**
* Iterator of {@link IHashMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, T, Unique extends boolean, Source extends IHashMap<Key, T, Unique, Source>> = MapElementList.Iterator<Key, T, Unique, Source>;
/**
* Reverse iterator of {@link IHashMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, T, Unique extends boolean, Source extends IHashMap<Key, T, Unique, Source>> = MapElementList.ReverseIterator<Key, T, Unique, Source>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IHashMap.js.map
+54
View File
@@ -0,0 +1,54 @@
/**
* @packageDocumentation
* @module std.base
*/
import { SetContainer } from "./SetContainer";
import { IHashContainer } from "../../internal/container/associative/IHashContainer";
import { SetElementList } from "../../internal/container/associative/SetElementList";
/**
* Common interface for hash sets.
*
* @template Key Key type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link IHashSet}
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface IHashSet<Key, Unique extends boolean, Source extends IHashSet<Key, Unique, Source>> extends SetContainer<Key, Unique, Source, IHashSet.Iterator<Key, Unique, Source>, IHashSet.ReverseIterator<Key, Unique, Source>>, IHashContainer<Key, Key, Source, IHashSet.Iterator<Key, Unique, Source>, IHashSet.ReverseIterator<Key, Unique, Source>, Key> {
/**
* @inheritDoc
*/
begin(): IHashSet.Iterator<Key, Unique, Source>;
/**
* Iterator to the first element in a specific bucket.
*
* @param index Index number of the specific bucket.
* @return Iterator from the specific bucket.
*/
begin(index: number): IHashSet.Iterator<Key, Unique, Source>;
/**
* @inheritDoc
*/
end(): IHashSet.Iterator<Key, Unique, Source>;
/**
* Iterator to the end in a specific bucket.
*
* @param index Index number of the specific bucket.
* @return Iterator from the specific bucket.
*/
end(index: number): IHashSet.Iterator<Key, Unique, Source>;
}
export declare namespace IHashSet {
/**
* Iterator of {@link IHashSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, Unique extends boolean, Source extends IHashSet<Key, Unique, Source>> = SetElementList.Iterator<Key, Unique, Source>;
/**
* Reverse iterator of {@link IHashSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, Unique extends boolean, Source extends IHashSet<Key, Unique, Source>> = SetElementList.ReverseIterator<Key, Unique, Source>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=IHashSet.js.map
+102
View File
@@ -0,0 +1,102 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IContainer } from "./IContainer";
import { ILinearContainerBase } from "../../internal/container/linear/ILinearContainerBase";
import { IFront } from "../../internal/container/partial/IFront";
import { IPushBack } from "../../internal/container/partial/IPushBack";
import { IForwardIterator } from "../../iterator/IForwardIterator";
/**
* Common interface for linear containers.
*
* @template T Stored elements' type
* @template SourceT Derived type extending this {@link ILinearContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
* @template PElem Parent type of *T*, used for inserting elements through {@link assign} and {@link insert}.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface ILinearContainer<T extends PElem, SourceT extends ILinearContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends ILinearContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends ILinearContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, PElem = T> extends ILinearContainerBase<T, SourceT, IteratorT, ReverseT, PElem>, IFront<T>, 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;
/**
* Get the last element.
*
* @return The last element.
*/
back(): T;
/**
* Change the last element.
*
* @param val The value to change.
*/
back(val: T): 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;
}
export declare namespace ILinearContainer {
/**
* Iterator of {@link ILinearContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<T extends ElemT, SourceT extends ILinearContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends ILinearContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends ILinearContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = IContainer.Iterator<T, SourceT, IteratorT, ReverseT, ElemT>;
/**
* Reverse iterator of {@link ILinearContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<T extends ElemT, SourceT extends ILinearContainer<T, SourceT, IteratorT, ReverseT, T>, IteratorT extends ILinearContainer.Iterator<T, SourceT, IteratorT, ReverseT, T>, ReverseT extends ILinearContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, T>, ElemT = T> = IContainer.ReverseIterator<T, SourceT, IteratorT, ReverseT, ElemT>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ILinearContainer.js.map
+36
View File
@@ -0,0 +1,36 @@
/**
* @packageDocumentation
* @module std.base
*/
import { MapContainer } from "./MapContainer";
import { ITreeContainer } from "../../internal/container/associative/ITreeContainer";
import { IPair } from "../../utility/IPair";
import { Entry } from "../../utility/Entry";
/**
* Common interface for tree maps.
*
* @template Key Key type
* @template T Mapped type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link ITreeMap}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface ITreeMap<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, IteratorT, ReverseT>, IteratorT extends ITreeMap.Iterator<Key, T, Unique, Source, IteratorT, ReverseT>, ReverseT extends ITreeMap.ReverseIterator<Key, T, Unique, Source, IteratorT, ReverseT>> extends MapContainer<Key, T, Unique, Source, IteratorT, ReverseT>, ITreeContainer<Key, Entry<Key, T>, Source, IteratorT, ReverseT, IPair<Key, T>> {
}
export declare namespace ITreeMap {
/**
* Iterator of {@link ITreeMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, Unique, Source, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, Unique, Source, IteratorT, ReverseT>> = MapContainer.Iterator<Key, T, Unique, Source, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link ITreeMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, T, Unique extends boolean, Source extends ITreeMap<Key, T, Unique, Source, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, Unique, Source, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, Unique, Source, IteratorT, ReverseT>> = MapContainer.ReverseIterator<Key, T, Unique, Source, IteratorT, ReverseT>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ITreeMap.js.map
+33
View File
@@ -0,0 +1,33 @@
/**
* @packageDocumentation
* @module std.base
*/
import { SetContainer } from "./SetContainer";
import { ITreeContainer } from "../../internal/container/associative/ITreeContainer";
/**
* Common interface for tree sets.
*
* @template Key Key type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link ITreeSet}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export interface ITreeSet<Key, Unique extends boolean, Source extends ITreeSet<Key, Unique, Source, IteratorT, ReverseT>, IteratorT extends ITreeSet.Iterator<Key, Unique, Source, IteratorT, ReverseT>, ReverseT extends ITreeSet.ReverseIterator<Key, Unique, Source, IteratorT, ReverseT>> extends SetContainer<Key, Unique, Source, IteratorT, ReverseT>, ITreeContainer<Key, Key, Source, IteratorT, ReverseT, Key> {
}
export declare namespace ITreeSet {
/**
* Iterator of {@link ITreeSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, Unique extends boolean, SourceT extends ITreeSet<Key, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>> = SetContainer.Iterator<Key, Unique, SourceT, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link ITreeSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, Unique extends boolean, SourceT extends ITreeSet<Key, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>> = SetContainer.ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=ITreeSet.js.map
+131
View File
@@ -0,0 +1,131 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IAssociativeContainer } from "../../internal/container/associative/IAssociativeContainer";
import { IContainer } from "./IContainer";
import { Container } from "./Container";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { ILinearContainerBase } from "../../internal/container/linear/ILinearContainerBase";
import { IPair } from "../../utility/IPair";
import { Entry } from "../../utility/Entry";
import { Pair } from "../../utility/Pair";
/**
* Basic map container.
*
* @template Key Key type
* @template T Mapped type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link MapContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class MapContainer<Key, T, Unique extends boolean, Source extends MapContainer<Key, T, Unique, Source, IteratorT, ReverseT>, IteratorT extends MapContainer.Iterator<Key, T, Unique, Source, IteratorT, ReverseT>, ReverseT extends MapContainer.ReverseIterator<Key, T, Unique, Source, IteratorT, ReverseT>> extends Container<Entry<Key, T>, Source, IteratorT, ReverseT, IPair<Key, T>> implements IAssociativeContainer<Key, Entry<Key, T>, Source, IteratorT, ReverseT, IPair<Key, T>> {
protected data_: ILinearContainerBase<Entry<Key, T>, Source, IteratorT, ReverseT>;
/**
* Default Constructor.
*/
protected constructor(factory: (thisArg: Source) => ILinearContainerBase<Entry<Key, T>, Source, IteratorT, ReverseT>);
/**
* @inheritDoc
*/
assign<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
abstract find(key: Key): IteratorT;
/**
* @inheritDoc
*/
begin(): IteratorT;
/**
* @inheritDoc
*/
end(): IteratorT;
/**
* @inheritDoc
*/
has(key: Key): boolean;
/**
* @inheritDoc
*/
abstract count(key: Key): number;
/**
* @inheritDoc
*/
size(): number;
/**
* @inheritDoc
*/
push(...items: IPair<Key, T>[]): number;
abstract emplace(key: Key, val: T): MapContainer.InsertRet<Key, T, Unique, Source, IteratorT, ReverseT>;
abstract emplace_hint(hint: IteratorT, key: Key, val: T): IteratorT;
insert(pair: IPair<Key, T>): MapContainer.InsertRet<Key, T, Unique, Source, IteratorT, ReverseT>;
insert(hint: IteratorT, pair: IPair<Key, T>): IteratorT;
insert<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected abstract _Insert_by_range<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
erase(key: Key): number;
/**
* @inheritDoc
*/
erase(it: IteratorT): IteratorT;
/**
* @inheritDoc
*/
erase(begin: IteratorT, end: IteratorT): IteratorT;
protected abstract _Erase_by_key(key: Key): number;
protected _Erase_by_range(first: IteratorT, last?: IteratorT): IteratorT;
/**
* @inheritDoc
*/
abstract swap(obj: Source): void;
/**
* Merge two containers.
*
* @param source Source container to transfer.
*/
abstract merge(source: Source): void;
protected abstract _Handle_insert(first: IteratorT, last: IteratorT): void;
protected abstract _Handle_erase(first: IteratorT, last: IteratorT): void;
}
/**
*
*/
export declare namespace MapContainer {
/**
* Return type of {@link MapContainer.insert}
*/
export type InsertRet<Key, T, Unique extends boolean, SourceT extends MapContainer<Key, T, Unique, SourceT, IteratorT, Reverse>, IteratorT extends Iterator<Key, T, Unique, SourceT, IteratorT, Reverse>, Reverse extends ReverseIterator<Key, T, Unique, SourceT, IteratorT, Reverse>> = Unique extends true ? Pair<IteratorT, boolean> : IteratorT;
/**
* Iterator of {@link MapContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
export type Iterator<Key, T, Unique extends boolean, SourceT extends MapContainer<Key, T, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, Unique, SourceT, IteratorT, ReverseT>> = IteratorBase<Key, T> & Readonly<IContainer.Iterator<Entry<Key, T>, SourceT, IteratorT, ReverseT, IPair<Key, T>>>;
/**
* Reverse iterator of {@link MapContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
export type ReverseIterator<Key, T, Unique extends boolean, SourceT extends MapContainer<Key, T, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, Unique, SourceT, IteratorT, ReverseT>> = IteratorBase<Key, T> & Readonly<IContainer.ReverseIterator<Entry<Key, T>, SourceT, IteratorT, ReverseT, IPair<Key, T>>>;
interface IteratorBase<Key, T> {
/**
* The first, key element.
*/
readonly first: Key;
/**
* The second, stored element.
*/
second: T;
}
export {};
}
+150
View File
@@ -0,0 +1,150 @@
"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.MapContainer = void 0;
var Container_1 = require("./Container");
var NativeArrayIterator_1 = require("../../internal/iterator/disposable/NativeArrayIterator");
/**
* Basic map container.
*
* @template Key Key type
* @template T Mapped type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link MapContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var MapContainer = /** @class */ (function (_super) {
__extends(MapContainer, _super);
/* ---------------------------------------------------------
CONSTURCTORS
--------------------------------------------------------- */
/**
* Default Constructor.
*/
function MapContainer(factory) {
var _this = _super.call(this) || this;
_this.data_ = factory(_this);
return _this;
}
/**
* @inheritDoc
*/
MapContainer.prototype.assign = function (first, last) {
// INSERT
this.clear();
this.insert(first, last);
};
/**
* @inheritDoc
*/
MapContainer.prototype.clear = function () {
// TO BE ABSTRACT
this.data_.clear();
};
/**
* @inheritDoc
*/
MapContainer.prototype.begin = function () {
return this.data_.begin();
};
/**
* @inheritDoc
*/
MapContainer.prototype.end = function () {
return this.data_.end();
};
/* ---------------------------------------------------------
ELEMENTS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
MapContainer.prototype.has = function (key) {
return !this.find(key).equals(this.end());
};
/**
* @inheritDoc
*/
MapContainer.prototype.size = function () {
return this.data_.size();
};
/* =========================================================
ELEMENTS I/O
- INSERT
- ERASE
- UTILITY
- POST-PROCESS
============================================================
INSERT
--------------------------------------------------------- */
/**
* @inheritDoc
*/
MapContainer.prototype.push = function () {
var items = [];
for (var _i = 0; _i < arguments.length; _i++) {
items[_i] = arguments[_i];
}
// INSERT BY RANGE
var first = new NativeArrayIterator_1.NativeArrayIterator(items, 0);
var last = new NativeArrayIterator_1.NativeArrayIterator(items, items.length);
this.insert(first, last);
// RETURN SIZE
return this.size();
};
MapContainer.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 1)
return this.emplace(args[0].first, args[0].second);
else if (args[0].next instanceof Function &&
args[1].next instanceof Function)
return this._Insert_by_range(args[0], args[1]);
else
return this.emplace_hint(args[0], args[1].first, args[1].second);
};
MapContainer.prototype.erase = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 1 &&
(args[0] instanceof this.end().constructor === false ||
args[0].source() !== this))
return this._Erase_by_key(args[0]);
else if (args.length === 1)
return this._Erase_by_range(args[0]);
else
return this._Erase_by_range(args[0], args[1]);
};
MapContainer.prototype._Erase_by_range = function (first, last) {
if (last === void 0) { last = first.next(); }
// ERASE
var it = this.data_.erase(first, last);
// POST-PROCESS
this._Handle_erase(first, last);
return it;
};
return MapContainer;
}(Container_1.Container));
exports.MapContainer = MapContainer;
//# sourceMappingURL=MapContainer.js.map
+82
View File
@@ -0,0 +1,82 @@
/**
* @packageDocumentation
* @module std.base
*/
import { MapContainer } from "./MapContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPair } from "../../utility/IPair";
/**
* Basic map container allowing duplicated keys.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link MultiMap}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class MultiMap<Key, T, Source extends MultiMap<Key, T, Source, Iterator, Reverse>, Iterator extends MultiMap.Iterator<Key, T, Source, Iterator, Reverse>, Reverse extends MultiMap.ReverseIterator<Key, T, Source, Iterator, Reverse>> extends MapContainer<Key, T, false, Source, Iterator, Reverse> {
/**
* Construct and insert an element.
*
* @param key Key to be mapped.
* @param value Value to emplace.
* @return An iterator to the newly inserted element.
*/
abstract emplace(key: Key, value: T): Iterator;
/**
* Construct and insert element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param key Key of the new element.
* @param val Value of the new element.
* @return An iterator to the newly inserted element.
*/
abstract emplace_hint(hint: Iterator, key: Key, val: T): Iterator;
/**
* Insert an element.
*
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element.
*/
insert(pair: IPair<Key, T>): Iterator;
/**
* Insert an element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element.
*/
insert(hint: Iterator, pair: IPair<Key, T>): Iterator;
/**
* Insert range elements.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
insert<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected abstract _Key_eq(x: Key, y: Key): boolean;
protected _Erase_by_key(key: Key): number;
/**
* @inheritDoc
*/
merge(source: Source): void;
}
/**
*
*/
export declare namespace MultiMap {
/**
* Iterator of {@link MultiMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, T, SourceT extends MultiMap<Key, T, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, SourceT, IteratorT, ReverseT>> = MapContainer.Iterator<Key, T, false, SourceT, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link MultiMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, T, SourceT extends MultiMap<Key, T, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, SourceT, IteratorT, ReverseT>> = MapContainer.ReverseIterator<Key, T, false, SourceT, IteratorT, ReverseT>;
}
+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 __());
};
})();
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.MultiMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.base
*/
//================================================================
var MapContainer_1 = require("./MapContainer");
/**
* Basic map container allowing duplicated keys.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link MultiMap}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var MultiMap = /** @class */ (function (_super) {
__extends(MultiMap, _super);
function MultiMap() {
return _super !== null && _super.apply(this, arguments) || this;
}
MultiMap.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return _super.prototype.insert.apply(this, __spreadArray([], __read(args), false));
};
MultiMap.prototype._Erase_by_key = function (key) {
var first = this.find(key);
if (first.equals(this.end()) === true)
return 0;
var last = first.next();
var ret = 1;
while (!last.equals(this.end()) && this._Key_eq(key, last.first)) {
last = last.next();
++ret;
}
this._Erase_by_range(first, last);
return ret;
};
/* ---------------------------------------------------------
UTILITY
--------------------------------------------------------- */
/**
* @inheritDoc
*/
MultiMap.prototype.merge = function (source) {
this.insert(source.begin(), source.end());
source.clear();
};
return MultiMap;
}(MapContainer_1.MapContainer));
exports.MultiMap = MultiMap;
//# sourceMappingURL=MultiMap.js.map
+64
View File
@@ -0,0 +1,64 @@
/**
* @packageDocumentation
* @module std.base
*/
import { SetContainer } from "./SetContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
/**
* Basic set container allowing multiple keys.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link MultiSet}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class MultiSet<Key, Source extends MultiSet<Key, Source, IteratorT, ReverseT>, IteratorT extends MultiSet.Iterator<Key, Source, IteratorT, ReverseT>, ReverseT extends MultiSet.ReverseIterator<Key, Source, IteratorT, ReverseT>> extends SetContainer<Key, false, Source, IteratorT, ReverseT> {
/**
* Insert an element.
*
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element.
*/
insert(key: Key): IteratorT;
/**
* Insert an element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element.
*/
insert(hint: IteratorT, key: Key): IteratorT;
/**
* Insert range elements.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
insert<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(begin: InputIterator, end: InputIterator): void;
protected abstract _Key_eq(x: Key, y: Key): boolean;
protected _Erase_by_val(key: Key): number;
/**
* @inheritDoc
*/
merge(source: Source): void;
}
/**
*
*/
export declare namespace MultiSet {
/**
* Iterator of {@link MultiSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, SourceT extends MultiSet<Key, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, SourceT, IteratorT, ReverseT>> = SetContainer.Iterator<Key, false, SourceT, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link MultiSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, SourceT extends MultiSet<Key, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, SourceT, IteratorT, ReverseT>> = SetContainer.ReverseIterator<Key, false, SourceT, IteratorT, ReverseT>;
}
+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 __());
};
})();
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.MultiSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.base
*/
//================================================================
var SetContainer_1 = require("./SetContainer");
/**
* Basic set container allowing multiple keys.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link MultiSet}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var MultiSet = /** @class */ (function (_super) {
__extends(MultiSet, _super);
function MultiSet() {
return _super !== null && _super.apply(this, arguments) || this;
}
MultiSet.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return _super.prototype.insert.apply(this, __spreadArray([], __read(args), false));
};
MultiSet.prototype._Erase_by_val = function (key) {
var first = this.find(key);
if (first.equals(this.end()) === true)
return 0;
var last = first.next();
var ret = 1;
while (!last.equals(this.end()) && this._Key_eq(key, last.value)) {
last = last.next();
++ret;
}
this._Erase_by_range(first, last);
return ret;
};
/* ---------------------------------------------------------
UTILITY
--------------------------------------------------------- */
/**
* @inheritDoc
*/
MultiSet.prototype.merge = function (source) {
this.insert(source.begin(), source.end());
source.clear();
};
return MultiSet;
}(SetContainer_1.SetContainer));
exports.MultiSet = MultiSet;
//# sourceMappingURL=MultiSet.js.map
+115
View File
@@ -0,0 +1,115 @@
/**
* @packageDocumentation
* @module std.base
*/
import { IAssociativeContainer } from "../../internal/container/associative/IAssociativeContainer";
import { IContainer } from "./IContainer";
import { Container } from "./Container";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { ILinearContainerBase } from "../../internal/container/linear/ILinearContainerBase";
import { Pair } from "../../utility/Pair";
/**
* Basic set container.
*
* @template Key Key type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link SetContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class SetContainer<Key, Unique extends boolean, SourceT extends SetContainer<Key, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends SetContainer.Iterator<Key, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends SetContainer.ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>> extends Container<Key, SourceT, IteratorT, ReverseT, Key> implements IAssociativeContainer<Key, Key, SourceT, IteratorT, ReverseT, Key> {
protected data_: ILinearContainerBase<Key, SourceT, IteratorT, ReverseT>;
/**
* Default Constructor.
*/
protected constructor(factory: (thisArg: SourceT) => ILinearContainerBase<Key, SourceT, IteratorT, ReverseT>);
/**
* @inheritDoc
*/
assign<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
abstract find(key: Key): IteratorT;
/**
* @inheritDoc
*/
begin(): IteratorT;
/**
* @inheritDoc
*/
end(): IteratorT;
/**
* @inheritDoc
*/
has(key: Key): boolean;
/**
* @inheritDoc
*/
abstract count(key: Key): number;
/**
* @inheritDoc
*/
size(): number;
/**
* @inheritDoc
*/
push(...items: Key[]): number;
insert(key: Key): SetContainer.InsertRet<Key, Unique, SourceT, IteratorT, ReverseT>;
insert(hint: IteratorT, key: Key): IteratorT;
insert<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected abstract _Insert_by_key(key: Key): SetContainer.InsertRet<Key, Unique, SourceT, IteratorT, ReverseT>;
protected abstract _Insert_by_hint(hint: IteratorT, key: Key): IteratorT;
protected abstract _Insert_by_range<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(begin: InputIterator, end: InputIterator): void;
/**
* @inheritDoc
*/
erase(key: Key): number;
/**
* @inheritDoc
*/
erase(pos: IteratorT): IteratorT;
/**
* @inheritDoc
*/
erase(first: IteratorT, last: IteratorT): IteratorT;
protected abstract _Erase_by_val(key: Key): number;
protected _Erase_by_range(first: IteratorT, last?: IteratorT): IteratorT;
/**
* @inheritDoc
*/
abstract swap(obj: SourceT): void;
/**
* @inheritDoc
*/
abstract merge(source: SourceT): void;
protected abstract _Handle_insert(first: IteratorT, last: IteratorT): void;
protected abstract _Handle_erase(first: IteratorT, last: IteratorT): void;
}
/**
*
*/
export declare namespace SetContainer {
/**
* Return type of {@link SetContainer.insert}
*/
type InsertRet<Key, Unique extends boolean, Source extends SetContainer<Key, Unique, Source, IteratorT, ReverseT>, IteratorT extends Iterator<Key, Unique, Source, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, Unique, Source, IteratorT, ReverseT>> = Unique extends true ? Pair<IteratorT, boolean> : IteratorT;
/**
* Iterator of {@link SetContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, Unique extends boolean, SourceT extends SetContainer<Key, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>> = Readonly<IContainer.Iterator<Key, SourceT, IteratorT, ReverseT, Key>>;
/**
* Reverse iterator of {@link SetContainer}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, Unique extends boolean, SourceT extends SetContainer<Key, Unique, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, Unique, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, Unique, SourceT, IteratorT, ReverseT>> = Readonly<IContainer.ReverseIterator<Key, SourceT, IteratorT, ReverseT, Key>>;
}
+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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetContainer = void 0;
var Container_1 = require("./Container");
var NativeArrayIterator_1 = require("../../internal/iterator/disposable/NativeArrayIterator");
/**
* Basic set container.
*
* @template Key Key type
* @template Unique Whether duplicated key is blocked or not
* @template Source Derived type extending this {@link SetContainer}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var SetContainer = /** @class */ (function (_super) {
__extends(SetContainer, _super);
/* ---------------------------------------------------------
CONSTURCTORS
--------------------------------------------------------- */
/**
* Default Constructor.
*/
function SetContainer(factory) {
var _this = _super.call(this) || this;
_this.data_ = factory(_this);
return _this;
}
/**
* @inheritDoc
*/
SetContainer.prototype.assign = function (first, last) {
// INSERT
this.clear();
this.insert(first, last);
};
/**
* @inheritDoc
*/
SetContainer.prototype.clear = function () {
// TO BE ABSTRACT
this.data_.clear();
};
/**
* @inheritDoc
*/
SetContainer.prototype.begin = function () {
return this.data_.begin();
};
/**
* @inheritDoc
*/
SetContainer.prototype.end = function () {
return this.data_.end();
};
/* ---------------------------------------------------------
ELEMENTS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
SetContainer.prototype.has = function (key) {
return !this.find(key).equals(this.end());
};
/**
* @inheritDoc
*/
SetContainer.prototype.size = function () {
return this.data_.size();
};
/* =========================================================
ELEMENTS I/O
- INSERT
- ERASE
- UTILITY
- POST-PROCESS
============================================================
INSERT
--------------------------------------------------------- */
/**
* @inheritDoc
*/
SetContainer.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(first, last);
// RETURN SIZE
return this.size();
};
SetContainer.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 1)
return this._Insert_by_key(args[0]);
else if (args[0].next instanceof Function &&
args[1].next instanceof Function)
return this._Insert_by_range(args[0], args[1]);
else
return this._Insert_by_hint(args[0], args[1]);
};
SetContainer.prototype.erase = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 1 &&
!(args[0] instanceof this.end().constructor &&
args[0].source() === this))
return this._Erase_by_val(args[0]);
else if (args.length === 1)
return this._Erase_by_range(args[0]);
else
return this._Erase_by_range(args[0], args[1]);
};
SetContainer.prototype._Erase_by_range = function (first, last) {
if (last === void 0) { last = first.next(); }
// ERASE
var it = this.data_.erase(first, last);
// POST-PROCESS
this._Handle_erase(first, last);
return it;
};
return SetContainer;
}(Container_1.Container));
exports.SetContainer = SetContainer;
//# sourceMappingURL=SetContainer.js.map
+147
View File
@@ -0,0 +1,147 @@
/**
* @packageDocumentation
* @module std.base
*/
import { MapContainer } from "./MapContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { IPair } from "../../utility/IPair";
import { Entry } from "../../utility/Entry";
import { Pair } from "../../utility/Pair";
/**
* Basic map container blocking duplicated key.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link UniqueMap}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class UniqueMap<Key, T, Source extends UniqueMap<Key, T, Source, Iterator, Reverse>, Iterator extends UniqueMap.Iterator<Key, T, Source, Iterator, Reverse>, Reverse extends UniqueMap.ReverseIterator<Key, T, Source, Iterator, Reverse>> extends MapContainer<Key, T, true, Source, Iterator, Reverse> {
/**
* @inheritDoc
*/
count(key: Key): number;
/**
* Get a value.
*
* @param key Key to search for.
* @return The value mapped by the key.
*/
get(key: Key): T;
/**
* Take a value.
*
* Get a value, or set the value and returns it.
*
* @param key Key to search for.
* @param generator Value generator when the matched key not found
* @returns Value, anyway
*/
take(key: Key, generator: () => T): T;
/**
* Set a value with key.
*
* @param key Key to be mapped or search for.
* @param val Value to insert or assign.
*/
set(key: Key, val: T): void;
/**
* Construct and insert element.
*
* @param key Key to be mapped or search for.
* @param value Value to emplace.
* @return {@link Pair} of an iterator to the newly inserted element and `true`, if the specified *key* doesn't exist, otherwise {@link Pair} of iterator to the ordinary element and `false`.
*/
abstract emplace(key: Key, value: T): Pair<Iterator, boolean>;
/**
* Construct and insert element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param key Key of the new element.
* @param val Value of the new element.
* @return An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.
*/
abstract emplace_hint(hint: Iterator, key: Key, val: T): Iterator;
/**
* Insert an element.
*
* @param pair A tuple to be referenced for the insert.
* @return {@link Pair} of an iterator to the newly inserted element and `true`, if the specified *key* doesn't exist, otherwise {@link Pair} of iterator to the ordinary element and `false`.
*/
insert(pair: IPair<Key, T>): Pair<Iterator, boolean>;
/**
* Insert an element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.
*/
insert(hint: Iterator, pair: IPair<Key, T>): Iterator;
/**
* Insert range elements.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
insert<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* Insert or assign an element.
*
* @param key Key to be mapped or search for.
* @param value Value to insert or assign.
* @return {@link Pair} of an iterator to the newly inserted element and `true`, if the specified *key* doesn't exist, otherwise {@link Pair} of iterator to the ordinary element and `false`.
*/
insert_or_assign(key: Key, value: T): Pair<Iterator, boolean>;
/**
* Insert or assign an element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param key Key to be mapped or search for.
* @param value Value to insert or assign.
* @return An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.
*/
insert_or_assign(hint: Iterator, key: Key, value: T): Iterator;
private _Insert_or_assign_with_key_value;
private _Insert_or_assign_with_hint;
/**
* Extract an element by key.
*
* @param key Key to search for.
* @return The extracted element.
*/
extract(key: Key): Entry<Key, T>;
/**
* Extract an element by iterator.
*
* @param pos The iterator to the element for extraction.
* @return Iterator following the *pos*, strained by the extraction.
*/
extract(pos: Iterator): Iterator;
private _Extract_by_key;
private _Extract_by_iterator;
protected _Erase_by_key(key: Key): number;
/**
* @inheritDoc
*/
merge(source: Source): void;
}
/**
*
*/
export declare namespace UniqueMap {
/**
* Iterator of {@link UniqueMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, T, SourceT extends UniqueMap<Key, T, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, SourceT, IteratorT, ReverseT>> = MapContainer.Iterator<Key, T, true, SourceT, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link UniqueMap}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, T, SourceT extends UniqueMap<Key, T, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, T, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, T, SourceT, IteratorT, ReverseT>> = MapContainer.ReverseIterator<Key, T, true, SourceT, IteratorT, ReverseT>;
}
+194
View File
@@ -0,0 +1,194 @@
"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.UniqueMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.base
*/
//================================================================
var MapContainer_1 = require("./MapContainer");
var ErrorGenerator_1 = require("../../internal/exception/ErrorGenerator");
/**
* Basic map container blocking duplicated key.
*
* @template Key Key type
* @template T Mapped type
* @template Source Derived type extending this {@link UniqueMap}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var UniqueMap = /** @class */ (function (_super) {
__extends(UniqueMap, _super);
function UniqueMap() {
return _super !== null && _super.apply(this, arguments) || this;
}
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
UniqueMap.prototype.count = function (key) {
return this.find(key).equals(this.end()) ? 0 : 1;
};
/**
* Get a value.
*
* @param key Key to search for.
* @return The value mapped by the key.
*/
UniqueMap.prototype.get = function (key) {
var it = this.find(key);
if (it.equals(this.end()) === true)
throw ErrorGenerator_1.ErrorGenerator.key_nout_found(this, "get", key);
return it.second;
};
/**
* Take a value.
*
* Get a value, or set the value and returns it.
*
* @param key Key to search for.
* @param generator Value generator when the matched key not found
* @returns Value, anyway
*/
UniqueMap.prototype.take = function (key, generator) {
var it = this.find(key);
return it.equals(this.end())
? this.emplace(key, generator()).first.second
: it.second;
};
/**
* Set a value with key.
*
* @param key Key to be mapped or search for.
* @param val Value to insert or assign.
*/
UniqueMap.prototype.set = function (key, val) {
this.insert_or_assign(key, val);
};
UniqueMap.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return _super.prototype.insert.apply(this, __spreadArray([], __read(args), false));
};
UniqueMap.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);
};
UniqueMap.prototype.insert_or_assign = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (args.length === 2) {
return this._Insert_or_assign_with_key_value(args[0], args[1]);
}
else if (args.length === 3) {
// INSERT OR ASSIGN AN ELEMENT
return this._Insert_or_assign_with_hint(args[0], args[1], args[2]);
}
};
UniqueMap.prototype._Insert_or_assign_with_key_value = function (key, value) {
var ret = this.emplace(key, value);
if (ret.second === false)
ret.first.second = value;
return ret;
};
UniqueMap.prototype._Insert_or_assign_with_hint = function (hint, key, value) {
var ret = this.emplace_hint(hint, key, value);
if (ret.second !== value)
ret.second = value;
return ret;
};
UniqueMap.prototype.extract = function (param) {
if (param instanceof this.end().constructor)
return this._Extract_by_iterator(param);
else
return this._Extract_by_key(param);
};
UniqueMap.prototype._Extract_by_key = function (key) {
var it = this.find(key);
if (it.equals(this.end()) === true)
throw ErrorGenerator_1.ErrorGenerator.key_nout_found(this, "extract", key);
var ret = it.value;
this._Erase_by_range(it);
return ret;
};
UniqueMap.prototype._Extract_by_iterator = function (it) {
if (it.equals(this.end()) === true)
return this.end();
this._Erase_by_range(it);
return it;
};
UniqueMap.prototype._Erase_by_key = function (key) {
var it = this.find(key);
if (it.equals(this.end()) === true)
return 0;
this._Erase_by_range(it);
return 1;
};
/* ---------------------------------------------------------
UTILITY
--------------------------------------------------------- */
/**
* @inheritDoc
*/
UniqueMap.prototype.merge = function (source) {
for (var it = source.begin(); !it.equals(source.end());)
if (this.has(it.first) === false) {
this.insert(it.value);
it = source.erase(it);
}
else
it = it.next();
};
return UniqueMap;
}(MapContainer_1.MapContainer));
exports.UniqueMap = UniqueMap;
//# sourceMappingURL=UniqueMap.js.map
+84
View File
@@ -0,0 +1,84 @@
/**
* @packageDocumentation
* @module std.base
*/
import { SetContainer } from "./SetContainer";
import { IForwardIterator } from "../../iterator/IForwardIterator";
import { Pair } from "../../utility/Pair";
/**
* Basic set container blocking duplicated key.
*
* @template Key Key type
* @template Source Derived type extending this {@link UniqueSet}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare abstract class UniqueSet<Key, Source extends UniqueSet<Key, Source, IteratorT, ReverseT>, IteratorT extends UniqueSet.Iterator<Key, Source, IteratorT, ReverseT>, ReverseT extends UniqueSet.ReverseIterator<Key, Source, IteratorT, ReverseT>> extends SetContainer<Key, true, Source, IteratorT, ReverseT> {
/**
* @inheritDoc
*/
count(key: Key): number;
/**
* Insert an element.
*
* @param key Key to insert.
* @return {@link Pair} of an iterator to the newly inserted element and `true`, if the specified *key* doesn't exist, otherwise {@link Pair} of iterator to ordinary element and `false`.
*/
insert(key: Key): Pair<IteratorT, boolean>;
/**
* Insert an element with hint.
*
* @param hint Hint for the position where the element can be inserted.
* @param pair A tuple to be referenced for the insert.
* @return An iterator to the newly inserted element, if the specified key doesn't exist, otherwise an iterator to the ordinary element.
*/
insert(hint: IteratorT, key: Key): IteratorT;
/**
* Insert range elements.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
insert<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* Extract an element by key.
*
* @param key Key to search for.
* @return The extracted element.
*/
extract(key: Key): Key;
/**
* Extract an element by iterator.
*
* @param pos The iterator to the element for extraction.
* @return Iterator following the *pos*, strained by the extraction.
*/
extract(it: IteratorT): IteratorT;
private _Extract_by_val;
private _Extract_by_iterator;
protected _Erase_by_val(key: Key): number;
/**
* @inheritDoc
*/
merge(source: Source): void;
}
/**
*
*/
export declare namespace UniqueSet {
/**
* Iterator of {@link UniqueSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type Iterator<Key, SourceT extends UniqueSet<Key, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, SourceT, IteratorT, ReverseT>> = SetContainer.Iterator<Key, true, SourceT, IteratorT, ReverseT>;
/**
* Reverse iterator of {@link UniqueSet}
*
* @author Jenogho Nam <http://samchon.org>
*/
type ReverseIterator<Key, SourceT extends UniqueSet<Key, SourceT, IteratorT, ReverseT>, IteratorT extends Iterator<Key, SourceT, IteratorT, ReverseT>, ReverseT extends ReverseIterator<Key, SourceT, IteratorT, ReverseT>> = SetContainer.ReverseIterator<Key, true, SourceT, IteratorT, ReverseT>;
}
+132
View File
@@ -0,0 +1,132 @@
"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.UniqueSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std.base
*/
//================================================================
var SetContainer_1 = require("./SetContainer");
var ErrorGenerator_1 = require("../../internal/exception/ErrorGenerator");
/**
* Basic set container blocking duplicated key.
*
* @template Key Key type
* @template Source Derived type extending this {@link UniqueSet}
* @template IteratorT Iterator type
* @template ReverseT Reverse iterator type
*
* @author Jeongho Nam - https://github.com/samchon
*/
var UniqueSet = /** @class */ (function (_super) {
__extends(UniqueSet, _super);
function UniqueSet() {
return _super !== null && _super.apply(this, arguments) || this;
}
/* ---------------------------------------------------------
ACCESSOR
--------------------------------------------------------- */
/**
* @inheritDoc
*/
UniqueSet.prototype.count = function (key) {
return this.find(key).equals(this.end()) ? 0 : 1;
};
UniqueSet.prototype.insert = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return _super.prototype.insert.apply(this, __spreadArray([], __read(args), false));
};
UniqueSet.prototype._Insert_by_range = function (first, last) {
for (; !first.equals(last); first = first.next())
this._Insert_by_key(first.value);
};
UniqueSet.prototype.extract = function (param) {
if (param instanceof this.end().constructor)
return this._Extract_by_iterator(param);
else
return this._Extract_by_val(param);
};
UniqueSet.prototype._Extract_by_val = function (key) {
var it = this.find(key);
if (it.equals(this.end()) === true)
throw ErrorGenerator_1.ErrorGenerator.key_nout_found(this, "extract", key);
this._Erase_by_range(it);
return key;
};
UniqueSet.prototype._Extract_by_iterator = function (it) {
if (it.equals(this.end()) === true || this.has(it.value) === false)
return this.end();
this._Erase_by_range(it);
return it;
};
UniqueSet.prototype._Erase_by_val = function (key) {
var it = this.find(key);
if (it.equals(this.end()) === true)
return 0;
this._Erase_by_range(it);
return 1;
};
/* ---------------------------------------------------------
UTILITY
--------------------------------------------------------- */
/**
* @inheritDoc
*/
UniqueSet.prototype.merge = function (source) {
for (var it = source.begin(); !it.equals(source.end());) {
if (this.has(it.value) === false) {
this.insert(it.value);
it = source.erase(it);
}
else
it = it.next();
}
};
return UniqueSet;
}(SetContainer_1.SetContainer));
exports.UniqueSet = UniqueSet;
//# sourceMappingURL=UniqueSet.js.map
+19
View File
@@ -0,0 +1,19 @@
/**
* @packageDocumentation
* @module std.base
*/
export * from "./IContainer";
export * from "./ILinearContainer";
export * from "./IDequeContainer";
export * from "./IArrayContainer";
export * from "./Container";
export * from "./SetContainer";
export * from "./UniqueSet";
export * from "./MultiSet";
export * from "./ITreeSet";
export * from "./IHashSet";
export * from "./MapContainer";
export * from "./UniqueMap";
export * from "./MultiMap";
export * from "./ITreeMap";
export * from "./IHashMap";
+41
View File
@@ -0,0 +1,41 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
//================================================================
/**
* @packageDocumentation
* @module std.base
*/
//================================================================
// LINEAR
__exportStar(require("./IContainer"), exports);
__exportStar(require("./ILinearContainer"), exports);
__exportStar(require("./IDequeContainer"), exports);
__exportStar(require("./IArrayContainer"), exports);
__exportStar(require("./Container"), exports);
// SETS
__exportStar(require("./SetContainer"), exports);
__exportStar(require("./UniqueSet"), exports);
__exportStar(require("./MultiSet"), exports);
__exportStar(require("./ITreeSet"), exports);
__exportStar(require("./IHashSet"), exports);
// MAPS
__exportStar(require("./MapContainer"), exports);
__exportStar(require("./UniqueMap"), exports);
__exportStar(require("./MultiMap"), exports);
__exportStar(require("./ITreeMap"), exports);
__exportStar(require("./IHashMap"), exports);
//# sourceMappingURL=index.js.map