@blackglory/structures 0.6.10 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -4
- package/dist/es2015/index.min.mjs +2 -2
- package/dist/es2015/index.min.mjs.map +1 -1
- package/dist/es2015/index.mjs +174 -15
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +176 -14
- package/dist/es2015/index.umd.js.map +1 -1
- package/dist/es2015/index.umd.min.js +2 -2
- package/dist/es2015/index.umd.min.js.map +1 -1
- package/dist/es2018/index.min.mjs +2 -2
- package/dist/es2018/index.min.mjs.map +1 -1
- package/dist/es2018/index.mjs +174 -15
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +176 -14
- package/dist/es2018/index.umd.js.map +1 -1
- package/dist/es2018/index.umd.min.js +2 -2
- package/dist/es2018/index.umd.min.js.map +1 -1
- package/lib/es2015/index.d.ts +3 -0
- package/lib/es2015/index.js +3 -0
- package/lib/es2015/index.js.map +1 -1
- package/lib/es2015/sparse-map.d.ts +13 -0
- package/lib/es2015/sparse-map.js +66 -0
- package/lib/es2015/sparse-map.js.map +1 -0
- package/lib/es2015/sparse-set.d.ts +3 -3
- package/lib/es2015/sparse-set.js +14 -15
- package/lib/es2015/sparse-set.js.map +1 -1
- package/lib/es2015/typed-sparse-map.d.ts +20 -0
- package/lib/es2015/typed-sparse-map.js +67 -0
- package/lib/es2015/typed-sparse-map.js.map +1 -0
- package/lib/es2015/typed-sparse-set.d.ts +15 -0
- package/lib/es2015/typed-sparse-set.js +39 -0
- package/lib/es2015/typed-sparse-set.js.map +1 -0
- package/lib/es2018/index.d.ts +3 -0
- package/lib/es2018/index.js +3 -0
- package/lib/es2018/index.js.map +1 -1
- package/lib/es2018/sparse-map.d.ts +13 -0
- package/lib/es2018/sparse-map.js +66 -0
- package/lib/es2018/sparse-map.js.map +1 -0
- package/lib/es2018/sparse-set.d.ts +3 -3
- package/lib/es2018/sparse-set.js +14 -15
- package/lib/es2018/sparse-set.js.map +1 -1
- package/lib/es2018/typed-sparse-map.d.ts +20 -0
- package/lib/es2018/typed-sparse-map.js +67 -0
- package/lib/es2018/typed-sparse-map.js.map +1 -0
- package/lib/es2018/typed-sparse-set.d.ts +15 -0
- package/lib/es2018/typed-sparse-set.js +39 -0
- package/lib/es2018/typed-sparse-set.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UnsignedTypedArrayConstructor } from 'justypes';
|
|
2
|
+
export interface ITypedSparseSetOptions {
|
|
3
|
+
capacity?: number;
|
|
4
|
+
growthFactor?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class TypedSparseSet<T extends UnsignedTypedArrayConstructor> implements Iterable<number> {
|
|
7
|
+
private valueToIndex;
|
|
8
|
+
private indexToValue;
|
|
9
|
+
constructor(typedArrayConstructor: T, { capacity, growthFactor }?: ITypedSparseSetOptions);
|
|
10
|
+
get [Symbol.toStringTag](): string;
|
|
11
|
+
[Symbol.iterator](): IterableIterator<number>;
|
|
12
|
+
has(value: number): boolean;
|
|
13
|
+
add(value: number): void;
|
|
14
|
+
delete(value: number): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypedSparseSet = void 0;
|
|
4
|
+
const dynamic_typed_array_1 = require("./dynamic-typed-array");
|
|
5
|
+
class TypedSparseSet {
|
|
6
|
+
constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
|
|
7
|
+
this.indexToValue = new dynamic_typed_array_1.DynamicTypedArray(typedArrayConstructor, { capacity, growthFactor });
|
|
8
|
+
this.valueToIndex = new dynamic_typed_array_1.DynamicTypedArray(Uint32Array, { capacity, growthFactor });
|
|
9
|
+
}
|
|
10
|
+
get [Symbol.toStringTag]() {
|
|
11
|
+
return this.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
[Symbol.iterator]() {
|
|
14
|
+
return this.indexToValue.internalTypedArray[Symbol.iterator]();
|
|
15
|
+
}
|
|
16
|
+
has(value) {
|
|
17
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
18
|
+
return this.indexToValue.internalTypedArray[index] === value;
|
|
19
|
+
}
|
|
20
|
+
add(value) {
|
|
21
|
+
if (!this.has(value)) {
|
|
22
|
+
const index = this.indexToValue.length;
|
|
23
|
+
this.indexToValue.push(value);
|
|
24
|
+
this.valueToIndex.set(value, index);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
delete(value) {
|
|
28
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
29
|
+
if (this.indexToValue.internalTypedArray[index] === value) {
|
|
30
|
+
const lastValue = this.indexToValue.pop();
|
|
31
|
+
if (value !== lastValue) {
|
|
32
|
+
this.indexToValue.internalTypedArray[index] = lastValue;
|
|
33
|
+
this.valueToIndex.internalTypedArray[lastValue] = index;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.TypedSparseSet = TypedSparseSet;
|
|
39
|
+
//# sourceMappingURL=typed-sparse-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-sparse-set.js","sourceRoot":"","sources":["../../src/typed-sparse-set.ts"],"names":[],"mappings":";;;AACA,+DAAyD;AAOzD,MAAa,cAAc;IAMzB,YACE,qBAAwB,EACxB,EAAE,QAAQ,GAAG,CAAC,EAAE,YAAY,GAAG,GAAG,KAA6B,EAAE;QAEjE,IAAI,CAAC,YAAY,GAAG,IAAI,uCAAiB,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAA;QAC5F,IAAI,CAAC,YAAY,GAAG,IAAI,uCAAiB,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAA;IACpF,CAAC;IAED,IAAI,CAA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
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackglory/structures",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@blackglory/types": "^1.2.1",
|
|
74
74
|
"extra-timers": "^0.2.5",
|
|
75
75
|
"iterable-operator": "^1.1.0",
|
|
76
|
-
"justypes": "^2.
|
|
76
|
+
"justypes": "^2.2.0",
|
|
77
77
|
"rxjs": "^7.5.5"
|
|
78
78
|
}
|
|
79
79
|
}
|