@blackglory/structures 0.6.8 → 0.7.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 +17 -1
- package/dist/es2015/index.min.mjs +2 -2
- package/dist/es2015/index.min.mjs.map +1 -1
- package/dist/es2015/index.mjs +97 -39
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +97 -38
- 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 +97 -39
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +97 -38
- 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 +1 -0
- package/lib/es2015/index.js +1 -0
- package/lib/es2015/index.js.map +1 -1
- package/lib/es2015/sparse-map.d.ts +13 -0
- package/lib/es2015/sparse-map.js +67 -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 +16 -20
- package/lib/es2015/sparse-set.js.map +1 -1
- package/lib/es2018/index.d.ts +1 -0
- package/lib/es2018/index.js +1 -0
- package/lib/es2018/index.js.map +1 -1
- package/lib/es2018/sparse-map.d.ts +13 -0
- package/lib/es2018/sparse-map.js +67 -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 +16 -20
- package/lib/es2018/sparse-set.js.map +1 -1
- package/package.json +1 -1
package/dist/es2015/index.umd.js
CHANGED
|
@@ -9647,44 +9647,6 @@
|
|
|
9647
9647
|
}
|
|
9648
9648
|
}
|
|
9649
9649
|
|
|
9650
|
-
class SparseSet {
|
|
9651
|
-
constructor() {
|
|
9652
|
-
this.values = [];
|
|
9653
|
-
this.valueToValueIndex = [];
|
|
9654
|
-
}
|
|
9655
|
-
get [Symbol.toStringTag]() {
|
|
9656
|
-
return this.constructor.name;
|
|
9657
|
-
}
|
|
9658
|
-
*[Symbol.iterator]() {
|
|
9659
|
-
for (const value of this.values) {
|
|
9660
|
-
yield value;
|
|
9661
|
-
}
|
|
9662
|
-
}
|
|
9663
|
-
has(value) {
|
|
9664
|
-
const index = this.valueToValueIndex[value];
|
|
9665
|
-
return es2018$e.isUndefined(index)
|
|
9666
|
-
? false
|
|
9667
|
-
: this.values[index] === value;
|
|
9668
|
-
}
|
|
9669
|
-
add(value) {
|
|
9670
|
-
if (!this.has(value)) {
|
|
9671
|
-
const index = this.values.length;
|
|
9672
|
-
this.values.push(value);
|
|
9673
|
-
this.valueToValueIndex[value] = index;
|
|
9674
|
-
}
|
|
9675
|
-
}
|
|
9676
|
-
remove(value) {
|
|
9677
|
-
if (this.has(value)) {
|
|
9678
|
-
const lastValue = this.values.pop();
|
|
9679
|
-
if (value !== lastValue) {
|
|
9680
|
-
const indexOfValue = this.valueToValueIndex[value];
|
|
9681
|
-
this.values[indexOfValue] = lastValue;
|
|
9682
|
-
this.valueToValueIndex[lastValue] = indexOfValue;
|
|
9683
|
-
}
|
|
9684
|
-
}
|
|
9685
|
-
}
|
|
9686
|
-
}
|
|
9687
|
-
|
|
9688
9650
|
// 相关提案: https://github.com/tc39/proposal-resizablearraybuffer
|
|
9689
9651
|
class DynamicTypedArray {
|
|
9690
9652
|
constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
|
|
@@ -9805,6 +9767,102 @@
|
|
|
9805
9767
|
}
|
|
9806
9768
|
}
|
|
9807
9769
|
|
|
9770
|
+
class SparseSet {
|
|
9771
|
+
constructor() {
|
|
9772
|
+
this.indexToValue = new DynamicTypedArray(Uint32Array);
|
|
9773
|
+
this.valueToIndex = new DynamicTypedArray(Uint32Array);
|
|
9774
|
+
}
|
|
9775
|
+
get [Symbol.toStringTag]() {
|
|
9776
|
+
return this.constructor.name;
|
|
9777
|
+
}
|
|
9778
|
+
[Symbol.iterator]() {
|
|
9779
|
+
return this.indexToValue.internalTypedArray[Symbol.iterator]();
|
|
9780
|
+
}
|
|
9781
|
+
has(value) {
|
|
9782
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
9783
|
+
return this.indexToValue.internalTypedArray[index] === value;
|
|
9784
|
+
}
|
|
9785
|
+
add(value) {
|
|
9786
|
+
if (!this.has(value)) {
|
|
9787
|
+
const index = this.indexToValue.length;
|
|
9788
|
+
this.indexToValue.push(value);
|
|
9789
|
+
this.valueToIndex.set(value, index);
|
|
9790
|
+
}
|
|
9791
|
+
}
|
|
9792
|
+
delete(value) {
|
|
9793
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
9794
|
+
if (this.indexToValue.internalTypedArray[index] === value) {
|
|
9795
|
+
const lastValue = this.indexToValue.pop();
|
|
9796
|
+
if (value !== lastValue) {
|
|
9797
|
+
this.indexToValue.internalTypedArray[index] = lastValue;
|
|
9798
|
+
this.valueToIndex.internalTypedArray[lastValue] = index;
|
|
9799
|
+
}
|
|
9800
|
+
}
|
|
9801
|
+
}
|
|
9802
|
+
}
|
|
9803
|
+
|
|
9804
|
+
class SparseMap {
|
|
9805
|
+
constructor() {
|
|
9806
|
+
this.keyToIndex = new DynamicTypedArray(Uint32Array);
|
|
9807
|
+
this.indexToKey = new DynamicTypedArray(Uint32Array);
|
|
9808
|
+
this.indexToValue = new DynamicTypedArray(Uint32Array);
|
|
9809
|
+
}
|
|
9810
|
+
get [Symbol.toStringTag]() {
|
|
9811
|
+
return this.constructor.name;
|
|
9812
|
+
}
|
|
9813
|
+
*entries() {
|
|
9814
|
+
for (let i = 0; i < this.indexToKey.length; i++) {
|
|
9815
|
+
yield [
|
|
9816
|
+
this.indexToKey.internalTypedArray[i],
|
|
9817
|
+
this.indexToValue.internalTypedArray[i]
|
|
9818
|
+
];
|
|
9819
|
+
}
|
|
9820
|
+
}
|
|
9821
|
+
keys() {
|
|
9822
|
+
return this.indexToKey.internalTypedArray.values();
|
|
9823
|
+
}
|
|
9824
|
+
values() {
|
|
9825
|
+
return this.indexToValue.internalTypedArray.values();
|
|
9826
|
+
}
|
|
9827
|
+
has(key) {
|
|
9828
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9829
|
+
return this.indexToKey.internalTypedArray[index] === key;
|
|
9830
|
+
}
|
|
9831
|
+
get(key) {
|
|
9832
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9833
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9834
|
+
return this.indexToValue.internalTypedArray[index];
|
|
9835
|
+
}
|
|
9836
|
+
else {
|
|
9837
|
+
return undefined;
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
set(key, value) {
|
|
9841
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9842
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9843
|
+
this.indexToValue.internalTypedArray[index] = value;
|
|
9844
|
+
}
|
|
9845
|
+
else {
|
|
9846
|
+
const index = this.indexToKey.length;
|
|
9847
|
+
this.indexToKey.push(key);
|
|
9848
|
+
this.indexToValue.push(value);
|
|
9849
|
+
this.keyToIndex.set(key, index);
|
|
9850
|
+
}
|
|
9851
|
+
}
|
|
9852
|
+
delete(key) {
|
|
9853
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9854
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9855
|
+
const lastKey = this.indexToKey.pop();
|
|
9856
|
+
const lastValue = this.indexToValue.pop();
|
|
9857
|
+
if (key !== lastKey) {
|
|
9858
|
+
this.indexToKey.internalTypedArray[index] = lastKey;
|
|
9859
|
+
this.indexToValue.internalTypedArray[index] = lastValue;
|
|
9860
|
+
this.keyToIndex.internalTypedArray[lastKey] = index;
|
|
9861
|
+
}
|
|
9862
|
+
}
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
|
|
9808
9866
|
exports.BadEventError = BadEventError;
|
|
9809
9867
|
exports.Box = Box;
|
|
9810
9868
|
exports.DynamicTypedArray = DynamicTypedArray;
|
|
@@ -9816,6 +9874,7 @@
|
|
|
9816
9874
|
exports.LRUMap = LRUMap;
|
|
9817
9875
|
exports.ObservableFiniteStateMachine = ObservableFiniteStateMachine;
|
|
9818
9876
|
exports.Queue = Queue;
|
|
9877
|
+
exports.SparseMap = SparseMap;
|
|
9819
9878
|
exports.SparseSet = SparseSet;
|
|
9820
9879
|
exports.TLRUMap = TLRUMap;
|
|
9821
9880
|
exports.TrieMap = TrieMap;
|