@blackglory/structures 0.6.1 → 0.6.4
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 +16 -5
- package/dist/es2015/index.min.mjs +2 -2
- package/dist/es2015/index.min.mjs.map +1 -1
- package/dist/es2015/index.mjs +36 -1
- package/dist/es2015/index.mjs.map +1 -1
- package/dist/es2015/index.umd.js +36 -0
- 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 +36 -1
- package/dist/es2018/index.mjs.map +1 -1
- package/dist/es2018/index.umd.js +36 -0
- 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/hash-map.d.ts +2 -2
- package/lib/es2015/hash-map.js.map +1 -1
- package/lib/es2015/hash-set.d.ts +2 -2
- package/lib/es2015/hash-set.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-set.d.ts +8 -0
- package/lib/es2015/sparse-set.js +38 -0
- package/lib/es2015/sparse-set.js.map +1 -0
- package/lib/es2015/trie-map.d.ts +1 -2
- package/lib/es2015/trie-map.js.map +1 -1
- package/lib/es2018/hash-map.d.ts +2 -2
- package/lib/es2018/hash-map.js.map +1 -1
- package/lib/es2018/hash-set.d.ts +2 -2
- package/lib/es2018/hash-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-set.d.ts +8 -0
- package/lib/es2018/sparse-set.js +38 -0
- package/lib/es2018/sparse-set.js.map +1 -0
- package/lib/es2018/trie-map.d.ts +1 -2
- package/lib/es2018/trie-map.js.map +1 -1
- package/package.json +1 -1
package/dist/es2018/index.umd.js
CHANGED
|
@@ -9262,6 +9262,41 @@
|
|
|
9262
9262
|
}
|
|
9263
9263
|
}
|
|
9264
9264
|
|
|
9265
|
+
class SparseSet {
|
|
9266
|
+
constructor() {
|
|
9267
|
+
this.values = [];
|
|
9268
|
+
this.valueToValueIndex = [];
|
|
9269
|
+
}
|
|
9270
|
+
*[Symbol.iterator]() {
|
|
9271
|
+
for (const value of this.values) {
|
|
9272
|
+
yield value;
|
|
9273
|
+
}
|
|
9274
|
+
}
|
|
9275
|
+
has(value) {
|
|
9276
|
+
// 跟一般的实现不同, 不需要访问values数组.
|
|
9277
|
+
return es2018$2.isntUndefined(this.valueToValueIndex[value]);
|
|
9278
|
+
}
|
|
9279
|
+
add(value) {
|
|
9280
|
+
if (!this.has(value)) {
|
|
9281
|
+
const index = this.values.length;
|
|
9282
|
+
this.values.push(value);
|
|
9283
|
+
this.valueToValueIndex[value] = index;
|
|
9284
|
+
}
|
|
9285
|
+
}
|
|
9286
|
+
remove(value) {
|
|
9287
|
+
if (this.has(value)) {
|
|
9288
|
+
const lastValue = this.values.pop();
|
|
9289
|
+
if (value !== lastValue) {
|
|
9290
|
+
const indexOfValue = this.valueToValueIndex[value];
|
|
9291
|
+
this.values[indexOfValue] = lastValue;
|
|
9292
|
+
this.valueToValueIndex[lastValue] = indexOfValue;
|
|
9293
|
+
// 跟一般的实现不同, 直接删除值的索引.
|
|
9294
|
+
this.valueToValueIndex[value] = undefined;
|
|
9295
|
+
}
|
|
9296
|
+
}
|
|
9297
|
+
}
|
|
9298
|
+
}
|
|
9299
|
+
|
|
9265
9300
|
exports.BadEventError = BadEventError;
|
|
9266
9301
|
exports.Box = Box;
|
|
9267
9302
|
exports.Emitter = Emitter;
|
|
@@ -9272,6 +9307,7 @@
|
|
|
9272
9307
|
exports.LRUMap = LRUMap;
|
|
9273
9308
|
exports.ObservableFiniteStateMachine = ObservableFiniteStateMachine;
|
|
9274
9309
|
exports.Queue = Queue;
|
|
9310
|
+
exports.SparseSet = SparseSet;
|
|
9275
9311
|
exports.TLRUMap = TLRUMap;
|
|
9276
9312
|
exports.TrieMap = TrieMap;
|
|
9277
9313
|
exports.convertArrayToCons = convertArrayToCons;
|