include node_modules so release .zip is deployable
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class HashBuckets<Key, Elem> {
|
||||
private readonly fetcher_;
|
||||
private readonly hasher_;
|
||||
private max_load_factor_;
|
||||
private data_;
|
||||
private size_;
|
||||
constructor(fetcher: Fetcher<Key, Elem>, hasher: Hasher<Key>);
|
||||
clear(): void;
|
||||
rehash(length: number): void;
|
||||
reserve(length: number): void;
|
||||
private initialize;
|
||||
length(): number;
|
||||
capacity(): number;
|
||||
at(index: number): Elem[];
|
||||
load_factor(): number;
|
||||
max_load_factor(): number;
|
||||
max_load_factor(z: number): void;
|
||||
hash_function(): Hasher<Key>;
|
||||
private index;
|
||||
insert(val: Elem): void;
|
||||
erase(val: Elem): void;
|
||||
}
|
||||
declare type Fetcher<Key, Elem> = (elem: Elem) => Key;
|
||||
export {};
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HashBuckets = void 0;
|
||||
/**
|
||||
* Hash buckets
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var HashBuckets = /** @class */ (function () {
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
function HashBuckets(fetcher, hasher) {
|
||||
this.fetcher_ = fetcher;
|
||||
this.hasher_ = hasher;
|
||||
this.max_load_factor_ = DEFAULT_MAX_FACTOR;
|
||||
this.data_ = [];
|
||||
this.size_ = 0;
|
||||
this.initialize();
|
||||
}
|
||||
HashBuckets.prototype.clear = function () {
|
||||
this.data_ = [];
|
||||
this.size_ = 0;
|
||||
this.initialize();
|
||||
};
|
||||
HashBuckets.prototype.rehash = function (length) {
|
||||
var e_1, _a, e_2, _b;
|
||||
length = Math.max(length, MIN_BUCKET_COUNT);
|
||||
var data = [];
|
||||
for (var i = 0; i < length; ++i)
|
||||
data.push([]);
|
||||
try {
|
||||
for (var _c = __values(this.data_), _d = _c.next(); !_d.done; _d = _c.next()) {
|
||||
var row = _d.value;
|
||||
try {
|
||||
for (var row_1 = (e_2 = void 0, __values(row)), row_1_1 = row_1.next(); !row_1_1.done; row_1_1 = row_1.next()) {
|
||||
var elem = row_1_1.value;
|
||||
var index = this.hasher_(this.fetcher_(elem)) % data.length;
|
||||
data[index].push(elem);
|
||||
}
|
||||
}
|
||||
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (row_1_1 && !row_1_1.done && (_b = row_1.return)) _b.call(row_1);
|
||||
}
|
||||
finally { if (e_2) throw e_2.error; }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
this.data_ = data;
|
||||
};
|
||||
HashBuckets.prototype.reserve = function (length) {
|
||||
if (length > this.capacity()) {
|
||||
length = Math.floor(length / this.max_load_factor_);
|
||||
this.rehash(length);
|
||||
}
|
||||
};
|
||||
HashBuckets.prototype.initialize = function () {
|
||||
for (var i = 0; i < MIN_BUCKET_COUNT; ++i)
|
||||
this.data_.push([]);
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ACCESSORS
|
||||
--------------------------------------------------------- */
|
||||
HashBuckets.prototype.length = function () {
|
||||
return this.data_.length;
|
||||
};
|
||||
HashBuckets.prototype.capacity = function () {
|
||||
return this.data_.length * this.max_load_factor_;
|
||||
};
|
||||
HashBuckets.prototype.at = function (index) {
|
||||
return this.data_[index];
|
||||
};
|
||||
HashBuckets.prototype.load_factor = function () {
|
||||
return this.size_ / this.length();
|
||||
};
|
||||
HashBuckets.prototype.max_load_factor = function (z) {
|
||||
if (z === void 0) { z = null; }
|
||||
if (z === null)
|
||||
return this.max_load_factor_;
|
||||
else
|
||||
this.max_load_factor_ = z;
|
||||
};
|
||||
HashBuckets.prototype.hash_function = function () {
|
||||
return this.hasher_;
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
ELEMENTS I/O
|
||||
--------------------------------------------------------- */
|
||||
HashBuckets.prototype.index = function (elem) {
|
||||
return this.hasher_(this.fetcher_(elem)) % this.length();
|
||||
};
|
||||
HashBuckets.prototype.insert = function (val) {
|
||||
var capacity = this.capacity();
|
||||
if (++this.size_ > capacity)
|
||||
this.reserve(capacity * 2);
|
||||
var index = this.index(val);
|
||||
this.data_[index].push(val);
|
||||
};
|
||||
HashBuckets.prototype.erase = function (val) {
|
||||
var index = this.index(val);
|
||||
var bucket = this.data_[index];
|
||||
for (var i = 0; i < bucket.length; ++i)
|
||||
if (bucket[i] === val) {
|
||||
bucket.splice(i, 1);
|
||||
--this.size_;
|
||||
break;
|
||||
}
|
||||
};
|
||||
return HashBuckets;
|
||||
}());
|
||||
exports.HashBuckets = HashBuckets;
|
||||
var MIN_BUCKET_COUNT = 10;
|
||||
var DEFAULT_MAX_FACTOR = 1.0;
|
||||
//# sourceMappingURL=HashBuckets.js.map
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { HashBuckets } from "./HashBuckets";
|
||||
import { IHashMap } from "../../base/container/IHashMap";
|
||||
import { Comparator } from "../functional/Comparator";
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets for map containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class MapHashBuckets<Key, T, Unique extends boolean, Source extends IHashMap<Key, T, Unique, Source>> extends HashBuckets<Key, IHashMap.Iterator<Key, T, Unique, Source>> {
|
||||
private source_;
|
||||
private readonly key_eq_;
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source map container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
constructor(source: Source, hasher: Hasher<Key>, pred: Comparator<Key>);
|
||||
key_eq(): Comparator<Key>;
|
||||
find(key: Key): IHashMap.Iterator<Key, T, Unique, Source>;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MapHashBuckets = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var HashBuckets_1 = require("./HashBuckets");
|
||||
/**
|
||||
* Hash buckets for map containers.
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var MapHashBuckets = /** @class */ (function (_super) {
|
||||
__extends(MapHashBuckets, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source map container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
function MapHashBuckets(source, hasher, pred) {
|
||||
var _this = _super.call(this, fetcher, hasher) || this;
|
||||
_this.source_ = source;
|
||||
_this.key_eq_ = pred;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
MapHashBuckets._Swap_source = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
FINDERS
|
||||
--------------------------------------------------------- */
|
||||
MapHashBuckets.prototype.key_eq = function () {
|
||||
return this.key_eq_;
|
||||
};
|
||||
MapHashBuckets.prototype.find = function (key) {
|
||||
var e_1, _a;
|
||||
var index = this.hash_function()(key) % this.length();
|
||||
var bucket = this.at(index);
|
||||
try {
|
||||
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
|
||||
var it = bucket_1_1.value;
|
||||
if (this.key_eq_(it.first, key))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return this.source_.end();
|
||||
};
|
||||
return MapHashBuckets;
|
||||
}(HashBuckets_1.HashBuckets));
|
||||
exports.MapHashBuckets = MapHashBuckets;
|
||||
function fetcher(elem) {
|
||||
return elem.first;
|
||||
}
|
||||
//# sourceMappingURL=MapHashBuckets.js.map
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
import { HashBuckets } from "./HashBuckets";
|
||||
import { IHashSet } from "../../base/container/IHashSet";
|
||||
import { Comparator } from "../functional/Comparator";
|
||||
import { Hasher } from "../functional/Hasher";
|
||||
/**
|
||||
* Hash buckets for set containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
export declare class SetHashBuckets<Key, Unique extends boolean, Source extends IHashSet<Key, Unique, Source>> extends HashBuckets<Key, IHashSet.Iterator<Key, Unique, Source>> {
|
||||
private source_;
|
||||
private readonly key_eq_;
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source set container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
constructor(source: IHashSet<Key, Unique, Source>, hasher: Hasher<Key>, pred: Comparator<Key>);
|
||||
key_eq(): Comparator<Key>;
|
||||
find(val: Key): IHashSet.Iterator<Key, Unique, Source>;
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
var __values = (this && this.__values) || function(o) {
|
||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
||||
if (m) return m.call(o);
|
||||
if (o && typeof o.length === "number") return {
|
||||
next: function () {
|
||||
if (o && i >= o.length) o = void 0;
|
||||
return { value: o && o[i++], done: !o };
|
||||
}
|
||||
};
|
||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SetHashBuckets = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std.internal
|
||||
*/
|
||||
//================================================================
|
||||
var HashBuckets_1 = require("./HashBuckets");
|
||||
/**
|
||||
* Hash buckets for set containers
|
||||
*
|
||||
* @author Jeongho Nam - https://github.com/samchon
|
||||
*/
|
||||
var SetHashBuckets = /** @class */ (function (_super) {
|
||||
__extends(SetHashBuckets, _super);
|
||||
/* ---------------------------------------------------------
|
||||
CONSTRUCTORS
|
||||
--------------------------------------------------------- */
|
||||
/**
|
||||
* Initializer Constructor
|
||||
*
|
||||
* @param source Source set container
|
||||
* @param hasher Hash function
|
||||
* @param pred Equality function
|
||||
*/
|
||||
function SetHashBuckets(source, hasher, pred) {
|
||||
var _this = _super.call(this, fetcher, hasher) || this;
|
||||
_this.source_ = source;
|
||||
_this.key_eq_ = pred;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
SetHashBuckets._Swap_source = function (x, y) {
|
||||
var _a;
|
||||
_a = __read([y.source_, x.source_], 2), x.source_ = _a[0], y.source_ = _a[1];
|
||||
};
|
||||
/* ---------------------------------------------------------
|
||||
FINDERS
|
||||
--------------------------------------------------------- */
|
||||
SetHashBuckets.prototype.key_eq = function () {
|
||||
return this.key_eq_;
|
||||
};
|
||||
SetHashBuckets.prototype.find = function (val) {
|
||||
var e_1, _a;
|
||||
var index = this.hash_function()(val) % this.length();
|
||||
var bucket = this.at(index);
|
||||
try {
|
||||
for (var bucket_1 = __values(bucket), bucket_1_1 = bucket_1.next(); !bucket_1_1.done; bucket_1_1 = bucket_1.next()) {
|
||||
var it = bucket_1_1.value;
|
||||
if (this.key_eq_(it.value, val))
|
||||
return it;
|
||||
}
|
||||
}
|
||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||
finally {
|
||||
try {
|
||||
if (bucket_1_1 && !bucket_1_1.done && (_a = bucket_1.return)) _a.call(bucket_1);
|
||||
}
|
||||
finally { if (e_1) throw e_1.error; }
|
||||
}
|
||||
return this.source_.end();
|
||||
};
|
||||
return SetHashBuckets;
|
||||
}(HashBuckets_1.HashBuckets));
|
||||
exports.SetHashBuckets = SetHashBuckets;
|
||||
function fetcher(elem) {
|
||||
return elem.value;
|
||||
}
|
||||
//# sourceMappingURL=SetHashBuckets.js.map
|
||||
Reference in New Issue
Block a user