remove node_modules and .gitignore them

This commit is contained in:
2023-11-24 14:40:32 -05:00
parent 5f6e638903
commit a74d7b91b8
8963 changed files with 1 additions and 874175 deletions
-167
View File
@@ -1,167 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { IArrayContainer } from "../base/container/IArrayContainer";
import { ArrayContainer } from "../internal/container/linear/ArrayContainer";
import { ArrayIterator } from "../internal/iterator/ArrayIterator";
import { ArrayReverseIterator } from "../internal/iterator/ArrayReverseIterator";
import { IForwardIterator } from "../iterator/IForwardIterator";
/**
* Double ended queue.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class Deque<T> extends ArrayContainer<T, Deque<T>, Deque<T>, Deque.Iterator<T>, Deque.ReverseIterator<T>, T> implements IArrayContainer<T, Deque<T>, Deque.Iterator<T>, Deque.ReverseIterator<T>> {
private matrix_;
private size_;
private capacity_;
/**
* Default Constructor.
*/
constructor();
/**
* Initializer Constructor.
*
* @param items Items to assign.
*/
constructor(items: T[]);
/**
* Copy Constructor
*
* @param obj Object to copy.
*/
constructor(obj: Deque<T>);
/**
* Fill Constructor.
*
* @param size Initial size.
* @param val Value to fill.
*/
constructor(size: number, val: T);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
*/
constructor(first: Readonly<IForwardIterator<T>>, last: Readonly<IForwardIterator<T>>);
/**
* @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;
/**
* Reserve {@link capacity} enable to store *n* elements.
*
* @param n The capacity to reserve.
*/
reserve(n: number): void;
private _Reserve;
/**
* Shrink {@link capacity} to actual {@link size}.
*/
shrink_to_fit(): void;
/**
* @inheritDoc
*/
swap(obj: Deque<T>): void;
private _Swap;
private static _Emend;
/**
* @inheritDoc
*/
size(): number;
/**
* The capacity to store elements.
*
* @return The capacity.
*/
capacity(): number;
/**
* @inheritDoc
*/
nth(index: number): Deque.Iterator<T>;
/**
* @inheritDoc
*/
[Symbol.iterator](): IterableIterator<T>;
protected source(): Deque<T>;
protected _At(index: number): T;
protected _Set(index: number, val: T): void;
private _Fetch_index;
private _Compute_col_size;
/**
* @inheritDoc
*/
push(...items: T[]): number;
/**
* @inheritDoc
*/
push_front(val: T): void;
/**
* @inheritDoc
*/
push_back(val: T): void;
/**
* @inheritDoc
*/
pop_front(): void;
protected _Pop_back(): void;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(pos: Deque.Iterator<T>, first: InputIterator, last: InputIterator): Deque.Iterator<T>;
private _Insert_to_middle;
private _Insert_to_end;
private _Try_expand_capacity;
private _Try_add_row_at_front;
private _Try_add_row_at_back;
protected _Erase_by_range(first: Deque.Iterator<T>, last: Deque.Iterator<T>): Deque.Iterator<T>;
}
/**
*
*/
export declare namespace Deque {
/**
* Iterator of {@link Deque}
*/
type Iterator<T> = ArrayIterator<T, Deque<T>>;
/**
* Reverse iterator of {@link Deque}
*/
type ReverseIterator<T> = ArrayReverseIterator<T, Deque<T>>;
const Iterator: typeof ArrayIterator;
const ReverseIterator: typeof ArrayReverseIterator;
/**
* Row size of the {@link Deque.matrix_ matrix} which contains elements.
*
* Note that the {@link ROW_SIZE} affects on time complexity of accessing and inserting element.
* Accessing element is {@link ROW_SIZE} times slower than ordinary {@link Vector} and inserting element
* in middle position is {@link ROW_SIZE} times faster than ordinary {@link Vector}.
*
* When the {@link ROW_SIZE} returns 8, time complexity of accessing element is O(8) and inserting
* element in middle position is O(N/8). ({@link Vector}'s time complexity of accessement is O(1)
* and inserting element is O(N)).
*/
const ROW_SIZE = 8;
/**
* Minimum {@link Deque.capacity}.
*
* Although a {@link Deque} has few elements, even no element is belonged to, the {@link Deque}
* keeps the minimum {@link Deque.capacity} at least.
*/
const MIN_CAPACITY = 36;
/**
* Expansion ratio.
*/
const MAGNIFIER = 1.5;
}
-529
View File
@@ -1,529 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.Deque = void 0;
var ArrayContainer_1 = require("../internal/container/linear/ArrayContainer");
var ArrayIterator_1 = require("../internal/iterator/ArrayIterator");
var ArrayReverseIterator_1 = require("../internal/iterator/ArrayReverseIterator");
var NativeArrayIterator_1 = require("../internal/iterator/disposable/NativeArrayIterator");
var Pair_1 = require("../utility/Pair");
var InvalidArgument_1 = require("../exception/InvalidArgument");
var global_1 = require("../iterator/global");
var ErrorGenerator_1 = require("../internal/exception/ErrorGenerator");
/**
* Double ended queue.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Deque = /** @class */ (function (_super) {
__extends(Deque, _super);
function Deque() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this) || this;
// CONSTRUCTORS BRANCH
if (args.length === 0) {
_this.clear();
}
if (args.length === 1 && args[0] instanceof Array) {
// INITIALIZER CONSTRUCTOR
var array = args[0];
var first = new NativeArrayIterator_1.NativeArrayIterator(array, 0);
var last = new NativeArrayIterator_1.NativeArrayIterator(array, array.length);
_this.assign(first, last);
}
else if (args.length === 1 && args[0] instanceof Deque) {
// COPY CONSTRUCTOR
var container = args[0];
_this.assign(container.begin(), container.end());
}
else if (args.length === 2) {
// ASSIGN CONSTRUCTOR
_this.assign(args[0], args[1]);
}
return _this;
}
Deque.prototype.assign = function (first, second) {
// CLEAR PREVIOUS CONTENTS
this.clear();
// INSERT ITEMS
this.insert(this.end(), first, second);
};
/**
* @inheritDoc
*/
Deque.prototype.clear = function () {
// CLEAR CONTENTS
this.matrix_ = [[]];
// RE-INDEX
this.size_ = 0;
this.capacity_ = Deque.MIN_CAPACITY;
};
/**
* @inheritDoc
*/
Deque.prototype.resize = function (n) {
n = Deque._Emend(n, "resize");
var expansion = n - this.size();
if (expansion > 0)
this.insert(this.end(), expansion, undefined);
else if (expansion < 0)
this.erase(this.end().advance(-expansion), this.end());
};
/**
* Reserve {@link capacity} enable to store *n* elements.
*
* @param n The capacity to reserve.
*/
Deque.prototype.reserve = function (n) {
this._Reserve(Deque._Emend(n, "reserve"));
};
Deque.prototype._Reserve = function (n) {
// NEW MEMBERS TO BE ASSSIGNED
var matrix = [[]];
var length = this._Compute_col_size(n);
//--------
// RE-FILL
//--------
for (var r = 0; r < this.matrix_.length; ++r) {
var row = this.matrix_[r];
for (var c = 0; c < row.length; ++c) {
var new_row = matrix[matrix.length - 1];
if (matrix.length < Deque.ROW_SIZE &&
new_row.length === length) {
new_row = [];
matrix.push(new_row);
}
new_row.push(row[c]);
}
}
// ASSIGN MEMBERS
this.matrix_ = matrix;
this.capacity_ = n;
};
/**
* Shrink {@link capacity} to actual {@link size}.
*/
Deque.prototype.shrink_to_fit = function () {
this._Reserve(this.size());
};
/**
* @inheritDoc
*/
Deque.prototype.swap = function (obj) {
this._Swap(obj);
};
Deque.prototype._Swap = function (obj) {
var _a, _b, _c;
// SWAP CONTENTS
_a = __read([obj.matrix_, this.matrix_], 2), this.matrix_ = _a[0], obj.matrix_ = _a[1];
_b = __read([obj.size_, this.size_], 2), this.size_ = _b[0], obj.size_ = _b[1];
_c = __read([obj.capacity_, this.capacity_], 2), this.capacity_ = _c[0], obj.capacity_ = _c[1];
};
Deque._Emend = function (n, method) {
n = Math.floor(n);
if (n <= 0)
throw new InvalidArgument_1.InvalidArgument("Error on Deque.".concat(method, "(): n must be positive integer -> (n = ").concat(n, ")"));
return n;
};
/* =========================================================
ACCESSORS
- BASIC ELEMENTS
- INDEX ACCESSORS
============================================================
BASIC ELEMENTS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
Deque.prototype.size = function () {
return this.size_;
};
/**
* The capacity to store elements.
*
* @return The capacity.
*/
Deque.prototype.capacity = function () {
return this.capacity_;
};
/**
* @inheritDoc
*/
Deque.prototype.nth = function (index) {
return new Deque.Iterator(this, index);
};
/**
* @inheritDoc
*/
Deque.prototype[Symbol.iterator] = function () {
return new Deque.ForOfAdaptor(this.matrix_);
};
Deque.prototype.source = function () {
return this;
};
/* ---------------------------------------------------------
INDEX ACCESSORS
--------------------------------------------------------- */
Deque.prototype._At = function (index) {
var indexPair = this._Fetch_index(index);
return this.matrix_[indexPair.first][indexPair.second];
};
Deque.prototype._Set = function (index, val) {
var indexPair = this._Fetch_index(index);
this.matrix_[indexPair.first][indexPair.second] = val;
};
Deque.prototype._Fetch_index = function (index) {
// Fetch row and column's index.
var row;
for (row = 0; row < this.matrix_.length; row++) {
var array = this.matrix_[row];
if (index < array.length)
break;
index -= array.length;
}
if (row === this.matrix_.length)
row--;
return new Pair_1.Pair(row, index);
};
Deque.prototype._Compute_col_size = function (capacity) {
if (capacity === void 0) { capacity = this.capacity_; }
// Get column size; {@link capacity_ capacity} / {@link ROW_SIZE row}.
return Math.floor(capacity / Deque.ROW_SIZE);
};
/* =========================================================
ELEMENTS I/O
- PUSH & POP
- INSERT
- ERASE
============================================================
PUSH & POP
--------------------------------------------------------- */
/**
* @inheritDoc
*/
Deque.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();
};
/**
* @inheritDoc
*/
Deque.prototype.push_front = function (val) {
// ADD CAPACITY & ROW
this._Try_expand_capacity(this.size_ + 1);
this._Try_add_row_at_front();
// INSERT VALUE
this.matrix_[0].unshift(val);
++this.size_;
};
/**
* @inheritDoc
*/
Deque.prototype.push_back = function (val) {
// ADD CAPACITY & ROW
this._Try_expand_capacity(this.size_ + 1);
this._Try_add_row_at_back();
// INSERT VALUE
this.matrix_[this.matrix_.length - 1].push(val);
++this.size_;
};
/**
* @inheritDoc
*/
Deque.prototype.pop_front = function () {
if (this.empty() === true)
throw ErrorGenerator_1.ErrorGenerator.empty(this.constructor, "pop_front");
// EREASE FIRST ELEMENT
this.matrix_[0].shift();
if (this.matrix_[0].length === 0 && this.matrix_.length > 1)
this.matrix_.shift();
// SHRINK SIZE
this.size_--;
};
Deque.prototype._Pop_back = function () {
// ERASE LAST ELEMENT
var lastArray = this.matrix_[this.matrix_.length - 1];
lastArray.pop();
if (lastArray.length === 0 && this.matrix_.length > 1)
this.matrix_.pop();
// SHRINK SIZE
this.size_--;
};
/* ---------------------------------------------------------
INSERT
--------------------------------------------------------- */
Deque.prototype._Insert_by_range = function (pos, first, last) {
var size = this.size_ + (0, global_1.distance)(first, last);
if (size === this.size_)
// FIRST === LAST
return pos;
if (pos.equals(this.end()) === true) {
// EXPAND CAPACITY IF REQUIRED
this._Try_expand_capacity(size);
// INSERT TO END
this._Insert_to_end(first, last);
// CHANGE POS TO RETURN
pos = this.nth(this.size_);
}
else {
// INSERT ITEMS IN THE MIDDLE
if (size > this.capacity_) {
// A TEMPORARY DEQUE
var deque = new Deque();
deque._Reserve(Math.max(size, Math.floor(this.capacity_ * Deque.MAGNIFIER)));
// INSERT ITEM SEQUENTIALLY
deque._Insert_to_end(this.begin(), pos);
deque._Insert_to_end(first, last);
deque._Insert_to_end(pos, this.end());
// AND SWAP THIS WITH THE TEMP
this._Swap(deque);
}
else
this._Insert_to_middle(pos, first, last);
}
this.size_ = size;
return pos;
};
Deque.prototype._Insert_to_middle = function (pos, first, last) {
var _a, _b;
var col_size = this._Compute_col_size();
// POSITION OF MATRIX
var indexes = this._Fetch_index(pos.index());
var row = this.matrix_[indexes.first];
var col = indexes.second;
// MOVE BACK SIDE TO TEMPORARY ARRAY
var back_items = row.splice(col);
// INSERT ITEMS
for (; !first.equals(last); first = first.next()) {
if (row.length === col_size &&
this.matrix_.length < Deque.ROW_SIZE) {
row = new Array();
var spliced_array = this.matrix_.splice(++indexes.first);
this.matrix_.push(row);
(_a = this.matrix_).push.apply(_a, __spreadArray([], __read(spliced_array), false));
}
row.push(first.value);
}
// INSERT ITEMS IN THE BACK SIDE
for (var i = 0; i < back_items.length; ++i) {
if (row.length === col_size &&
this.matrix_.length < Deque.ROW_SIZE) {
row = new Array();
var spliced_array = this.matrix_.splice(++indexes.first);
this.matrix_.push(row);
(_b = this.matrix_).push.apply(_b, __spreadArray([], __read(spliced_array), false));
}
row.push(back_items[i]);
}
};
Deque.prototype._Insert_to_end = function (first, last) {
// INSERT ITEMS IN THE BACK
for (; !first.equals(last); first = first.next()) {
// ADD ROW IF REQUIRED
this._Try_add_row_at_back();
// INSERT VALUE
this.matrix_[this.matrix_.length - 1].push(first.value);
}
};
Deque.prototype._Try_expand_capacity = function (size) {
if (size <= this.capacity_)
return false;
// MAX (CAPACITY * 1.5, TARGET SIZE)
size = Math.max(size, Math.floor(this.capacity_ * Deque.MAGNIFIER));
this._Reserve(size);
return true;
};
Deque.prototype._Try_add_row_at_front = function () {
var _a;
var col_size = this._Compute_col_size();
if (this.matrix_[0].length >= col_size &&
this.matrix_.length < Deque.ROW_SIZE) {
this.matrix_ = (_a = [[]]).concat.apply(_a, __spreadArray([], __read(this.matrix_), false));
return true;
}
else
return false;
};
Deque.prototype._Try_add_row_at_back = function () {
var col_size = this._Compute_col_size();
if (this.matrix_[this.matrix_.length - 1].length >= col_size &&
this.matrix_.length < Deque.ROW_SIZE) {
this.matrix_.push([]);
return true;
}
else
return false;
};
/* ---------------------------------------------------------
ERASE
--------------------------------------------------------- */
Deque.prototype._Erase_by_range = function (first, last) {
if (first.index() >= this.size())
return first;
// INDEXING
var size;
if (last.index() >= this.size())
// LAST IS END()
size = this.size() - first.index();
// LAST IS NOT END()
else
size = last.index() - first.index();
this.size_ -= size;
// ERASING
var first_row = null;
var second_row = null;
var i = 0;
while (size !== 0) {
// FIND MATCHED ROW AND COLUMN
var indexes = this._Fetch_index(first.index());
var row = this.matrix_[indexes.first];
var col = indexes.second;
// EARSE FROM THE ROW
var my_delete_size = Math.min(size, row.length - col);
row.splice(col, my_delete_size);
// TO MERGE
if (row.length !== 0)
if (i === 0)
first_row = row;
else
second_row = row;
// ERASE THE ENTIRE ROW IF REQUIRED
if (row.length === 0 && this.matrix_.length > 1)
this.matrix_.splice(indexes.first, 1);
// TO THE NEXT STEP
size -= my_delete_size;
++i;
}
// MERGE FIRST AND SECOND ROW
if (first_row !== null &&
second_row !== null &&
first_row.length + second_row.length <= this._Compute_col_size()) {
first_row.push.apply(first_row, __spreadArray([], __read(second_row), false));
this.matrix_.splice(this.matrix_.indexOf(second_row), 1);
}
return first;
};
return Deque;
}(ArrayContainer_1.ArrayContainer));
exports.Deque = Deque;
/**
*
*/
(function (Deque) {
// BODY
Deque.Iterator = ArrayIterator_1.ArrayIterator;
Deque.ReverseIterator = ArrayReverseIterator_1.ArrayReverseIterator;
//----
// CONSTANTS
//----
/**
* Row size of the {@link Deque.matrix_ matrix} which contains elements.
*
* Note that the {@link ROW_SIZE} affects on time complexity of accessing and inserting element.
* Accessing element is {@link ROW_SIZE} times slower than ordinary {@link Vector} and inserting element
* in middle position is {@link ROW_SIZE} times faster than ordinary {@link Vector}.
*
* When the {@link ROW_SIZE} returns 8, time complexity of accessing element is O(8) and inserting
* element in middle position is O(N/8). ({@link Vector}'s time complexity of accessement is O(1)
* and inserting element is O(N)).
*/
Deque.ROW_SIZE = 8;
/**
* Minimum {@link Deque.capacity}.
*
* Although a {@link Deque} has few elements, even no element is belonged to, the {@link Deque}
* keeps the minimum {@link Deque.capacity} at least.
*/
Deque.MIN_CAPACITY = 36;
/**
* Expansion ratio.
*/
Deque.MAGNIFIER = 1.5;
/**
* @internal
*/
var ForOfAdaptor = /** @class */ (function () {
function ForOfAdaptor(matrix) {
this.matrix_ = matrix;
this.row_ = 0;
this.col_ = 0;
}
ForOfAdaptor.prototype.next = function () {
if (this.row_ === this.matrix_.length)
return {
done: true,
value: undefined,
};
else {
var val = this.matrix_[this.row_][this.col_];
if (++this.col_ === this.matrix_[this.row_].length) {
++this.row_;
this.col_ = 0;
}
return {
done: false,
value: val,
};
}
};
ForOfAdaptor.prototype[Symbol.iterator] = function () {
return this;
};
return ForOfAdaptor;
}());
Deque.ForOfAdaptor = ForOfAdaptor;
})(Deque = exports.Deque || (exports.Deque = {}));
exports.Deque = Deque;
//# sourceMappingURL=Deque.js.map
-256
View File
@@ -1,256 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { IForwardContainer } from "../ranges/container/IForwardContainer";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { IClear } from "../internal/container/partial/IClear";
import { IEmpty } from "../internal/container/partial/IEmpty";
import { ISize } from "../internal/container/partial/ISize";
import { IDeque } from "../internal/container/partial/IDeque";
import { IFront } from "../internal/container/partial/IFront";
import { IListAlgorithm } from "../internal/container/linear/IListAlgorithm";
import { Comparator } from "../internal/functional/Comparator";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { UnaryPredicator } from "../internal/functional/UnaryPredicator";
/**
* Singly Linked List.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class ForwardList<T> implements IForwardContainer<ForwardList.Iterator<T>>, IClear, IEmpty, ISize, IDeque<T>, IFront<T>, Iterable<T>, IListAlgorithm<T, ForwardList<T>> {
private ptr_;
private size_;
private before_begin_;
private end_;
/**
* Default Constructor.
*/
constructor();
/**
* Initializer Constructor.
*
* @param items Items to assign.
*/
constructor(items: T[]);
/**
* Copy Constructor
*
* @param obj Object to copy.
*/
constructor(obj: ForwardList<T>);
/**
* Fill Constructor.
*
* @param size Initial size.
* @param val Value to fill.
*/
constructor(n: number, val: T);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
*/
constructor(first: Readonly<IForwardIterator<T>>, last: Readonly<IForwardIterator<T>>);
/**
* Fill Assigner.
*
* @param n Initial size.
* @param val Value to fill.
*/
assign(n: number, val: T): void;
/**
* Range Assigner.
*
* @param first Input iteartor of the first position.
* @param last Input iterator of the last position.
*/
assign<T, InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
size(): number;
/**
* @inheritDoc
*/
empty(): boolean;
/**
* @inheritDoc
*/
front(): T;
/**
* @inheritDoc
*/
front(val: T): void;
/**
* Iterator to before beginning.
*
* @return Iterator to the before beginning.
*/
before_begin(): ForwardList.Iterator<T>;
/**
* @inheritDoc
*/
begin(): ForwardList.Iterator<T>;
/**
* @inheritDoc
*/
end(): ForwardList.Iterator<T>;
/**
* @inheritDoc
*/
[Symbol.iterator](): IterableIterator<T>;
/**
* @inheritDoc
*/
push_front(val: T): void;
/**
* Insert an element.
*
* @param pos Position to insert after.
* @param val Value to insert.
* @return An iterator to the newly inserted element.
*/
insert_after(pos: ForwardList.Iterator<T>, val: T): ForwardList.Iterator<T>;
/**
* Inserted repeated elements.
*
* @param pos Position to insert after.
* @param n Number of elements to insert.
* @param val Value to insert repeatedly.
* @return An iterator to the last of the newly inserted elements.
*/
insert_after(pos: ForwardList.Iterator<T>, n: number, val: T): ForwardList.Iterator<T>;
/**
* Insert range elements.
*
* @param pos Position to insert after.
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
* @return An iterator to the last of the newly inserted elements.
*/
insert_after<T, InputIterator extends Readonly<IForwardIterator<T, InputIterator>>>(pos: ForwardList.Iterator<T>, first: InputIterator, last: InputIterator): ForwardList.Iterator<T>;
private _Insert_by_repeating_val;
private _Insert_by_range;
/**
* @inheritDoc
*/
pop_front(): void;
/**
* Erase an element.
*
* @param it Position to erase after.
* @return Iterator to the erased element.
*/
erase_after(it: ForwardList.Iterator<T>): ForwardList.Iterator<T>;
/**
* Erase elements.
*
* @param first Range of the first position to erase after.
* @param last Rangee of the last position to erase.
* @return Iterator to the last removed element.
*/
erase_after(first: ForwardList.Iterator<T>, last: ForwardList.Iterator<T>): ForwardList.Iterator<T>;
/**
* @inheritDoc
*/
unique(binary_pred?: BinaryPredicator<T>): void;
/**
* @inheritDoc
*/
remove(val: T): void;
/**
* @inheritDoc
*/
remove_if(pred: UnaryPredicator<T>): void;
/**
* @inheritDoc
*/
merge(from: ForwardList<T>, comp?: Comparator<T>): void;
/**
* Transfer elements.
*
* @param pos Position to insert after.
* @param from Target container to transfer.
*/
splice_after(pos: ForwardList.Iterator<T>, from: ForwardList<T>): void;
/**
* Transfer a single element.
*
* @param pos Position to insert after.
* @param from Target container to transfer.
* @param before Previous position of the single element to transfer.
*/
splice_after(pos: ForwardList.Iterator<T>, from: ForwardList<T>, before: ForwardList.Iterator<T>): void;
/**
* Transfer range elements.
*
* @param pos Position to insert after.
* @param from Target container to transfer.
* @param first Range of previous of the first position to transfer.
* @param last Rangee of the last position to transfer.
*/
splice_after(pos: ForwardList.Iterator<T>, from: ForwardList<T>, first_before: ForwardList.Iterator<T>, last: ForwardList.Iterator<T>): void;
/**
* @inheritDoc
*/
sort(comp?: Comparator<T>): void;
/**
* @inheritDoc
*/
reverse(): void;
/**
* @inheritDoc
*/
swap(obj: ForwardList<T>): void;
/**
* Native function for `JSON.stringify()`.
*
* @return An array containing children elements.
*/
toJSON(): Array<T>;
}
/**
*
*/
export declare namespace ForwardList {
/**
* Iterator of {@link ForwardList}
*
* @author Jeongho Nam - https://github.com/samchon
*/
class Iterator<T> implements IForwardIterator<T, Iterator<T>> {
private source_ptr_;
private next_;
private value_;
private constructor();
/**
* Get source container.
*
* @return The source container.
*/
source(): ForwardList<T>;
/**
* @inheritDoc
*/
get value(): T;
/**
* @inheritDoc
*/
set value(val: T);
private _Try_value;
/**
* @inheritDoc
*/
next(): Iterator<T>;
/**
* @inheritDoc
*/
equals(obj: Iterator<T>): boolean;
}
}
-424
View File
@@ -1,424 +0,0 @@
"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.");
};
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.ForwardList = void 0;
var Repeater_1 = require("../internal/iterator/disposable/Repeater");
var ForOfAdaptor_1 = require("../internal/iterator/disposable/ForOfAdaptor");
var Vector_1 = require("./Vector");
var ErrorGenerator_1 = require("../internal/exception/ErrorGenerator");
var global_1 = require("../iterator/global");
var comparators_1 = require("../functional/comparators");
var sorting_1 = require("../algorithm/sorting");
/**
* Singly Linked List.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var ForwardList = /** @class */ (function () {
function ForwardList() {
var e_1, _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
this.ptr_ = { value: this };
this.end_ = ForwardList.Iterator.create(this.ptr_, null);
this.before_begin_ = ForwardList.Iterator.create(this.ptr_, this.end_);
this.size_ = 0;
if (args.length === 1 && args[0] instanceof Array) {
var array = args[0];
var it = this.before_begin();
try {
for (var array_1 = __values(array), array_1_1 = array_1.next(); !array_1_1.done; array_1_1 = array_1.next()) {
var val = array_1_1.value;
it = this.insert_after(it, val);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (array_1_1 && !array_1_1.done && (_a = array_1.return)) _a.call(array_1);
}
finally { if (e_1) throw e_1.error; }
}
}
else if (args.length === 1 && args[0] instanceof ForwardList) {
this.assign(args[0].begin(), args[0].end());
}
else if (args.length === 2)
this.assign(args[0], args[1]);
}
ForwardList.prototype.assign = function (first, last) {
this.clear();
this.insert_after(this.before_begin_, first, last);
};
/**
* @inheritDoc
*/
ForwardList.prototype.clear = function () {
ForwardList.Iterator._Set_next(this.before_begin_, this.end_);
this.size_ = 0;
};
/* ===============================================================
ACCESSORS
=============================================================== */
/**
* @inheritDoc
*/
ForwardList.prototype.size = function () {
return this.size_;
};
/**
* @inheritDoc
*/
ForwardList.prototype.empty = function () {
return this.size_ === 0;
};
ForwardList.prototype.front = function (val) {
var it = this.begin();
if (arguments.length === 0)
return it.value;
else
it.value = val;
};
/**
* Iterator to before beginning.
*
* @return Iterator to the before beginning.
*/
ForwardList.prototype.before_begin = function () {
return this.before_begin_;
};
/**
* @inheritDoc
*/
ForwardList.prototype.begin = function () {
return this.before_begin_.next();
};
/**
* @inheritDoc
*/
ForwardList.prototype.end = function () {
return this.end_;
};
/**
* @inheritDoc
*/
ForwardList.prototype[Symbol.iterator] = function () {
return new ForOfAdaptor_1.ForOfAdaptor(this.begin(), this.end());
};
/* ===============================================================
ELEMENTS I/O
- INSERT
- ERASE
==================================================================
INSERT
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.push_front = function (val) {
this.insert_after(this.before_begin_, val);
};
ForwardList.prototype.insert_after = function (pos) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
var ret;
// BRANCHES
if (args.length === 1)
ret = this._Insert_by_repeating_val(pos, 1, args[0]);
else if (typeof args[0] === "number")
ret = this._Insert_by_repeating_val(pos, args[0], args[1]);
else
ret = this._Insert_by_range(pos, args[0], args[1]);
// RETURNS
return ret;
};
ForwardList.prototype._Insert_by_repeating_val = function (pos, n, val) {
var first = new Repeater_1.Repeater(0, val);
var last = new Repeater_1.Repeater(n);
return this._Insert_by_range(pos, first, last);
};
ForwardList.prototype._Insert_by_range = function (pos, first, last) {
var nodes = [];
var count = 0;
for (; !first.equals(last); first = first.next()) {
var node = ForwardList.Iterator.create(this.ptr_, null, first.value);
nodes.push(node);
++count;
}
if (count === 0)
return pos;
for (var i = 0; i < count - 1; ++i)
ForwardList.Iterator._Set_next(nodes[i], nodes[i + 1]);
ForwardList.Iterator._Set_next(nodes[nodes.length - 1], pos.next());
ForwardList.Iterator._Set_next(pos, nodes[0]);
this.size_ += count;
return nodes[nodes.length - 1];
};
/* ---------------------------------------------------------------
ERASE
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.pop_front = function () {
this.erase_after(this.before_begin());
};
ForwardList.prototype.erase_after = function (first, last) {
if (last === void 0) { last = (0, global_1.advance)(first, 2); }
// SHRINK SIZE
this.size_ -= Math.max(0, (0, global_1.distance)(first, last) - 1);
// RE-CONNECT
ForwardList.Iterator._Set_next(first, last);
return last;
};
/* ===============================================================
ALGORITHMS
- UNIQUE & REMOVE(_IF)
- MERGE & SPLICE
- SORT
==================================================================
UNIQUE & REMOVE(_IF)
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.unique = function (binary_pred) {
if (binary_pred === void 0) { binary_pred = comparators_1.equal_to; }
for (var it = this.begin().next(); !it.equals(this.end()); it = it.next()) {
var next_it = it.next();
if (next_it.equals(this.end()))
break;
if (binary_pred(it.value, next_it.value))
this.erase_after(it);
}
};
/**
* @inheritDoc
*/
ForwardList.prototype.remove = function (val) {
return this.remove_if(function (elem) { return (0, comparators_1.equal_to)(elem, val); });
};
/**
* @inheritDoc
*/
ForwardList.prototype.remove_if = function (pred) {
var count = 0;
for (var it = this.before_begin(); !it.next().equals(this.end()); it = it.next())
if (pred(it.next().value) === true) {
ForwardList.Iterator._Set_next(it, it.next().next());
++count;
}
this.size_ -= count;
};
/* ---------------------------------------------------------------
MERGE & SPLICE
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.merge = function (from, comp) {
if (comp === void 0) { comp = comparators_1.less; }
if (this === from)
return;
var it = this.before_begin();
while (from.empty() === false) {
var value = from.begin().value;
while (!it.next().equals(this.end()) &&
comp(it.next().value, value))
it = it.next();
this.splice_after(it, from, from.before_begin());
}
};
ForwardList.prototype.splice_after = function (pos, from, first_before, last) {
if (first_before === void 0) { first_before = from.before_begin(); }
if (last === void 0) { last = first_before.next().next(); }
// DEFAULT PARAMETERS
if (last === null)
last = from.end();
// INSERT & ERASE
this.insert_after(pos, first_before.next(), last);
from.erase_after(first_before, last);
};
/* ---------------------------------------------------------------
SORT
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.sort = function (comp) {
if (comp === void 0) { comp = comparators_1.less; }
var vec = new Vector_1.Vector(this.begin(), this.end());
(0, sorting_1.sort)(vec.begin(), vec.end(), comp);
this.assign(vec.begin(), vec.end());
};
/**
* @inheritDoc
*/
ForwardList.prototype.reverse = function () {
var vec = new Vector_1.Vector(this.begin(), this.end());
this.assign(vec.rbegin(), vec.rend());
};
/* ---------------------------------------------------------------
UTILITIES
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
ForwardList.prototype.swap = function (obj) {
var _a, _b, _c, _d, _e;
// SIZE AND NODES
_a = __read([obj.size_, this.size_], 2), this.size_ = _a[0], obj.size_ = _a[1];
_b = __read([
obj.before_begin_,
this.before_begin_,
], 2), this.before_begin_ = _b[0], obj.before_begin_ = _b[1];
_c = __read([obj.end_, this.end_], 2), this.end_ = _c[0], obj.end_ = _c[1];
// POINTER OF THE SOURCE
_d = __read([obj.ptr_, this.ptr_], 2), this.ptr_ = _d[0], obj.ptr_ = _d[1];
_e = __read([obj.ptr_.value, this.ptr_.value], 2), this.ptr_.value = _e[0], obj.ptr_.value = _e[1];
};
/**
* Native function for `JSON.stringify()`.
*
* @return An array containing children elements.
*/
ForwardList.prototype.toJSON = function () {
var e_2, _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_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
return ret;
};
return ForwardList;
}());
exports.ForwardList = ForwardList;
/**
*
*/
(function (ForwardList) {
/**
* Iterator of {@link ForwardList}
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Iterator = /** @class */ (function () {
/* ---------------------------------------------------------------
CONSTRUCTORS
--------------------------------------------------------------- */
function Iterator(source, next, value) {
this.source_ptr_ = source;
this.next_ = next;
this.value_ = value;
}
/**
* @internal
*/
Iterator.create = function (source, next, value) {
return new Iterator(source, next, value);
};
/* ---------------------------------------------------------------
ACCESSORS
--------------------------------------------------------------- */
/**
* Get source container.
*
* @return The source container.
*/
Iterator.prototype.source = function () {
return this.source_ptr_.value;
};
Object.defineProperty(Iterator.prototype, "value", {
/**
* @inheritDoc
*/
get: function () {
this._Try_value();
return this.value_;
},
/**
* @inheritDoc
*/
set: function (val) {
this._Try_value();
this.value_ = val;
},
enumerable: false,
configurable: true
});
Iterator.prototype._Try_value = function () {
if (this.value_ === undefined) {
var source = this.source();
if (this.equals(source.end()) === true)
throw ErrorGenerator_1.ErrorGenerator.iterator_end_value(source);
else if (this.equals(source.before_begin()) === true)
throw ErrorGenerator_1.ErrorGenerator.iterator_end_value(source, "before_begin");
}
};
/* ---------------------------------------------------------
MOVERS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
Iterator.prototype.next = function () {
return this.next_;
};
/**
* @inheritDoc
*/
Iterator.prototype.equals = function (obj) {
return this === obj;
};
/**
* @internal
*/
Iterator._Set_next = function (it, next) {
it.next_ = next;
};
return Iterator;
}());
ForwardList.Iterator = Iterator;
})(ForwardList = exports.ForwardList || (exports.ForwardList = {}));
exports.ForwardList = ForwardList;
//# sourceMappingURL=ForwardList.js.map
-159
View File
@@ -1,159 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { UniqueMap } from "../base/container/UniqueMap";
import { IHashMap } from "../base/container/IHashMap";
import { MapElementList } from "../internal/container/associative/MapElementList";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { IPair } from "../utility/IPair";
import { Pair } from "../utility/Pair";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { Hasher } from "../internal/functional/Hasher";
/**
* Unique-key Map based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class HashMap<Key, T> extends UniqueMap<Key, T, HashMap<Key, T>, HashMap.Iterator<Key, T>, HashMap.ReverseIterator<Key, T>> implements IHashMap<Key, T, true, HashMap<Key, T>> {
private buckets_;
/**
* Default Constructor.
*
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(items: IPair<Key, T>[], hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: HashMap<Key, T>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(first: Readonly<IForwardIterator<IPair<Key, T>>>, last: Readonly<IForwardIterator<IPair<Key, T>>>, hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: HashMap<Key, T>): void;
/**
* @inheritDoc
*/
find(key: Key): HashMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
begin(): HashMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
begin(index: number): HashMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
end(): HashMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
end(index: number): HashMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
rbegin(): HashMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rbegin(index: number): HashMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rend(): HashMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rend(index: number): HashMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
bucket_count(): number;
/**
* @inheritDoc
*/
bucket_size(index: number): number;
/**
* @inheritDoc
*/
load_factor(): number;
/**
* @inheritDoc
*/
hash_function(): Hasher<Key>;
/**
* @inheritDoc
*/
key_eq(): BinaryPredicator<Key>;
/**
* @inheritDoc
*/
bucket(key: Key): number;
/**
* @inheritDoc
*/
max_load_factor(): number;
/**
* @inheritDoc
*/
max_load_factor(z: number): void;
/**
* @inheritDoc
*/
reserve(n: number): void;
/**
* @inheritDoc
*/
rehash(n: number): void;
/**
* @inheritDoc
*/
emplace(key: Key, val: T): Pair<HashMap.Iterator<Key, T>, boolean>;
/**
* @inheritDoc
*/
emplace_hint(hint: HashMap.Iterator<Key, T>, key: Key, val: T): HashMap.Iterator<Key, T>;
protected _Handle_insert(first: HashMap.Iterator<Key, T>, last: HashMap.Iterator<Key, T>): void;
protected _Handle_erase(first: HashMap.Iterator<Key, T>, last: HashMap.Iterator<Key, T>): void;
}
/**
*
*/
export declare namespace HashMap {
/**
* Iterator of {@link HashMap}
*/
type Iterator<Key, T> = MapElementList.Iterator<Key, T, true, HashMap<Key, T>>;
/**
* Reverse iterator of {@link HashMap}
*/
type ReverseIterator<Key, T> = MapElementList.ReverseIterator<Key, T, true, HashMap<Key, T>>;
const Iterator: typeof MapElementList.Iterator;
const ReverseIterator: typeof MapElementList.ReverseIterator;
}
-249
View File
@@ -1,249 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.HashMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var UniqueMap_1 = require("../base/container/UniqueMap");
var IHashContainer_1 = require("../internal/container/associative/IHashContainer");
var MapElementList_1 = require("../internal/container/associative/MapElementList");
var MapHashBuckets_1 = require("../internal/hash/MapHashBuckets");
var Entry_1 = require("../utility/Entry");
var Pair_1 = require("../utility/Pair");
/**
* Unique-key Map based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var HashMap = /** @class */ (function (_super) {
__extends(HashMap, _super);
function HashMap() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new MapElementList_1.MapElementList(thisArg); }) || this;
IHashContainer_1.IHashContainer.construct.apply(IHashContainer_1.IHashContainer, __spreadArray([_this,
HashMap,
function (hash, pred) {
_this.buckets_ = new MapHashBuckets_1.MapHashBuckets(_this, hash, pred);
}], __read(args), false));
return _this;
}
/* ---------------------------------------------------------
ASSIGN & CLEAR
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMap.prototype.clear = function () {
this.buckets_.clear();
_super.prototype.clear.call(this);
};
/**
* @inheritDoc
*/
HashMap.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
MapElementList_1.MapElementList._Swap_associative(this.data_, obj.data_);
// SWAP BUCKETS
MapHashBuckets_1.MapHashBuckets._Swap_source(this.buckets_, obj.buckets_);
_b = __read([obj.buckets_, this.buckets_], 2), this.buckets_ = _b[0], obj.buckets_ = _b[1];
};
/* =========================================================
ACCESSORS
- MEMBER
- HASH
============================================================
MEMBER
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMap.prototype.find = function (key) {
return this.buckets_.find(key);
};
HashMap.prototype.begin = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.begin.call(this);
else
return this.buckets_.at(index)[0];
};
HashMap.prototype.end = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.end.call(this);
else {
var bucket = this.buckets_.at(index);
return bucket[bucket.length - 1].next();
}
};
HashMap.prototype.rbegin = function (index) {
if (index === void 0) { index = null; }
return this.end(index).reverse();
};
HashMap.prototype.rend = function (index) {
if (index === void 0) { index = null; }
return this.begin(index).reverse();
};
/* ---------------------------------------------------------
HASH
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMap.prototype.bucket_count = function () {
return this.buckets_.length();
};
/**
* @inheritDoc
*/
HashMap.prototype.bucket_size = function (index) {
return this.buckets_.at(index).length;
};
/**
* @inheritDoc
*/
HashMap.prototype.load_factor = function () {
return this.buckets_.load_factor();
};
/**
* @inheritDoc
*/
HashMap.prototype.hash_function = function () {
return this.buckets_.hash_function();
};
/**
* @inheritDoc
*/
HashMap.prototype.key_eq = function () {
return this.buckets_.key_eq();
};
/**
* @inheritDoc
*/
HashMap.prototype.bucket = function (key) {
return this.hash_function()(key) % this.buckets_.length();
};
HashMap.prototype.max_load_factor = function (z) {
if (z === void 0) { z = null; }
return this.buckets_.max_load_factor(z);
};
/**
* @inheritDoc
*/
HashMap.prototype.reserve = function (n) {
this.buckets_.reserve(n);
};
/**
* @inheritDoc
*/
HashMap.prototype.rehash = function (n) {
this.buckets_.rehash(n);
};
/* =========================================================
ELEMENTS I/O
- INSERT
- POST-PROCESS
============================================================
INSERT
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMap.prototype.emplace = function (key, val) {
// TEST WHETHER EXIST
var it = this.find(key);
if (it.equals(this.end()) === false)
return new Pair_1.Pair(it, false);
// INSERT
this.data_.push(new Entry_1.Entry(key, val));
it = it.prev();
// POST-PROCESS
this._Handle_insert(it, it.next());
return new Pair_1.Pair(it, true);
};
/**
* @inheritDoc
*/
HashMap.prototype.emplace_hint = function (hint, key, val) {
// FIND DUPLICATED KEY
var it = this.find(key);
if (it.equals(this.end()) === true) {
// INSERT
it = this.data_.insert(hint, new Entry_1.Entry(key, val));
// POST-PROCESS
this._Handle_insert(it, it.next());
}
return it;
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
HashMap.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.insert(first);
};
HashMap.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.erase(first);
};
return HashMap;
}(UniqueMap_1.UniqueMap));
exports.HashMap = HashMap;
/**
*
*/
(function (HashMap) {
// BODY
HashMap.Iterator = MapElementList_1.MapElementList.Iterator;
HashMap.ReverseIterator = MapElementList_1.MapElementList.ReverseIterator;
})(HashMap = exports.HashMap || (exports.HashMap = {}));
exports.HashMap = HashMap;
//# sourceMappingURL=HashMap.js.map
-164
View File
@@ -1,164 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { MultiMap } from "../base/container/MultiMap";
import { IHashMap } from "../base/container/IHashMap";
import { MapElementList } from "../internal/container/associative/MapElementList";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { IPair } from "../utility/IPair";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { Hasher } from "../internal/functional/Hasher";
/**
* Multiple-key Map based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class HashMultiMap<Key, T> extends MultiMap<Key, T, HashMultiMap<Key, T>, HashMultiMap.Iterator<Key, T>, HashMultiMap.ReverseIterator<Key, T>> implements IHashMap<Key, T, false, HashMultiMap<Key, T>> {
private buckets_;
/**
* Default Constructor.
*
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(items: IPair<Key, T>[], hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: HashMultiMap<Key, T>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(first: Readonly<IForwardIterator<IPair<Key, T>>>, last: Readonly<IForwardIterator<IPair<Key, T>>>, hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: HashMultiMap<Key, T>): void;
/**
* @inheritDoc
*/
find(key: Key): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
count(key: Key): number;
/**
* @inheritDoc
*/
begin(): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
begin(index: number): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
end(): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
end(index: number): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
rbegin(): HashMultiMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rbegin(index: number): HashMultiMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rend(): HashMultiMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
rend(index: number): HashMultiMap.ReverseIterator<Key, T>;
/**
* @inheritDoc
*/
bucket_count(): number;
/**
* @inheritDoc
*/
bucket_size(index: number): number;
/**
* @inheritDoc
*/
load_factor(): number;
/**
* @inheritDoc
*/
hash_function(): Hasher<Key>;
/**
* @inheritDoc
*/
key_eq(): BinaryPredicator<Key>;
/**
* @inheritDoc
*/
bucket(key: Key): number;
/**
* @inheritDoc
*/
max_load_factor(): number;
/**
* @inheritDoc
*/
max_load_factor(z: number): void;
/**
* @inheritDoc
*/
reserve(n: number): void;
/**
* @inheritDoc
*/
rehash(n: number): void;
protected _Key_eq(x: Key, y: Key): boolean;
/**
* @inheritDoc
*/
emplace(key: Key, val: T): HashMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
emplace_hint(hint: HashMultiMap.Iterator<Key, T>, key: Key, val: T): HashMultiMap.Iterator<Key, T>;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<IPair<Key, T>, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected _Handle_insert(first: HashMultiMap.Iterator<Key, T>, last: HashMultiMap.Iterator<Key, T>): void;
protected _Handle_erase(first: HashMultiMap.Iterator<Key, T>, last: HashMultiMap.Iterator<Key, T>): void;
}
/**
*
*/
export declare namespace HashMultiMap {
/**
* Iterator of {@link HashMultiMap}
*/
type Iterator<Key, T> = MapElementList.Iterator<Key, T, false, HashMultiMap<Key, T>>;
/**
* Reverse iterator of {@link HashMultiMap}
*/
type ReverseIterator<Key, T> = MapElementList.ReverseIterator<Key, T, false, HashMultiMap<Key, T>>;
const Iterator: typeof MapElementList.Iterator;
const ReverseIterator: typeof MapElementList.ReverseIterator;
}
-300
View File
@@ -1,300 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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));
};
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.HashMultiMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var MultiMap_1 = require("../base/container/MultiMap");
var IHashContainer_1 = require("../internal/container/associative/IHashContainer");
var MapElementList_1 = require("../internal/container/associative/MapElementList");
var MapHashBuckets_1 = require("../internal/hash/MapHashBuckets");
var NativeArrayIterator_1 = require("../internal/iterator/disposable/NativeArrayIterator");
var Entry_1 = require("../utility/Entry");
/**
* Multiple-key Map based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var HashMultiMap = /** @class */ (function (_super) {
__extends(HashMultiMap, _super);
function HashMultiMap() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new MapElementList_1.MapElementList(thisArg); }) || this;
IHashContainer_1.IHashContainer.construct.apply(IHashContainer_1.IHashContainer, __spreadArray([_this,
HashMultiMap,
function (hash, pred) {
_this.buckets_ = new MapHashBuckets_1.MapHashBuckets(_this, hash, pred);
}], __read(args), false));
return _this;
}
/* ---------------------------------------------------------
ASSIGN & CLEAR
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiMap.prototype.clear = function () {
this.buckets_.clear();
_super.prototype.clear.call(this);
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
MapElementList_1.MapElementList._Swap_associative(this.data_, obj.data_);
// SWAP BUCKETS
MapHashBuckets_1.MapHashBuckets._Swap_source(this.buckets_, obj.buckets_);
_b = __read([obj.buckets_, this.buckets_], 2), this.buckets_ = _b[0], obj.buckets_ = _b[1];
};
/* =========================================================
ACCESSORS
- MEMBER
- HASH
============================================================
MEMBER
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiMap.prototype.find = function (key) {
return this.buckets_.find(key);
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.count = function (key) {
var e_1, _a;
// FIND MATCHED BUCKET
var index = this.bucket(key);
var bucket = this.buckets_.at(index);
// ITERATE THE BUCKET
var cnt = 0;
try {
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
var it = bucket_1_1.value;
if (this.buckets_.key_eq()(it.first, key))
++cnt;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
}
finally { if (e_1) throw e_1.error; }
}
return cnt;
};
HashMultiMap.prototype.begin = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.begin.call(this);
else
return this.buckets_.at(index)[0];
};
HashMultiMap.prototype.end = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.end.call(this);
else {
var bucket = this.buckets_.at(index);
return bucket[bucket.length - 1].next();
}
};
HashMultiMap.prototype.rbegin = function (index) {
if (index === void 0) { index = null; }
return this.end(index).reverse();
};
HashMultiMap.prototype.rend = function (index) {
if (index === void 0) { index = null; }
return this.begin(index).reverse();
};
/* ---------------------------------------------------------
HASH
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiMap.prototype.bucket_count = function () {
return this.buckets_.length();
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.bucket_size = function (index) {
return this.buckets_.at(index).length;
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.load_factor = function () {
return this.buckets_.load_factor();
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.hash_function = function () {
return this.buckets_.hash_function();
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.key_eq = function () {
return this.buckets_.key_eq();
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.bucket = function (key) {
return this.hash_function()(key) % this.buckets_.length();
};
HashMultiMap.prototype.max_load_factor = function (z) {
if (z === void 0) { z = null; }
return this.buckets_.max_load_factor(z);
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.reserve = function (n) {
this.buckets_.reserve(n);
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.rehash = function (n) {
if (n <= this.bucket_count())
return;
this.buckets_.rehash(n);
};
HashMultiMap.prototype._Key_eq = function (x, y) {
return this.key_eq()(x, y);
};
/* =========================================================
ELEMENTS I/O
- INSERT
- POST-PROCESS
============================================================
INSERT
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiMap.prototype.emplace = function (key, val) {
// INSERT
var it = this.data_.insert(this.data_.end(), new Entry_1.Entry(key, val));
this._Handle_insert(it, it.next()); // POST-PROCESS
return it;
};
/**
* @inheritDoc
*/
HashMultiMap.prototype.emplace_hint = function (hint, key, val) {
// INSERT
var it = this.data_.insert(hint, new Entry_1.Entry(key, val));
// POST-PROCESS
this._Handle_insert(it, it.next());
return it;
};
HashMultiMap.prototype._Insert_by_range = function (first, last) {
//--------
// INSERTIONS
//--------
// PRELIMINARIES
var entries = [];
for (var it = first; !it.equals(last); it = it.next())
entries.push(new Entry_1.Entry(it.value.first, it.value.second));
// INSERT ELEMENTS
var my_first = this.data_.insert(this.data_.end(), new NativeArrayIterator_1.NativeArrayIterator(entries, 0), new NativeArrayIterator_1.NativeArrayIterator(entries, entries.length));
//--------
// HASHING INSERTED ITEMS
//--------
// IF NEEDED, HASH_BUCKET TO HAVE SUITABLE SIZE
if (this.size() > this.buckets_.capacity())
this.reserve(Math.max(this.size(), this.buckets_.capacity() * 2));
// POST-PROCESS
this._Handle_insert(my_first, this.end());
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
HashMultiMap.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.insert(first);
};
HashMultiMap.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.erase(first);
};
return HashMultiMap;
}(MultiMap_1.MultiMap));
exports.HashMultiMap = HashMultiMap;
/**
*
*/
(function (HashMultiMap) {
// BODY
HashMultiMap.Iterator = MapElementList_1.MapElementList.Iterator;
HashMultiMap.ReverseIterator = MapElementList_1.MapElementList.ReverseIterator;
})(HashMultiMap = exports.HashMultiMap || (exports.HashMultiMap = {}));
exports.HashMultiMap = HashMultiMap;
//# sourceMappingURL=HashMultiMap.js.map
-157
View File
@@ -1,157 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { MultiSet } from "../base/container/MultiSet";
import { IHashSet } from "../base/container/IHashSet";
import { SetElementList } from "../internal/container/associative/SetElementList";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { Hasher } from "../internal/functional/Hasher";
/**
* Multiple-key Set based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class HashMultiSet<Key> extends MultiSet<Key, HashMultiSet<Key>, HashMultiSet.Iterator<Key>, HashMultiSet.ReverseIterator<Key>> implements IHashSet<Key, false, HashMultiSet<Key>> {
private buckets_;
/**
* Default Constructor.
*
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(items: Key[], hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: HashMultiSet<Key>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(first: Readonly<IForwardIterator<Key>>, last: Readonly<IForwardIterator<Key>>, hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: HashMultiSet<Key>): void;
/**
* @inheritDoc
*/
find(key: Key): HashMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
count(key: Key): number;
/**
* @inheritDoc
*/
begin(): HashMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
begin(index: number): HashMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
end(): HashMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
end(index: number): HashMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
rbegin(): HashMultiSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rbegin(index: number): HashMultiSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rend(): HashMultiSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rend(index: number): HashMultiSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
bucket_count(): number;
/**
* @inheritDoc
*/
bucket_size(n: number): number;
/**
* @inheritDoc
*/
load_factor(): number;
/**
* @inheritDoc
*/
hash_function(): Hasher<Key>;
/**
* @inheritDoc
*/
key_eq(): BinaryPredicator<Key>;
/**
* @inheritDoc
*/
bucket(key: Key): number;
/**
* @inheritDoc
*/
max_load_factor(): number;
/**
* @inheritDoc
*/
max_load_factor(z: number): void;
/**
* @inheritDoc
*/
reserve(n: number): void;
/**
* @inheritDoc
*/
rehash(n: number): void;
protected _Key_eq(x: Key, y: Key): boolean;
protected _Insert_by_key(key: Key): HashMultiSet.Iterator<Key>;
protected _Insert_by_hint(hint: HashMultiSet.Iterator<Key>, key: Key): HashMultiSet.Iterator<Key>;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<Key, InputIterator>>>(first: InputIterator, last: InputIterator): void;
protected _Handle_insert(first: HashMultiSet.Iterator<Key>, last: HashMultiSet.Iterator<Key>): void;
protected _Handle_erase(first: HashMultiSet.Iterator<Key>, last: HashMultiSet.Iterator<Key>): void;
}
/**
*
*/
export declare namespace HashMultiSet {
/**
* Iterator of {@link HashMultiSet}
*/
type Iterator<Key> = SetElementList.Iterator<Key, false, HashMultiSet<Key>>;
/**
* Reverse iterator of {@link HashMultiSet}
*/
type ReverseIterator<Key> = SetElementList.ReverseIterator<Key, false, HashMultiSet<Key>>;
const Iterator: typeof SetElementList.Iterator;
const ReverseIterator: typeof SetElementList.ReverseIterator;
}
-282
View File
@@ -1,282 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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));
};
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.HashMultiSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var MultiSet_1 = require("../base/container/MultiSet");
var IHashContainer_1 = require("../internal/container/associative/IHashContainer");
var SetElementList_1 = require("../internal/container/associative/SetElementList");
var SetHashBuckets_1 = require("../internal/hash/SetHashBuckets");
/**
* Multiple-key Set based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var HashMultiSet = /** @class */ (function (_super) {
__extends(HashMultiSet, _super);
function HashMultiSet() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new SetElementList_1.SetElementList(thisArg); }) || this;
IHashContainer_1.IHashContainer.construct.apply(IHashContainer_1.IHashContainer, __spreadArray([_this,
HashMultiSet,
function (hash, pred) {
_this.buckets_ = new SetHashBuckets_1.SetHashBuckets(_this, hash, pred);
}], __read(args), false));
return _this;
}
/* ---------------------------------------------------------
ASSIGN & CLEAR
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiSet.prototype.clear = function () {
this.buckets_.clear();
_super.prototype.clear.call(this);
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
SetElementList_1.SetElementList._Swap_associative(this.data_, obj.data_);
// SWAP BUCKETS
SetHashBuckets_1.SetHashBuckets._Swap_source(this.buckets_, obj.buckets_);
_b = __read([obj.buckets_, this.buckets_], 2), this.buckets_ = _b[0], obj.buckets_ = _b[1];
};
/* =========================================================
ACCESSORS
- MEMBER
- HASH
============================================================
MEMBER
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiSet.prototype.find = function (key) {
return this.buckets_.find(key);
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.count = function (key) {
var e_1, _a;
// FIND MATCHED BUCKET
var index = this.bucket(key);
var bucket = this.buckets_.at(index);
// ITERATE THE BUCKET
var cnt = 0;
try {
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
var it = bucket_1_1.value;
if (this.buckets_.key_eq()(it.value, key))
++cnt;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
}
finally { if (e_1) throw e_1.error; }
}
return cnt;
};
HashMultiSet.prototype.begin = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.begin.call(this);
else
return this.buckets_.at(index)[0];
};
HashMultiSet.prototype.end = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.end.call(this);
else {
var bucket = this.buckets_.at(index);
return bucket[bucket.length - 1].next();
}
};
HashMultiSet.prototype.rbegin = function (index) {
if (index === void 0) { index = null; }
return this.end(index).reverse();
};
HashMultiSet.prototype.rend = function (index) {
if (index === void 0) { index = null; }
return this.begin(index).reverse();
};
/* ---------------------------------------------------------
HASH
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashMultiSet.prototype.bucket_count = function () {
return this.buckets_.length();
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.bucket_size = function (n) {
return this.buckets_.at(n).length;
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.load_factor = function () {
return this.buckets_.load_factor();
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.hash_function = function () {
return this.buckets_.hash_function();
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.key_eq = function () {
return this.buckets_.key_eq();
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.bucket = function (key) {
return this.hash_function()(key) % this.buckets_.length();
};
HashMultiSet.prototype.max_load_factor = function (z) {
if (z === void 0) { z = null; }
return this.buckets_.max_load_factor(z);
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.reserve = function (n) {
this.buckets_.rehash(Math.ceil(n * this.max_load_factor()));
};
/**
* @inheritDoc
*/
HashMultiSet.prototype.rehash = function (n) {
if (n <= this.bucket_count())
return;
this.buckets_.rehash(n);
};
HashMultiSet.prototype._Key_eq = function (x, y) {
return this.key_eq()(x, y);
};
/* =========================================================
ELEMENTS I/O
- INSERT
- POST-PROCESS
============================================================
INSERT
--------------------------------------------------------- */
HashMultiSet.prototype._Insert_by_key = function (key) {
// INSERT
var it = this.data_.insert(this.data_.end(), key);
this._Handle_insert(it, it.next()); // POST-PROCESS
return it;
};
HashMultiSet.prototype._Insert_by_hint = function (hint, key) {
// INSERT
var it = this.data_.insert(hint, key);
// POST-PROCESS
this._Handle_insert(it, it.next());
return it;
};
HashMultiSet.prototype._Insert_by_range = function (first, last) {
// INSERT ELEMENTS
var my_first = this.data_.insert(this.data_.end(), first, last);
// IF NEEDED, HASH_BUCKET TO HAVE SUITABLE SIZE
if (this.size() > this.buckets_.capacity())
this.reserve(Math.max(this.size(), this.buckets_.capacity() * 2));
// POST-PROCESS
this._Handle_insert(my_first, this.end());
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
HashMultiSet.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.insert(first);
};
HashMultiSet.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.erase(first);
};
return HashMultiSet;
}(MultiSet_1.MultiSet));
exports.HashMultiSet = HashMultiSet;
/**
*
*/
(function (HashMultiSet) {
// BODY
HashMultiSet.Iterator = SetElementList_1.SetElementList.Iterator;
HashMultiSet.ReverseIterator = SetElementList_1.SetElementList.ReverseIterator;
})(HashMultiSet = exports.HashMultiSet || (exports.HashMultiSet = {}));
exports.HashMultiSet = HashMultiSet;
//# sourceMappingURL=HashMultiSet.js.map
-152
View File
@@ -1,152 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { UniqueSet } from "../base/container/UniqueSet";
import { IHashSet } from "../base/container/IHashSet";
import { SetElementList } from "../internal/container/associative/SetElementList";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { Pair } from "../utility/Pair";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { Hasher } from "../internal/functional/Hasher";
/**
* Unique-key Set based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class HashSet<Key> extends UniqueSet<Key, HashSet<Key>, HashSet.Iterator<Key>, HashSet.ReverseIterator<Key>> implements IHashSet<Key, true, HashSet<Key>> {
private buckets_;
/**
* Default Constructor.
*
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(items: Key[], hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: HashSet<Key>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param hash An unary function returns hash code. Default is {hash}.
* @param equal A binary function predicates two arguments are equal. Default is {@link equal_to}.
*/
constructor(first: Readonly<IForwardIterator<Key>>, last: Readonly<IForwardIterator<Key>>, hash?: Hasher<Key>, equal?: BinaryPredicator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: HashSet<Key>): void;
/**
* @inheritDoc
*/
find(key: Key): HashSet.Iterator<Key>;
/**
* @inheritDoc
*/
begin(): HashSet.Iterator<Key>;
/**
* @inheritDoc
*/
begin(index: number): HashSet.Iterator<Key>;
/**
* @inheritDoc
*/
end(): HashSet.Iterator<Key>;
/**
* @inheritDoc
*/
end(index: number): HashSet.Iterator<Key>;
/**
* @inheritDoc
*/
rbegin(): HashSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rbegin(index: number): HashSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rend(): HashSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
rend(index: number): HashSet.ReverseIterator<Key>;
/**
* @inheritDoc
*/
bucket_count(): number;
/**
* @inheritDoc
*/
bucket_size(n: number): number;
/**
* @inheritDoc
*/
load_factor(): number;
/**
* @inheritDoc
*/
hash_function(): Hasher<Key>;
/**
* @inheritDoc
*/
key_eq(): BinaryPredicator<Key>;
/**
* @inheritDoc
*/
bucket(key: Key): number;
/**
* @inheritDoc
*/
max_load_factor(): number;
/**
* @inheritDoc
*/
max_load_factor(z: number): void;
/**
* @inheritDoc
*/
reserve(n: number): void;
/**
* @inheritDoc
*/
rehash(n: number): void;
protected _Insert_by_key(key: Key): Pair<HashSet.Iterator<Key>, boolean>;
protected _Insert_by_hint(hint: HashSet.Iterator<Key>, key: Key): HashSet.Iterator<Key>;
protected _Handle_insert(first: HashSet.Iterator<Key>, last: HashSet.Iterator<Key>): void;
protected _Handle_erase(first: HashSet.Iterator<Key>, last: HashSet.Iterator<Key>): void;
}
/**
*
*/
export declare namespace HashSet {
/**
* Iterator of {@link HashSet}
*/
type Iterator<Key> = SetElementList.Iterator<Key, true, HashSet<Key>>;
/**
* Reverse iterator of {@link HashSet}
*/
type ReverseIterator<Key> = SetElementList.ReverseIterator<Key, true, HashSet<Key>>;
const Iterator: typeof SetElementList.Iterator;
const ReverseIterator: typeof SetElementList.ReverseIterator;
}
-243
View File
@@ -1,243 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.HashSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var UniqueSet_1 = require("../base/container/UniqueSet");
var IHashContainer_1 = require("../internal/container/associative/IHashContainer");
var SetElementList_1 = require("../internal/container/associative/SetElementList");
var SetHashBuckets_1 = require("../internal/hash/SetHashBuckets");
var Pair_1 = require("../utility/Pair");
/**
* Unique-key Set based on Hash buckets.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var HashSet = /** @class */ (function (_super) {
__extends(HashSet, _super);
function HashSet() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new SetElementList_1.SetElementList(thisArg); }) || this;
IHashContainer_1.IHashContainer.construct.apply(IHashContainer_1.IHashContainer, __spreadArray([_this,
HashSet,
function (hash, pred) {
_this.buckets_ = new SetHashBuckets_1.SetHashBuckets(_this, hash, pred);
}], __read(args), false));
return _this;
}
/* ---------------------------------------------------------
ASSIGN & CLEAR
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashSet.prototype.clear = function () {
this.buckets_.clear();
_super.prototype.clear.call(this);
};
/**
* @inheritDoc
*/
HashSet.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
SetElementList_1.SetElementList._Swap_associative(this.data_, obj.data_);
// SWAP BUCKETS
SetHashBuckets_1.SetHashBuckets._Swap_source(this.buckets_, obj.buckets_);
_b = __read([obj.buckets_, this.buckets_], 2), this.buckets_ = _b[0], obj.buckets_ = _b[1];
};
/* =========================================================
ACCESSORS
- MEMBER
- HASH
============================================================
MEMBER
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashSet.prototype.find = function (key) {
return this.buckets_.find(key);
};
HashSet.prototype.begin = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.begin.call(this);
else
return this.buckets_.at(index)[0];
};
HashSet.prototype.end = function (index) {
if (index === void 0) { index = null; }
if (index === null)
return _super.prototype.end.call(this);
else {
var bucket = this.buckets_.at(index);
return bucket[bucket.length - 1].next();
}
};
HashSet.prototype.rbegin = function (index) {
if (index === void 0) { index = null; }
return this.end(index).reverse();
};
HashSet.prototype.rend = function (index) {
if (index === void 0) { index = null; }
return this.begin(index).reverse();
};
/* ---------------------------------------------------------
HASH
--------------------------------------------------------- */
/**
* @inheritDoc
*/
HashSet.prototype.bucket_count = function () {
return this.buckets_.length();
};
/**
* @inheritDoc
*/
HashSet.prototype.bucket_size = function (n) {
return this.buckets_.at(n).length;
};
/**
* @inheritDoc
*/
HashSet.prototype.load_factor = function () {
return this.buckets_.load_factor();
};
/**
* @inheritDoc
*/
HashSet.prototype.hash_function = function () {
return this.buckets_.hash_function();
};
/**
* @inheritDoc
*/
HashSet.prototype.key_eq = function () {
return this.buckets_.key_eq();
};
/**
* @inheritDoc
*/
HashSet.prototype.bucket = function (key) {
return this.hash_function()(key) % this.buckets_.length();
};
HashSet.prototype.max_load_factor = function (z) {
if (z === void 0) { z = null; }
return this.buckets_.max_load_factor(z);
};
/**
* @inheritDoc
*/
HashSet.prototype.reserve = function (n) {
this.buckets_.reserve(n);
};
/**
* @inheritDoc
*/
HashSet.prototype.rehash = function (n) {
this.buckets_.rehash(n);
};
/* =========================================================
ELEMENTS I/O
- INSERT
- POST-PROCESS
- SWAP
============================================================
INSERT
--------------------------------------------------------- */
HashSet.prototype._Insert_by_key = function (key) {
// TEST WHETHER EXIST
var it = this.find(key);
if (it.equals(this.end()) === false)
return new Pair_1.Pair(it, false);
// INSERT
this.data_.push(key);
it = it.prev();
// POST-PROCESS
this._Handle_insert(it, it.next());
return new Pair_1.Pair(it, true);
};
HashSet.prototype._Insert_by_hint = function (hint, key) {
// FIND DUPLICATED KEY
var it = this.find(key);
if (it.equals(this.end()) === true) {
// INSERT
it = this.data_.insert(hint, key);
// POST-PROCESS
this._Handle_insert(it, it.next());
}
return it;
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
HashSet.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.insert(first);
};
HashSet.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.buckets_.erase(first);
};
return HashSet;
}(UniqueSet_1.UniqueSet));
exports.HashSet = HashSet;
/**
*
*/
(function (HashSet) {
// BODY
HashSet.Iterator = SetElementList_1.SetElementList.Iterator;
HashSet.ReverseIterator = SetElementList_1.SetElementList.ReverseIterator;
})(HashSet = exports.HashSet || (exports.HashSet = {}));
exports.HashSet = HashSet;
//# sourceMappingURL=HashSet.js.map
-169
View File
@@ -1,169 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { ListContainer } from "../internal/container/linear/ListContainer";
import { IDequeContainer } from "../base/container/IDequeContainer";
import { IListAlgorithm } from "../internal/container/linear/IListAlgorithm";
import { ListIterator } from "../internal/iterator/ListIterator";
import { ReverseIterator as ReverseIteratorBase } from "../internal/iterator/ReverseIterator";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { BinaryPredicator } from "../internal/functional/BinaryPredicator";
import { Comparator } from "../internal/functional/Comparator";
import { UnaryPredicator } from "../internal/functional/UnaryPredicator";
/**
* Doubly Linked List.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class List<T> extends ListContainer<T, List<T>, List.Iterator<T>, List.ReverseIterator<T>> implements IDequeContainer<T, List<T>, List.Iterator<T>, List.ReverseIterator<T>>, IListAlgorithm<T, List<T>> {
private ptr_;
/**
* Default Constructor.
*/
constructor();
/**
* Initializer Constructor.
*
* @param items Items to assign.
*/
constructor(items: Array<T>);
/**
* Copy Constructor
*
* @param obj Object to copy.
*/
constructor(obj: List<T>);
/**
* Fill Constructor.
*
* @param size Initial size.
* @param val Value to fill.
*/
constructor(size: number, val: T);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
constructor(first: Readonly<IForwardIterator<T>>, last: Readonly<IForwardIterator<T>>);
protected _Create_iterator(prev: List.Iterator<T>, next: List.Iterator<T>, val: T): List.Iterator<T>;
/**
* @inheritDoc
*/
front(): T;
/**
* @inheritDoc
*/
front(val: T): void;
/**
* @inheritDoc
*/
back(): T;
/**
* @inheritDoc
*/
back(val: T): void;
/**
* @inheritDoc
*/
unique(binary_pred?: BinaryPredicator<T>): void;
/**
* @inheritDoc
*/
remove(val: T): void;
/**
* @inheritDoc
*/
remove_if(pred: UnaryPredicator<T>): void;
/**
* @inheritDoc
*/
merge(source: List<T>, comp?: Comparator<T>): void;
/**
* Transfer elements.
*
* @param pos Position to insert.
* @param from Target container to transfer.
*/
splice(pos: List.Iterator<T>, from: List<T>): void;
/**
* Transfer a single element.
*
* @param pos Position to insert.
* @param from Target container to transfer.
* @param it Position of the single element to transfer.
*/
splice(pos: List.Iterator<T>, from: List<T>, it: List.Iterator<T>): void;
/**
* Transfer range elements.
*
* @param pos Position to insert.
* @param from Target container to transfer.
* @param first Range of the first position to transfer.
* @param last Rangee of the last position to transfer.
*/
splice(pos: List.Iterator<T>, from: List<T>, first: List.Iterator<T>, last: List.Iterator<T>): void;
/**
* @inheritDoc
*/
sort(comp?: Comparator<T>): void;
private _Quick_sort;
private _Quick_sort_partition;
/**
* @inheritDoc
*/
reverse(): void;
/**
* @inheritDoc
*/
swap(obj: List<T>): void;
}
/**
*
*/
export declare namespace List {
/**
* Iterator of {@link List}
*
* @author Jeongho Nam - https://github.com/samchon
*/
class Iterator<T> extends ListIterator<T, List<T>, Iterator<T>, ReverseIterator<T>, T> {
private source_ptr_;
private constructor();
/**
* @inheritDoc
*/
reverse(): ReverseIterator<T>;
/**
* @inheritDoc
*/
source(): List<T>;
/**
* @inheritDoc
*/
get value(): T;
/**
* @inheritDoc
*/
set value(val: T);
equals(obj: Iterator<T>): boolean;
}
/**
* Reverse iterator of {@link List}
*
* @author Jeongho Nam - https://github.com/samchon
*/
class ReverseIterator<T> extends ReverseIteratorBase<T, List<T>, Iterator<T>, ReverseIterator<T>, T> {
protected _Create_neighbor(base: Iterator<T>): ReverseIterator<T>;
/**
* @inheritDoc
*/
get value(): T;
/**
* @inheritDoc
*/
set value(val: T);
}
}
-359
View File
@@ -1,359 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.List = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var ListContainer_1 = require("../internal/container/linear/ListContainer");
var ListIterator_1 = require("../internal/iterator/ListIterator");
var ReverseIterator_1 = require("../internal/iterator/ReverseIterator");
var comparators_1 = require("../functional/comparators");
/**
* Doubly Linked List.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var List = /** @class */ (function (_super) {
__extends(List, _super);
function List() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this =
//----
// DEFAULT CONFIGURATIONS
//----
// INHERITS
_super.call(this) || this;
// DECLARE SOURCE POINTER
_this.ptr_ = { value: _this };
List.Iterator._Set_source_ptr(_this.end_, _this.ptr_);
//----
// BRANCHES
//----
if (args.length === 0) {
// DEFAULT CONSTRUCTOR
}
else if (args.length === 1 && args[0] instanceof Array) {
// INITIALIZER CONSTRUCTOR
var array = args[0];
_this.push.apply(_this, __spreadArray([], __read(array), false));
}
else if (args.length === 1 && args[0] instanceof List) {
// COPY CONSTRUCTOR
var container = args[0];
_this.assign(container.begin(), container.end());
}
else if (args.length === 2) {
// ASSIGN CONTRUCTOR
_this.assign(args[0], args[1]);
}
return _this;
}
List.prototype._Create_iterator = function (prev, next, val) {
return List.Iterator.create(this.ptr_, prev, next, val);
};
List.prototype.front = function (val) {
if (arguments.length === 0)
return this.begin_.value;
else
this.begin_.value = val;
};
List.prototype.back = function (val) {
var it = this.end().prev();
if (arguments.length === 0)
return it.value;
else
it.value = val;
};
/* ===============================================================
ALGORITHMS
- UNIQUE & REMOVE(_IF)
- MERGE & SPLICE
- SORT & SWAP
==================================================================
UNIQUE & REMOVE(_IF)
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
List.prototype.unique = function (binary_pred) {
if (binary_pred === void 0) { binary_pred = comparators_1.equal_to; }
var it = this.begin().next();
while (!it.equals(this.end())) {
if (binary_pred(it.value, it.prev().value) === true)
it = this.erase(it);
else
it = it.next();
}
};
/**
* @inheritDoc
*/
List.prototype.remove = function (val) {
return this.remove_if(function (elem) { return (0, comparators_1.equal_to)(elem, val); });
};
/**
* @inheritDoc
*/
List.prototype.remove_if = function (pred) {
var it = this.begin();
while (!it.equals(this.end())) {
if (pred(it.value) === true)
it = this.erase(it);
else
it = it.next();
}
};
/* ---------------------------------------------------------
MERGE & SPLICE
--------------------------------------------------------- */
/**
* @inheritDoc
*/
List.prototype.merge = function (source, comp) {
if (comp === void 0) { comp = comparators_1.less; }
if (this === source)
return;
var it = this.begin();
while (source.empty() === false) {
var first = source.begin();
while (!it.equals(this.end()) &&
comp(it.value, first.value) === true)
it = it.next();
this.splice(it, source, first);
}
};
List.prototype.splice = function (pos, obj, first, last) {
if (first === undefined) {
first = obj.begin();
last = obj.end();
}
else if (last === undefined)
last = first.next();
this.insert(pos, first, last);
obj.erase(first, last);
};
/* ---------------------------------------------------------
SORT & SWAP
--------------------------------------------------------- */
/**
* @inheritDoc
*/
List.prototype.sort = function (comp) {
if (comp === void 0) { comp = comparators_1.less; }
this._Quick_sort(this.begin(), this.end().prev(), comp);
};
List.prototype._Quick_sort = function (first, last, comp) {
if (!first.equals(last) &&
!last.equals(this.end()) &&
!first.equals(last.next())) {
var temp = this._Quick_sort_partition(first, last, comp);
this._Quick_sort(first, temp.prev(), comp);
this._Quick_sort(temp.next(), last, comp);
}
};
List.prototype._Quick_sort_partition = function (first, last, comp) {
var _a, _b;
var standard = last.value; // TO BE COMPARED
var prev = first.prev(); // TO BE SMALLEST
var it = first;
for (; !it.equals(last); it = it.next())
if (comp(it.value, standard)) {
prev = prev.equals(this.end()) ? first : prev.next();
_a = __read([it.value, prev.value], 2), prev.value = _a[0], it.value = _a[1];
}
prev = prev.equals(this.end()) ? first : prev.next();
_b = __read([it.value, prev.value], 2), prev.value = _b[0], it.value = _b[1];
return prev;
};
/**
* @inheritDoc
*/
List.prototype.reverse = function () {
var begin = this.end_.prev();
var prev_of_end = this.begin();
for (var it = this.begin(); !it.equals(this.end());) {
var prev = it.prev();
var next = it.next();
List.Iterator._Set_prev(it, next);
List.Iterator._Set_next(it, prev);
it = next;
}
// ADJUST THE BEGIN AND END
this.begin_ = begin; // THE NEW BEGIN
List.Iterator._Set_prev(this.end_, prev_of_end);
List.Iterator._Set_next(this.end_, begin);
};
/**
* @inheritDoc
*/
List.prototype.swap = function (obj) {
var _a, _b;
// CHANGE CONTENTS
_super.prototype.swap.call(this, obj);
// CHANGE ITERATORS' SOURCES
_a = __read([obj.ptr_, this.ptr_], 2), this.ptr_ = _a[0], obj.ptr_ = _a[1];
_b = __read([obj.ptr_.value, this.ptr_.value], 2), this.ptr_.value = _b[0], obj.ptr_.value = _b[1];
};
return List;
}(ListContainer_1.ListContainer));
exports.List = List;
/**
*
*/
(function (List) {
/**
* Iterator of {@link List}
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Iterator = /** @class */ (function (_super) {
__extends(Iterator, _super);
/* ---------------------------------------------------------------
CONSTRUCTORS
--------------------------------------------------------------- */
function Iterator(sourcePtr, prev, next, value) {
var _this = _super.call(this, prev, next, value) || this;
_this.source_ptr_ = sourcePtr;
return _this;
}
/**
* @internal
*/
Iterator.create = function (sourcePtr, prev, next, value) {
return new Iterator(sourcePtr, prev, next, value);
};
/**
* @inheritDoc
*/
Iterator.prototype.reverse = function () {
return new ReverseIterator(this);
};
/**
* @internal
*/
Iterator._Set_source_ptr = function (it, ptr) {
it.source_ptr_ = ptr;
};
/* ---------------------------------------------------------------
ACCESSORS
--------------------------------------------------------------- */
/**
* @inheritDoc
*/
Iterator.prototype.source = function () {
return this.source_ptr_.value;
};
Object.defineProperty(Iterator.prototype, "value", {
/**
* @inheritDoc
*/
get: function () {
this._Try_value();
return this.value_;
},
/**
* @inheritDoc
*/
set: function (val) {
this._Try_value();
this.value_ = val;
},
enumerable: false,
configurable: true
});
/* ---------------------------------------------------------------
COMPARISON
--------------------------------------------------------------- */
Iterator.prototype.equals = function (obj) {
return this === obj;
};
return Iterator;
}(ListIterator_1.ListIterator));
List.Iterator = Iterator;
/**
* Reverse iterator of {@link List}
*
* @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, "value", {
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
get: function () {
return this.base_.value;
},
/**
* @inheritDoc
*/
set: function (val) {
this.base_.value = val;
},
enumerable: false,
configurable: true
});
return ReverseIterator;
}(ReverseIterator_1.ReverseIterator));
List.ReverseIterator = ReverseIterator;
})(List = exports.List || (exports.List = {}));
exports.List = List;
//# sourceMappingURL=List.js.map
-56
View File
@@ -1,56 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { AdaptorContainer } from "../internal/container/linear/AdaptorContainer";
import { Vector } from "./Vector";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { Comparator } from "../internal/functional/Comparator";
/**
* Priority Queue; Greater Out First.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class PriorityQueue<T> extends AdaptorContainer<T, Vector<T>, PriorityQueue<T>> {
private comp_;
/**
* Default Constructor.
*
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(comp?: Comparator<T>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: PriorityQueue<T>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(first: Readonly<IForwardIterator<T>>, last: Readonly<IForwardIterator<T>>, comp?: Comparator<T>);
/**
* Get value comparison function.
*/
value_comp(): Comparator<T>;
/**
* Get top element.
*/
top(): T;
/**
* @inheritDoc
*/
push(...elems: T[]): number;
/**
* @inheritDoc
*/
pop(): void;
/**
* @inheritDoc
*/
swap(obj: PriorityQueue<T>): void;
}
-169
View File
@@ -1,169 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __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.");
};
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.PriorityQueue = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var AdaptorContainer_1 = require("../internal/container/linear/AdaptorContainer");
var Vector_1 = require("./Vector");
var heap_1 = require("../algorithm/heap");
var comparators_1 = require("../functional/comparators");
/**
* Priority Queue; Greater Out First.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var PriorityQueue = /** @class */ (function (_super) {
__extends(PriorityQueue, _super);
function PriorityQueue() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, new Vector_1.Vector()) || this;
// DECLARE MEMBERS
var comp = comparators_1.less;
var post_process = null;
//----
// INITIALIZE MEMBERS AND POST-PROCESS
//----
// BRANCH - METHOD OVERLOADINGS
if (args.length === 1 && args[0] instanceof PriorityQueue) {
var obj_1 = args[0];
comp = obj_1.comp_;
post_process = function () {
var first = obj_1.source_.begin();
var last = obj_1.source_.end();
_this.source_.assign(first, last);
};
}
else if (args.length >= 2 &&
args[0].next instanceof Function &&
args[1].next instanceof Function) {
// FUNCTION TEMPLATE
if (args.length === 3)
comp = args[2];
post_process = function () {
// RANGE CONSTRUCTOR
var first = args[0]; // PARAMETER 1
var last = args[1]; // PARAMETER 2
_this.source_.assign(first, last);
};
}
else if (args.length === 1)
comp = args[0];
//----
// DO PROCESS
//----
_this.comp_ = comp;
if (post_process !== null)
post_process();
return _this;
}
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* Get value comparison function.
*/
PriorityQueue.prototype.value_comp = function () {
return this.comp_;
};
/**
* Get top element.
*/
PriorityQueue.prototype.top = function () {
return this.source_.front();
};
/* ---------------------------------------------------------
ELEMENTS I/O
--------------------------------------------------------- */
/**
* @inheritDoc
*/
PriorityQueue.prototype.push = function () {
var e_1, _a;
var elems = [];
for (var _i = 0; _i < arguments.length; _i++) {
elems[_i] = arguments[_i];
}
try {
for (var elems_1 = __values(elems), elems_1_1 = elems_1.next(); !elems_1_1.done; elems_1_1 = elems_1.next()) {
var elem = elems_1_1.value;
this.source_.push_back(elem);
(0, heap_1.push_heap)(this.source_.begin(), this.source_.end(), this.comp_);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (elems_1_1 && !elems_1_1.done && (_a = elems_1.return)) _a.call(elems_1);
}
finally { if (e_1) throw e_1.error; }
}
return this.size();
};
/**
* @inheritDoc
*/
PriorityQueue.prototype.pop = function () {
(0, heap_1.pop_heap)(this.source_.begin(), this.source_.end(), this.comp_);
this.source_.pop_back();
};
/**
* @inheritDoc
*/
PriorityQueue.prototype.swap = function (obj) {
var _a;
_super.prototype.swap.call(this, obj);
_a = __read([obj.comp_, this.comp_], 2), this.comp_ = _a[0], obj.comp_ = _a[1];
};
return PriorityQueue;
}(AdaptorContainer_1.AdaptorContainer));
exports.PriorityQueue = PriorityQueue;
//# sourceMappingURL=PriorityQueue.js.map
-39
View File
@@ -1,39 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { AdaptorContainer } from "../internal/container/linear/AdaptorContainer";
import { List } from "./List";
/**
* Queue; FIFO (First In First Out).
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class Queue<T> extends AdaptorContainer<T, List<T>, Queue<T>> {
/**
* Default Constructor.
*/
constructor();
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: Queue<T>);
/**
* Get the first element.
*
* @return The first element.
*/
front(): T;
/**
* Get the last element.
*
* @return The last element.
*/
back(): T;
/**
* @inheritDoc
*/
pop(): void;
}
-68
View File
@@ -1,68 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Queue = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var AdaptorContainer_1 = require("../internal/container/linear/AdaptorContainer");
var List_1 = require("./List");
/**
* Queue; FIFO (First In First Out).
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Queue = /** @class */ (function (_super) {
__extends(Queue, _super);
function Queue(obj) {
var _this = _super.call(this, new List_1.List()) || this;
if (obj !== undefined)
_this.source_.assign(obj.source_.begin(), obj.source_.end());
return _this;
}
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* Get the first element.
*
* @return The first element.
*/
Queue.prototype.front = function () {
return this.source_.front();
};
/**
* Get the last element.
*
* @return The last element.
*/
Queue.prototype.back = function () {
return this.source_.back();
};
/**
* @inheritDoc
*/
Queue.prototype.pop = function () {
this.source_.pop_front();
};
return Queue;
}(AdaptorContainer_1.AdaptorContainer));
exports.Queue = Queue;
//# sourceMappingURL=Queue.js.map
-33
View File
@@ -1,33 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { AdaptorContainer } from "../internal/container/linear/AdaptorContainer";
import { Vector } from "./Vector";
/**
* Stack; LIFO (Last In First Out).
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class Stack<T> extends AdaptorContainer<T, Vector<T>, Stack<T>> {
/**
* Default Constructor.
*/
constructor();
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: Stack<T>);
/**
* Get the last element.
*
* @return The last element.
*/
top(): T;
/**
* @inheritDoc
*/
pop(): void;
}
-60
View File
@@ -1,60 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stack = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var AdaptorContainer_1 = require("../internal/container/linear/AdaptorContainer");
var Vector_1 = require("./Vector");
/**
* Stack; LIFO (Last In First Out).
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Stack = /** @class */ (function (_super) {
__extends(Stack, _super);
function Stack(obj) {
var _this = _super.call(this, new Vector_1.Vector()) || this;
if (obj !== undefined)
_this.source_.assign(obj.source_.begin(), obj.source_.end());
return _this;
}
/* ---------------------------------------------------------
ACCESSOR
--------------------------------------------------------- */
/**
* Get the last element.
*
* @return The last element.
*/
Stack.prototype.top = function () {
return this.source_.back();
};
/**
* @inheritDoc
*/
Stack.prototype.pop = function () {
this.source_.pop_back();
};
return Stack;
}(AdaptorContainer_1.AdaptorContainer));
exports.Stack = Stack;
//# sourceMappingURL=Stack.js.map
-81
View File
@@ -1,81 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { UniqueTreeMap } from "../internal/container/associative/UniqueTreeMap";
import { MapElementList } from "../internal/container/associative/MapElementList";
import { Comparator } from "../internal/functional/Comparator";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { IPair } from "../utility/IPair";
/**
* Unique-key Map based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class TreeMap<Key, T> extends UniqueTreeMap<Key, T, TreeMap<Key, T>, TreeMap.Iterator<Key, T>, TreeMap.ReverseIterator<Key, T>> {
private tree_;
/**
* Default Constructor.
*
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(comp?: Comparator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(items: IPair<Key, T>[], comp?: Comparator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: TreeMap<Key, T>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(first: Readonly<IForwardIterator<IPair<Key, T>>>, last: Readonly<IForwardIterator<IPair<Key, T>>>, comp?: Comparator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: TreeMap<Key, T>): void;
/**
* @inheritDoc
*/
key_comp(): Comparator<Key>;
/**
* @inheritDoc
*/
lower_bound(key: Key): TreeMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
upper_bound(key: Key): TreeMap.Iterator<Key, T>;
protected _Handle_insert(first: TreeMap.Iterator<Key, T>, last: TreeMap.Iterator<Key, T>): void;
protected _Handle_erase(first: TreeMap.Iterator<Key, T>, last: TreeMap.Iterator<Key, T>): void;
}
/**
*
*/
export declare namespace TreeMap {
/**
* Iterator of {@link TreeMap}
*/
type Iterator<Key, T> = MapElementList.Iterator<Key, T, true, TreeMap<Key, T>>;
/**
* Reverse iterator of {@link TreeMap}
*/
type ReverseIterator<Key, T> = MapElementList.ReverseIterator<Key, T, true, TreeMap<Key, T>>;
const Iterator: typeof MapElementList.Iterator;
const ReverseIterator: typeof MapElementList.ReverseIterator;
}
-140
View File
@@ -1,140 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.TreeMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var UniqueTreeMap_1 = require("../internal/container/associative/UniqueTreeMap");
var ITreeContainer_1 = require("../internal/container/associative/ITreeContainer");
var MapElementList_1 = require("../internal/container/associative/MapElementList");
var UniqueMapTree_1 = require("../internal/tree/UniqueMapTree");
/**
* Unique-key Map based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var TreeMap = /** @class */ (function (_super) {
__extends(TreeMap, _super);
function TreeMap() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this =
// INITIALIZATION
_super.call(this, function (thisArg) { return new MapElementList_1.MapElementList(thisArg); }) || this;
// OVERLOADINGS
ITreeContainer_1.ITreeContainer.construct.apply(ITreeContainer_1.ITreeContainer, __spreadArray([_this,
TreeMap,
function (comp) {
_this.tree_ = new UniqueMapTree_1.UniqueMapTree(_this, comp);
}], __read(args), false));
return _this;
}
/**
* @inheritDoc
*/
TreeMap.prototype.clear = function () {
_super.prototype.clear.call(this);
this.tree_.clear();
};
/**
* @inheritDoc
*/
TreeMap.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
MapElementList_1.MapElementList._Swap_associative(this.data_, obj.data_);
// SWAP RB-TREE
UniqueMapTree_1.UniqueMapTree._Swap_source(this.tree_, obj.tree_);
_b = __read([obj.tree_, this.tree_], 2), this.tree_ = _b[0], obj.tree_ = _b[1];
};
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
TreeMap.prototype.key_comp = function () {
return this.tree_.key_comp();
};
/**
* @inheritDoc
*/
TreeMap.prototype.lower_bound = function (key) {
return this.tree_.lower_bound(key);
};
/**
* @inheritDoc
*/
TreeMap.prototype.upper_bound = function (key) {
return this.tree_.upper_bound(key);
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
TreeMap.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.insert(first);
};
TreeMap.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.erase(first);
};
return TreeMap;
}(UniqueTreeMap_1.UniqueTreeMap));
exports.TreeMap = TreeMap;
/**
*
*/
(function (TreeMap) {
// BODY
TreeMap.Iterator = MapElementList_1.MapElementList.Iterator;
TreeMap.ReverseIterator = MapElementList_1.MapElementList.ReverseIterator;
})(TreeMap = exports.TreeMap || (exports.TreeMap = {}));
exports.TreeMap = TreeMap;
//# sourceMappingURL=TreeMap.js.map
-81
View File
@@ -1,81 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { MultiTreeMap } from "../internal/container/associative/MultiTreeMap";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { MapElementList } from "../internal/container/associative/MapElementList";
import { Comparator } from "../internal/functional/Comparator";
import { IPair } from "../utility/IPair";
/**
* Multiple-key Map based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class TreeMultiMap<Key, T> extends MultiTreeMap<Key, T, TreeMultiMap<Key, T>, TreeMultiMap.Iterator<Key, T>, TreeMultiMap.ReverseIterator<Key, T>> {
private tree_;
/**
* Default Constructor.
*
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(comp?: Comparator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(items: IPair<Key, T>[], comp?: Comparator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: TreeMultiMap<Key, T>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(first: Readonly<IForwardIterator<IPair<Key, T>>>, last: Readonly<IForwardIterator<IPair<Key, T>>>, comp?: Comparator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: TreeMultiMap<Key, T>): void;
/**
* @inheritDoc
*/
key_comp(): Comparator<Key>;
/**
* @inheritDoc
*/
lower_bound(key: Key): TreeMultiMap.Iterator<Key, T>;
/**
* @inheritDoc
*/
upper_bound(key: Key): TreeMultiMap.Iterator<Key, T>;
protected _Handle_insert(first: TreeMultiMap.Iterator<Key, T>, last: TreeMultiMap.Iterator<Key, T>): void;
protected _Handle_erase(first: TreeMultiMap.Iterator<Key, T>, last: TreeMultiMap.Iterator<Key, T>): void;
}
/**
*
*/
export declare namespace TreeMultiMap {
/**
* Iterator of {@link TreeMultiMap}
*/
type Iterator<Key, T> = MapElementList.Iterator<Key, T, false, TreeMultiMap<Key, T>>;
/**
* Iterator of {@link TreeMultiMap}
*/
type ReverseIterator<Key, T> = MapElementList.ReverseIterator<Key, T, false, TreeMultiMap<Key, T>>;
const Iterator: typeof MapElementList.Iterator;
const ReverseIterator: typeof MapElementList.ReverseIterator;
}
-137
View File
@@ -1,137 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.TreeMultiMap = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var MultiTreeMap_1 = require("../internal/container/associative/MultiTreeMap");
var ITreeContainer_1 = require("../internal/container/associative/ITreeContainer");
var MapElementList_1 = require("../internal/container/associative/MapElementList");
var MultiMapTree_1 = require("../internal/tree/MultiMapTree");
/**
* Multiple-key Map based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var TreeMultiMap = /** @class */ (function (_super) {
__extends(TreeMultiMap, _super);
function TreeMultiMap() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new MapElementList_1.MapElementList(thisArg); }) || this;
ITreeContainer_1.ITreeContainer.construct.apply(ITreeContainer_1.ITreeContainer, __spreadArray([_this,
TreeMultiMap,
function (comp) {
_this.tree_ = new MultiMapTree_1.MultiMapTree(_this, comp);
}], __read(args), false));
return _this;
}
/**
* @inheritDoc
*/
TreeMultiMap.prototype.clear = function () {
_super.prototype.clear.call(this);
this.tree_.clear();
};
/**
* @inheritDoc
*/
TreeMultiMap.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
MapElementList_1.MapElementList._Swap_associative(this.data_, obj.data_);
// SWAP RB-TREE
MultiMapTree_1.MultiMapTree._Swap_source(this.tree_, obj.tree_);
_b = __read([obj.tree_, this.tree_], 2), this.tree_ = _b[0], obj.tree_ = _b[1];
};
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
TreeMultiMap.prototype.key_comp = function () {
return this.tree_.key_comp();
};
/**
* @inheritDoc
*/
TreeMultiMap.prototype.lower_bound = function (key) {
return this.tree_.lower_bound(key);
};
/**
* @inheritDoc
*/
TreeMultiMap.prototype.upper_bound = function (key) {
return this.tree_.upper_bound(key);
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
TreeMultiMap.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.insert(first);
};
TreeMultiMap.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.erase(first);
};
return TreeMultiMap;
}(MultiTreeMap_1.MultiTreeMap));
exports.TreeMultiMap = TreeMultiMap;
/**
*
*/
(function (TreeMultiMap) {
// BODY
TreeMultiMap.Iterator = MapElementList_1.MapElementList.Iterator;
TreeMultiMap.ReverseIterator = MapElementList_1.MapElementList.ReverseIterator;
})(TreeMultiMap = exports.TreeMultiMap || (exports.TreeMultiMap = {}));
exports.TreeMultiMap = TreeMultiMap;
//# sourceMappingURL=TreeMultiMap.js.map
-80
View File
@@ -1,80 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { MultiTreeSet } from "../internal/container/associative/MultiTreeSet";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { SetElementList } from "../internal/container/associative/SetElementList";
import { Comparator } from "../internal/functional/Comparator";
/**
* Multiple-key Set based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class TreeMultiSet<Key> extends MultiTreeSet<Key, TreeMultiSet<Key>, TreeMultiSet.Iterator<Key>, TreeMultiSet.ReverseIterator<Key>> {
private tree_;
/**
* Default Constructor.
*
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(comp?: Comparator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(items: Key[], comp?: Comparator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(obj: TreeMultiSet<Key>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(first: Readonly<IForwardIterator<Key>>, last: Readonly<IForwardIterator<Key>>, comp?: Comparator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: TreeMultiSet<Key>): void;
/**
* @inheritDoc
*/
key_comp(): Comparator<Key>;
/**
* @inheritDoc
*/
lower_bound(key: Key): TreeMultiSet.Iterator<Key>;
/**
* @inheritDoc
*/
upper_bound(key: Key): TreeMultiSet.Iterator<Key>;
protected _Handle_insert(first: TreeMultiSet.Iterator<Key>, last: TreeMultiSet.Iterator<Key>): void;
protected _Handle_erase(first: TreeMultiSet.Iterator<Key>, last: TreeMultiSet.Iterator<Key>): void;
}
/**
*
*/
export declare namespace TreeMultiSet {
/**
* Iterator of {@link TreeMultiSet}
*/
type Iterator<Key> = SetElementList.Iterator<Key, false, TreeMultiSet<Key>>;
/**
* Reverse iterator of {@link TreeMultiSet}
*/
type ReverseIterator<Key> = SetElementList.ReverseIterator<Key, false, TreeMultiSet<Key>>;
const Iterator: typeof SetElementList.Iterator;
const ReverseIterator: typeof SetElementList.ReverseIterator;
}
-137
View File
@@ -1,137 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.TreeMultiSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var MultiTreeSet_1 = require("../internal/container/associative/MultiTreeSet");
var ITreeContainer_1 = require("../internal/container/associative/ITreeContainer");
var SetElementList_1 = require("../internal/container/associative/SetElementList");
var MultiSetTree_1 = require("../internal/tree/MultiSetTree");
/**
* Multiple-key Set based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var TreeMultiSet = /** @class */ (function (_super) {
__extends(TreeMultiSet, _super);
function TreeMultiSet() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new SetElementList_1.SetElementList(thisArg); }) || this;
ITreeContainer_1.ITreeContainer.construct.apply(ITreeContainer_1.ITreeContainer, __spreadArray([_this,
TreeMultiSet,
function (comp) {
_this.tree_ = new MultiSetTree_1.MultiSetTree(_this, comp);
}], __read(args), false));
return _this;
}
/**
* @inheritDoc
*/
TreeMultiSet.prototype.clear = function () {
_super.prototype.clear.call(this);
this.tree_.clear();
};
/**
* @inheritDoc
*/
TreeMultiSet.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
SetElementList_1.SetElementList._Swap_associative(this.data_, obj.data_);
// SWAP RB-TREE
MultiSetTree_1.MultiSetTree._Swap_source(this.tree_, obj.tree_);
_b = __read([obj.tree_, this.tree_], 2), this.tree_ = _b[0], obj.tree_ = _b[1];
};
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
TreeMultiSet.prototype.key_comp = function () {
return this.tree_.key_comp();
};
/**
* @inheritDoc
*/
TreeMultiSet.prototype.lower_bound = function (key) {
return this.tree_.lower_bound(key);
};
/**
* @inheritDoc
*/
TreeMultiSet.prototype.upper_bound = function (key) {
return this.tree_.upper_bound(key);
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
TreeMultiSet.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.insert(first);
};
TreeMultiSet.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.erase(first);
};
return TreeMultiSet;
}(MultiTreeSet_1.MultiTreeSet));
exports.TreeMultiSet = TreeMultiSet;
/**
*
*/
(function (TreeMultiSet) {
// BODY
TreeMultiSet.Iterator = SetElementList_1.SetElementList.Iterator;
TreeMultiSet.ReverseIterator = SetElementList_1.SetElementList.ReverseIterator;
})(TreeMultiSet = exports.TreeMultiSet || (exports.TreeMultiSet = {}));
exports.TreeMultiSet = TreeMultiSet;
//# sourceMappingURL=TreeMultiSet.js.map
-80
View File
@@ -1,80 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { UniqueTreeSet } from "../internal/container/associative/UniqueTreeSet";
import { IForwardIterator } from "../iterator/IForwardIterator";
import { SetElementList } from "../internal/container/associative/SetElementList";
import { Comparator } from "../internal/functional/Comparator";
/**
* Unique-key Set based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class TreeSet<Key> extends UniqueTreeSet<Key, TreeSet<Key>, TreeSet.Iterator<Key>, TreeSet.ReverseIterator<Key>> {
private tree_;
/**
* Default Constructor.
*
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(comp?: Comparator<Key>);
/**
* Initializer Constructor.
*
* @param items Items to assign.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(items: Key[], comp?: Comparator<Key>);
/**
* Copy Constructor.
*
* @param obj Object to copy.
*/
constructor(container: TreeSet<Key>);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iterator of the last position.
* @param comp A binary function predicates *x* element would be placed before *y*. When returns `true`, then *x* precedes *y*. Note that, because *equality* is predicated by `!comp(x, y) && !comp(y, x)`, the function must not cover the *equality* like `<=` or `>=`. It must exclude the *equality* like `<` or `>`. Default is {@link less}.
*/
constructor(first: Readonly<IForwardIterator<Key>>, last: Readonly<IForwardIterator<Key>>, comp?: Comparator<Key>);
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
swap(obj: TreeSet<Key>): void;
/**
* @inheritDoc
*/
key_comp(): Comparator<Key>;
/**
* @inheritDoc
*/
lower_bound(key: Key): TreeSet.Iterator<Key>;
/**
* @inheritDoc
*/
upper_bound(key: Key): TreeSet.Iterator<Key>;
protected _Handle_insert(first: TreeSet.Iterator<Key>, last: TreeSet.Iterator<Key>): void;
protected _Handle_erase(first: TreeSet.Iterator<Key>, last: TreeSet.Iterator<Key>): void;
}
/**
*
*/
export declare namespace TreeSet {
/**
* Iterator of {@link TreeSet}
*/
type Iterator<Key> = SetElementList.Iterator<Key, true, TreeSet<Key>>;
/**
* Reverse iterator of {@link TreeSet}
*/
type ReverseIterator<Key> = SetElementList.ReverseIterator<Key, true, TreeSet<Key>>;
const Iterator: typeof SetElementList.Iterator;
const ReverseIterator: typeof SetElementList.ReverseIterator;
}
-137
View File
@@ -1,137 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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.TreeSet = void 0;
//================================================================
/**
* @packageDocumentation
* @module std
*/
//================================================================
var UniqueTreeSet_1 = require("../internal/container/associative/UniqueTreeSet");
var ITreeContainer_1 = require("../internal/container/associative/ITreeContainer");
var SetElementList_1 = require("../internal/container/associative/SetElementList");
var UniqueSetTree_1 = require("../internal/tree/UniqueSetTree");
/**
* Unique-key Set based on Tree.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var TreeSet = /** @class */ (function (_super) {
__extends(TreeSet, _super);
function TreeSet() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this, function (thisArg) { return new SetElementList_1.SetElementList(thisArg); }) || this;
ITreeContainer_1.ITreeContainer.construct.apply(ITreeContainer_1.ITreeContainer, __spreadArray([_this,
TreeSet,
function (comp) {
_this.tree_ = new UniqueSetTree_1.UniqueSetTree(_this, comp);
}], __read(args), false));
return _this;
}
/**
* @inheritDoc
*/
TreeSet.prototype.clear = function () {
_super.prototype.clear.call(this);
this.tree_.clear();
};
/**
* @inheritDoc
*/
TreeSet.prototype.swap = function (obj) {
var _a, _b;
// SWAP CONTENTS
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
SetElementList_1.SetElementList._Swap_associative(this.data_, obj.data_);
// SWAP RB-TREE
UniqueSetTree_1.UniqueSetTree._Swap_source(this.tree_, obj.tree_);
_b = __read([obj.tree_, this.tree_], 2), this.tree_ = _b[0], obj.tree_ = _b[1];
};
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* @inheritDoc
*/
TreeSet.prototype.key_comp = function () {
return this.tree_.key_comp();
};
/**
* @inheritDoc
*/
TreeSet.prototype.lower_bound = function (key) {
return this.tree_.lower_bound(key);
};
/**
* @inheritDoc
*/
TreeSet.prototype.upper_bound = function (key) {
return this.tree_.upper_bound(key);
};
/* ---------------------------------------------------------
POST-PROCESS
--------------------------------------------------------- */
TreeSet.prototype._Handle_insert = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.insert(first);
};
TreeSet.prototype._Handle_erase = function (first, last) {
for (; !first.equals(last); first = first.next())
this.tree_.erase(first);
};
return TreeSet;
}(UniqueTreeSet_1.UniqueTreeSet));
exports.TreeSet = TreeSet;
/**
*
*/
(function (TreeSet) {
// BODY
TreeSet.Iterator = SetElementList_1.SetElementList.Iterator;
TreeSet.ReverseIterator = SetElementList_1.SetElementList.ReverseIterator;
})(TreeSet = exports.TreeSet || (exports.TreeSet = {}));
exports.TreeSet = TreeSet;
//# sourceMappingURL=TreeSet.js.map
-73
View File
@@ -1,73 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { IArrayContainer } from "../base/container/IArrayContainer";
import { VectorContainer } from "../internal/container/linear/VectorContainer";
import { ArrayIterator } from "../internal/iterator/ArrayIterator";
import { ArrayReverseIterator } from "../internal/iterator/ArrayReverseIterator";
import { IForwardIterator } from "../iterator/IForwardIterator";
/**
* Vector, an array with variable capacity.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class Vector<T> extends VectorContainer<T, Vector<T>, Vector<T>, Vector.Iterator<T>, Vector.ReverseIterator<T>> implements IArrayContainer<T, Vector<T>, Vector.Iterator<T>, Vector.ReverseIterator<T>> {
/**
* Default Constructor.
*/
constructor();
/**
* Initializer Constructor.
*
* @param items Items to assign.
*/
constructor(items: Array<T>);
/**
* Copy Constructor
*
* @param obj Object to copy.
*/
constructor(obj: Vector<T>);
/**
* Fill Constructor.
*
* @param size Initial size.
* @param val Value to fill.
*/
constructor(n: number, val: T);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
constructor(first: Readonly<IForwardIterator<T>>, last: Readonly<IForwardIterator<T>>);
/**
* Wrap an array into a vector.
*
* @param data Target array to be wrapped
* @return A vector wrapping the parametric array.
*/
static wrap<T>(data: Array<T>): Vector<T>;
/**
* @inheritDoc
*/
nth(index: number): Vector.Iterator<T>;
protected source(): Vector<T>;
}
/**
*
*/
export declare namespace Vector {
/**
* Iterator of {@link Vector}
*/
type Iterator<T> = ArrayIterator<T, Vector<T>>;
/**
* Reverse iterator of {@link Vector}
*/
type ReverseIterator<T> = ArrayReverseIterator<T, Vector<T>>;
const Iterator: typeof ArrayIterator;
const ReverseIterator: typeof ArrayReverseIterator;
}
-90
View File
@@ -1,90 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vector = void 0;
var VectorContainer_1 = require("../internal/container/linear/VectorContainer");
var ArrayIterator_1 = require("../internal/iterator/ArrayIterator");
var ArrayReverseIterator_1 = require("../internal/iterator/ArrayReverseIterator");
/**
* Vector, an array with variable capacity.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var Vector = /** @class */ (function (_super) {
__extends(Vector, _super);
function Vector() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this) || this;
// CONSTRUCTORS BRANCH
if (args.length === 0) {
// DEFAULT CONSTRUCTOR
_this.data_ = [];
}
else if (args[0] instanceof Array) {
// INITIALIZER CONSTRUCTOR
var array = args[0];
_this.data_ = args[1] === true ? array : array.slice();
}
else if (args.length === 1 && args[0] instanceof Vector) {
// COPY CONSTRUCTOR
var v = args[0];
_this.data_ = v.data_.slice();
}
else if (args.length === 2) {
// ASSIGN CONSTRUCTOR
_this.data_ = [];
_this.assign(args[0], args[1]);
}
return _this;
}
/* ---------------------------------------------------------
ACCESSORS
--------------------------------------------------------- */
/**
* Wrap an array into a vector.
*
* @param data Target array to be wrapped
* @return A vector wrapping the parametric array.
*/
Vector.wrap = function (data) {
return new Vector(data, true);
};
/**
* @inheritDoc
*/
Vector.prototype.nth = function (index) {
return new Vector.Iterator(this, index);
};
Vector.prototype.source = function () {
return this;
};
return Vector;
}(VectorContainer_1.VectorContainer));
exports.Vector = Vector;
/**
*
*/
(function (Vector) {
// BODY
Vector.Iterator = ArrayIterator_1.ArrayIterator;
Vector.ReverseIterator = ArrayReverseIterator_1.ArrayReverseIterator;
})(Vector = exports.Vector || (exports.Vector = {}));
exports.Vector = Vector;
//# sourceMappingURL=Vector.js.map
-122
View File
@@ -1,122 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
import { IArrayContainer } from "../base/container/IArrayContainer";
import { ArrayContainer } from "../internal/container/linear/ArrayContainer";
import { ArrayIterator } from "../internal/iterator/ArrayIterator";
import { ArrayReverseIterator } from "../internal/iterator/ArrayReverseIterator";
import { IForwardIterator } from "../iterator/IForwardIterator";
/**
* Vector only for `boolean`.
*
* @author Jeongho Nam - https://github.com/samchon
*/
export declare class VectorBoolean extends ArrayContainer<boolean, VectorBoolean, VectorBoolean, VectorBoolean.Iterator, VectorBoolean.ReverseIterator, boolean> implements IArrayContainer<boolean, VectorBoolean, VectorBoolean.Iterator, VectorBoolean.ReverseIterator> {
/**
* Store not full elements, but their sequence.
*
* - first: index
* - second: value
*/
private data_;
/**
* Number of elements
*/
private size_;
/**
* Default Constructor.
*/
constructor();
/**
* Initializer Constructor.
*
* @param items Items to assign.
*/
constructor(array: boolean[]);
/**
* Copy Constructor
*
* @param obj Object to copy.
*/
constructor(obj: VectorBoolean);
/**
* Fill Constructor.
*
* @param size Initial size.
* @param val Value to fill.
*/
constructor(n: number, val: boolean);
/**
* Range Constructor.
*
* @param first Input iterator of the first position.
* @param last Input iteartor of the last position.
*/
constructor(first: Readonly<IForwardIterator<boolean>>, last: Readonly<IForwardIterator<boolean>>);
/**
* @inheritDoc
*/
assign(n: number, val: boolean): void;
/**
* @inheritDoc
*/
assign<InputIterator extends Readonly<IForwardIterator<boolean, InputIterator>>>(first: InputIterator, last: InputIterator): void;
/**
* @inheritDoc
*/
clear(): void;
/**
* @inheritDoc
*/
resize(n: number): void;
/**
* Flip all values.
*/
flip(): void;
/**
* @inheritDoc
*/
swap(obj: VectorBoolean): void;
protected source(): VectorBoolean;
/**
* @inheritDoc
*/
size(): number;
protected _At(index: number): boolean;
protected _Set(index: number, val: boolean): void;
/**
* @inheritDoc
*/
nth(index: number): VectorBoolean.Iterator;
private _Find_node;
/**
* @inheritDoc
*/
push(...items: boolean[]): number;
/**
* @inheritDoc
*/
push_back(val: boolean): void;
protected _Pop_back(): void;
protected _Insert_by_repeating_val(pos: VectorBoolean.Iterator, n: number, val: boolean): VectorBoolean.Iterator;
protected _Insert_by_range<InputIterator extends Readonly<IForwardIterator<boolean, InputIterator>>>(pos: VectorBoolean.Iterator, first: InputIterator, last: InputIterator): VectorBoolean.Iterator;
private _Insert_to_middle;
private _Insert_to_end;
protected _Erase_by_range(first: VectorBoolean.Iterator, last: VectorBoolean.Iterator): VectorBoolean.Iterator;
}
/**
*
*/
export declare namespace VectorBoolean {
/**
* Iterator of {@link VectorBoolean}
*/
type Iterator = ArrayIterator<boolean, VectorBoolean>;
/**
* Reverse iterator of {@link VectorBoolean}
*/
type ReverseIterator = ArrayReverseIterator<boolean, VectorBoolean>;
const Iterator: typeof ArrayIterator;
const ReverseIterator: typeof ArrayReverseIterator;
}
-359
View File
@@ -1,359 +0,0 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
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));
};
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.VectorBoolean = void 0;
var ArrayContainer_1 = require("../internal/container/linear/ArrayContainer");
var ArrayIterator_1 = require("../internal/iterator/ArrayIterator");
var ArrayReverseIterator_1 = require("../internal/iterator/ArrayReverseIterator");
var TreeMap_1 = require("./TreeMap");
var NativeArrayIterator_1 = require("../internal/iterator/disposable/NativeArrayIterator");
var Pair_1 = require("../utility/Pair");
var comparators_1 = require("../functional/comparators");
/**
* Vector only for `boolean`.
*
* @author Jeongho Nam - https://github.com/samchon
*/
var VectorBoolean = /** @class */ (function (_super) {
__extends(VectorBoolean, _super);
function VectorBoolean() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.call(this) || this;
if (args.length === 1 && args[0] instanceof VectorBoolean) {
// COPY CONSTRUCTOR
var obj = args[0];
_this.data_ = new TreeMap_1.TreeMap(obj.data_.begin(), obj.data_.end());
_this.size_ = obj.size_;
}
else if (args.length === 1 && args[0] instanceof Array) {
// INITIALIZER
_this.clear();
_this.push.apply(_this, __spreadArray([], __read(args[0]), false));
}
else if (args.length === 2) {
// ASSIGNER
_this.assign(args[0], args[1]);
} // DEFAULT CONSTRUCTOR
else
_this.clear();
return _this;
}
VectorBoolean.prototype.assign = function (first, last) {
this.clear();
this.insert(this.end(), first, last);
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.clear = function () {
this.data_ = new TreeMap_1.TreeMap();
this.size_ = 0;
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.resize = function (n) {
var expansion = n - this.size();
if (expansion > 0)
this.insert(this.end(), expansion, false);
else if (expansion < 0)
this.erase(this.end().advance(-expansion), this.end());
};
/**
* Flip all values.
*/
VectorBoolean.prototype.flip = function () {
var e_1, _a;
try {
for (var _b = __values(this.data_), _c = _b.next(); !_c.done; _c = _b.next()) {
var entry = _c.value;
entry.second = !entry.second;
}
}
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; }
}
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.swap = function (obj) {
var _a, _b;
_a = __read([obj.data_, this.data_], 2), this.data_ = _a[0], obj.data_ = _a[1];
_b = __read([obj.size_, this.size_], 2), this.size_ = _b[0], obj.size_ = _b[1];
};
/* =========================================================
ACCESSORS
========================================================= */
VectorBoolean.prototype.source = function () {
return this;
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.size = function () {
return this.size_;
};
VectorBoolean.prototype._At = function (index) {
// FIND THE NEAREST NODE OF LEFT
var it = this._Find_node(index);
return it.second; // RETURNS
};
VectorBoolean.prototype._Set = function (index, val) {
val = !!val; // SIFT
// FIND THE NEAREAST NODE OF LEFT
var it = this._Find_node(index);
if (it.second === val)
return; // NO NEED TO CHANGE
//----
// CHANGE VALUE
//----
if (it.first === index) {
// CHANGE VALUE DIRECTLY
it.second = val;
}
else {
// EMPLACE NEW NODE
it = this.data_.emplace(index, val).first;
}
//----
// POST-PROCESS
//----
// THE LAST ELEMENT, NO POST-PROCESS REQUIRED
if (index === this.size() - 1)
return;
// LIST UP NEIGHBORS
var prev = it.prev();
var next = it.next();
// ARRANGE LEFT SIDE
if ((0, comparators_1.not_equal_to)(prev, this.data_.end()) && prev.second === it.second)
this.data_.erase(it);
// ARRANGE RIGHT SIDE
if (next.equals(this.data_.end()) === true ||
next.first !== index + 1 ||
next.second !== val) {
// 1) IT'S THE LAST NODE
// 2) NEXT NODE DOES NOT POINT THE INDEX + 1 (NEAREST NEIGHBOR)
// 3) NEXT NODE'S VALUE IS DIFFERENT WITH THE CHANGED VALUE
//----
// EMPLACE NEW NODE WITH OLD
this.data_.emplace(index + 1, !val);
}
else {
// NEXT NODE'S VALUE IS SAME WITH THE CHANGED VALUE
//----
// ERASE THE NEXT NODE
this.data_.erase(next);
}
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.nth = function (index) {
return new VectorBoolean.Iterator(this, index);
};
VectorBoolean.prototype._Find_node = function (index) {
return this.data_.upper_bound(index).prev();
};
/* =========================================================
ELEMENTS I/O
- PUSH & POP
- INSERT
- ERASE
============================================================
PUSH & POP
--------------------------------------------------------- */
/**
* @inheritDoc
*/
VectorBoolean.prototype.push = function () {
var items = [];
for (var _i = 0; _i < arguments.length; _i++) {
items[_i] = arguments[_i];
}
if (items.length === 0)
return this.size();
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 this.size();
};
/**
* @inheritDoc
*/
VectorBoolean.prototype.push_back = function (val) {
var it = this.data_.rbegin();
var index = this.size_++;
val = !!val; // SIFT
// EMPLACE OR NOT
if (this.data_.empty() || it.second !== val)
this.data_.emplace(index, val);
};
VectorBoolean.prototype._Pop_back = function () {
var it = this.data_.rbegin();
var index = --this.size_;
// ERASE OR NOT
if (it.first === index)
this.data_.erase(it.base());
};
/* ---------------------------------------------------------
INSERT
--------------------------------------------------------- */
VectorBoolean.prototype._Insert_by_repeating_val = function (pos, n, val) {
// RESERVE ELEMENTS -> THE REPEATED COUNT AND VALUE
var elements = [];
elements.push(new Pair_1.Pair(n, val));
// DO INSERT
if (pos.equals(this.end()) === true)
return this._Insert_to_end(elements);
else
return this._Insert_to_middle(pos, elements);
};
VectorBoolean.prototype._Insert_by_range = function (pos, first, last) {
// RESERVE ELEMENTS -> REPEATED SIZE & VALUE
var elements = [];
for (var it = first; !it.equals(last); it = it.next()) {
if (elements.length === 0 ||
elements[elements.length - 1].second !== it.value)
elements.push(new Pair_1.Pair(1, it.value));
else
++elements[elements.length - 1].first;
}
if (pos.equals(this.end()) === true)
return this._Insert_to_end(elements);
else
return this._Insert_to_middle(pos, elements);
};
VectorBoolean.prototype._Insert_to_middle = function (pos, elements) {
var first = this._Find_node(pos.index());
for (var it = first; !it.equals(this.data_.end()); it = it.next()) {
// COMPUTE SIZE TO ENROLL
var next = it.next();
var sx = it.first < pos.index()
? pos.index() // POSITION TO INSERT
: it.first; // CURRENT POINT
var sy = next.equals(this.data_.end())
? this.size() // IT'S THE LAST ELEMENT
: next.first; // TO NEXT ELEMENT
// DO ENROLL
var size = sy - sx;
var value = !!it.second;
elements.push(new Pair_1.Pair(size, value));
}
// ERASE BACK-SIDE ELEMENTS FOR THE POST-INSERTION
this.size_ = pos.index();
this.data_.erase(first.first === pos.index() ? first : first.next(), this.data_.end());
// DO POST-INSERTION
return this._Insert_to_end(elements);
};
VectorBoolean.prototype._Insert_to_end = function (elements) {
var old_size = this.size();
var last_value = this.data_.empty()
? null
: this.data_.rbegin().second;
for (var i = 0; i < elements.length; ++i) {
var p = elements[i];
// INDEXING
var index = this.size();
var value = !!p.second;
this.size_ += p.first;
// NEED NOT TO EMPLACE, JUST SKIP
if (i === 0 && value === last_value)
continue;
// DO EMPLACE
this.data_.emplace(index, value);
}
return this.begin().advance(old_size);
};
/* ---------------------------------------------------------
ERASE
--------------------------------------------------------- */
VectorBoolean.prototype._Erase_by_range = function (first, last) {
var elements = [];
if (last.equals(this.end()) === false) {
var last_index = Math.min(this.size(), last.index());
for (var it = this._Find_node(last_index); !it.equals(this.data_.end()); it = it.next()) {
var next = it.next();
var sx = Math.max(it.first, last_index);
var sy = next.equals(this.data_.end())
? this.size() // IT'S THE LAST ELEMENT
: next.first; // TO NEXT ELEMENT
var size = sy - sx;
var value = it.second;
elements.push(new Pair_1.Pair(size, value));
}
}
this.size_ = first.index();
this.data_.erase(this.data_.lower_bound(this.size_), this.data_.end());
return this._Insert_to_end(elements);
};
return VectorBoolean;
}(ArrayContainer_1.ArrayContainer));
exports.VectorBoolean = VectorBoolean;
/**
*
*/
(function (VectorBoolean) {
// BODY
VectorBoolean.Iterator = ArrayIterator_1.ArrayIterator;
VectorBoolean.ReverseIterator = ArrayReverseIterator_1.ArrayReverseIterator;
})(VectorBoolean = exports.VectorBoolean || (exports.VectorBoolean = {}));
exports.VectorBoolean = VectorBoolean;
//# sourceMappingURL=VectorBoolean.js.map
-20
View File
@@ -1,20 +0,0 @@
/**
* @packageDocumentation
* @module std
*/
export * from "./Vector";
export * from "./Deque";
export * from "./List";
export * from "./VectorBoolean";
export * from "./ForwardList";
export * from "./TreeSet";
export * from "./HashSet";
export * from "./TreeMultiSet";
export * from "./HashMultiSet";
export * from "./TreeMap";
export * from "./HashMap";
export * from "./TreeMultiMap";
export * from "./HashMultiMap";
export * from "./Stack";
export * from "./Queue";
export * from "./PriorityQueue";
-53
View File
@@ -1,53 +0,0 @@
"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
*/
//================================================================
//--------
// LINEAR CONTAINERS
//--------
// FORMAL CONTAINERS
__exportStar(require("./Vector"), exports);
__exportStar(require("./Deque"), exports);
__exportStar(require("./List"), exports);
// SPECIAL CONTAINERS
__exportStar(require("./VectorBoolean"), exports);
__exportStar(require("./ForwardList"), exports);
//--------
// ASSOCIATIVE CONTAINERS
//--------
// SETS
__exportStar(require("./TreeSet"), exports);
__exportStar(require("./HashSet"), exports);
__exportStar(require("./TreeMultiSet"), exports);
__exportStar(require("./HashMultiSet"), exports);
// MAPS
__exportStar(require("./TreeMap"), exports);
__exportStar(require("./HashMap"), exports);
__exportStar(require("./TreeMultiMap"), exports);
__exportStar(require("./HashMultiMap"), exports);
//--------
// ADAPTOR CONTAINERS
//--------
// LINEAR
__exportStar(require("./Stack"), exports);
__exportStar(require("./Queue"), exports);
__exportStar(require("./PriorityQueue"), exports);
//# sourceMappingURL=index.js.map