@blackglory/structures 0.6.10 → 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 -40
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +97 -39
- 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 -40
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +97 -39
- 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 -19
- 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 -19
- package/lib/es2018/sparse-set.js.map +1 -1
- package/package.json +1 -1
package/dist/es2018/index.mjs
CHANGED
|
@@ -9641,45 +9641,6 @@ class ObservableFiniteStateMachine extends FiniteStateMachine {
|
|
|
9641
9641
|
}
|
|
9642
9642
|
}
|
|
9643
9643
|
|
|
9644
|
-
class SparseSet {
|
|
9645
|
-
constructor() {
|
|
9646
|
-
this.values = [];
|
|
9647
|
-
this.valueToValueIndex = [];
|
|
9648
|
-
}
|
|
9649
|
-
get [Symbol.toStringTag]() {
|
|
9650
|
-
return this.constructor.name;
|
|
9651
|
-
}
|
|
9652
|
-
[Symbol.iterator]() {
|
|
9653
|
-
return this.values[Symbol.iterator]();
|
|
9654
|
-
}
|
|
9655
|
-
has(value) {
|
|
9656
|
-
// 跟一般的实现不同, 不需要访问values数组.
|
|
9657
|
-
return es2018$e.isntUndefined(this.valueToValueIndex[value]);
|
|
9658
|
-
}
|
|
9659
|
-
add(value) {
|
|
9660
|
-
if (!this.has(value)) {
|
|
9661
|
-
const index = this.values.length;
|
|
9662
|
-
this.values.push(value);
|
|
9663
|
-
this.valueToValueIndex[value] = index;
|
|
9664
|
-
}
|
|
9665
|
-
}
|
|
9666
|
-
remove(value) {
|
|
9667
|
-
if (this.has(value)) {
|
|
9668
|
-
const lastValue = this.values.pop();
|
|
9669
|
-
if (value === lastValue) {
|
|
9670
|
-
this.valueToValueIndex[value] = undefined;
|
|
9671
|
-
}
|
|
9672
|
-
else {
|
|
9673
|
-
const indexOfValue = this.valueToValueIndex[value];
|
|
9674
|
-
this.values[indexOfValue] = lastValue;
|
|
9675
|
-
this.valueToValueIndex[lastValue] = indexOfValue;
|
|
9676
|
-
// 跟一般的实现不同, 直接删除值的索引.
|
|
9677
|
-
this.valueToValueIndex[value] = undefined;
|
|
9678
|
-
}
|
|
9679
|
-
}
|
|
9680
|
-
}
|
|
9681
|
-
}
|
|
9682
|
-
|
|
9683
9644
|
// 相关提案: https://github.com/tc39/proposal-resizablearraybuffer
|
|
9684
9645
|
class DynamicTypedArray {
|
|
9685
9646
|
constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
|
|
@@ -9800,5 +9761,101 @@ function computeNewCapacity(oldCapacity, targetLength, growthFactor) {
|
|
|
9800
9761
|
}
|
|
9801
9762
|
}
|
|
9802
9763
|
|
|
9803
|
-
|
|
9764
|
+
class SparseSet {
|
|
9765
|
+
constructor() {
|
|
9766
|
+
this.indexToValue = new DynamicTypedArray(Uint32Array);
|
|
9767
|
+
this.valueToIndex = new DynamicTypedArray(Uint32Array);
|
|
9768
|
+
}
|
|
9769
|
+
get [Symbol.toStringTag]() {
|
|
9770
|
+
return this.constructor.name;
|
|
9771
|
+
}
|
|
9772
|
+
[Symbol.iterator]() {
|
|
9773
|
+
return this.indexToValue.internalTypedArray[Symbol.iterator]();
|
|
9774
|
+
}
|
|
9775
|
+
has(value) {
|
|
9776
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
9777
|
+
return this.indexToValue.internalTypedArray[index] === value;
|
|
9778
|
+
}
|
|
9779
|
+
add(value) {
|
|
9780
|
+
if (!this.has(value)) {
|
|
9781
|
+
const index = this.indexToValue.length;
|
|
9782
|
+
this.indexToValue.push(value);
|
|
9783
|
+
this.valueToIndex.set(value, index);
|
|
9784
|
+
}
|
|
9785
|
+
}
|
|
9786
|
+
delete(value) {
|
|
9787
|
+
const index = this.valueToIndex.internalTypedArray[value];
|
|
9788
|
+
if (this.indexToValue.internalTypedArray[index] === value) {
|
|
9789
|
+
const lastValue = this.indexToValue.pop();
|
|
9790
|
+
if (value !== lastValue) {
|
|
9791
|
+
this.indexToValue.internalTypedArray[index] = lastValue;
|
|
9792
|
+
this.valueToIndex.internalTypedArray[lastValue] = index;
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9797
|
+
|
|
9798
|
+
class SparseMap {
|
|
9799
|
+
constructor() {
|
|
9800
|
+
this.keyToIndex = new DynamicTypedArray(Uint32Array);
|
|
9801
|
+
this.indexToKey = new DynamicTypedArray(Uint32Array);
|
|
9802
|
+
this.indexToValue = new DynamicTypedArray(Uint32Array);
|
|
9803
|
+
}
|
|
9804
|
+
get [Symbol.toStringTag]() {
|
|
9805
|
+
return this.constructor.name;
|
|
9806
|
+
}
|
|
9807
|
+
*entries() {
|
|
9808
|
+
for (let i = 0; i < this.indexToKey.length; i++) {
|
|
9809
|
+
yield [
|
|
9810
|
+
this.indexToKey.internalTypedArray[i],
|
|
9811
|
+
this.indexToValue.internalTypedArray[i]
|
|
9812
|
+
];
|
|
9813
|
+
}
|
|
9814
|
+
}
|
|
9815
|
+
keys() {
|
|
9816
|
+
return this.indexToKey.internalTypedArray.values();
|
|
9817
|
+
}
|
|
9818
|
+
values() {
|
|
9819
|
+
return this.indexToValue.internalTypedArray.values();
|
|
9820
|
+
}
|
|
9821
|
+
has(key) {
|
|
9822
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9823
|
+
return this.indexToKey.internalTypedArray[index] === key;
|
|
9824
|
+
}
|
|
9825
|
+
get(key) {
|
|
9826
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9827
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9828
|
+
return this.indexToValue.internalTypedArray[index];
|
|
9829
|
+
}
|
|
9830
|
+
else {
|
|
9831
|
+
return undefined;
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
set(key, value) {
|
|
9835
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9836
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9837
|
+
this.indexToValue.internalTypedArray[index] = value;
|
|
9838
|
+
}
|
|
9839
|
+
else {
|
|
9840
|
+
const index = this.indexToKey.length;
|
|
9841
|
+
this.indexToKey.push(key);
|
|
9842
|
+
this.indexToValue.push(value);
|
|
9843
|
+
this.keyToIndex.set(key, index);
|
|
9844
|
+
}
|
|
9845
|
+
}
|
|
9846
|
+
delete(key) {
|
|
9847
|
+
const index = this.keyToIndex.internalTypedArray[key];
|
|
9848
|
+
if (this.indexToKey.internalTypedArray[index] === key) {
|
|
9849
|
+
const lastKey = this.indexToKey.pop();
|
|
9850
|
+
const lastValue = this.indexToValue.pop();
|
|
9851
|
+
if (key !== lastKey) {
|
|
9852
|
+
this.indexToKey.internalTypedArray[index] = lastKey;
|
|
9853
|
+
this.indexToValue.internalTypedArray[index] = lastValue;
|
|
9854
|
+
this.keyToIndex.internalTypedArray[lastKey] = index;
|
|
9855
|
+
}
|
|
9856
|
+
}
|
|
9857
|
+
}
|
|
9858
|
+
}
|
|
9859
|
+
|
|
9860
|
+
export { BadEventError, Box, DynamicTypedArray, Emitter, ExpirableMap, FiniteStateMachine, HashMap, HashSet, LRUMap, ObservableFiniteStateMachine, Queue, SparseMap, SparseSet, TLRUMap, TrieMap, convertArrayToCons, convertConsToArray };
|
|
9804
9861
|
//# sourceMappingURL=index.mjs.map
|