@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/es2015/index.mjs
CHANGED
|
@@ -9256,5 +9256,40 @@ class ObservableFiniteStateMachine extends FiniteStateMachine {
|
|
|
9256
9256
|
}
|
|
9257
9257
|
}
|
|
9258
9258
|
|
|
9259
|
-
|
|
9259
|
+
class SparseSet {
|
|
9260
|
+
constructor() {
|
|
9261
|
+
this.values = [];
|
|
9262
|
+
this.valueToValueIndex = [];
|
|
9263
|
+
}
|
|
9264
|
+
*[Symbol.iterator]() {
|
|
9265
|
+
for (const value of this.values) {
|
|
9266
|
+
yield value;
|
|
9267
|
+
}
|
|
9268
|
+
}
|
|
9269
|
+
has(value) {
|
|
9270
|
+
// 跟一般的实现不同, 不需要访问values数组.
|
|
9271
|
+
return es2018$2.isntUndefined(this.valueToValueIndex[value]);
|
|
9272
|
+
}
|
|
9273
|
+
add(value) {
|
|
9274
|
+
if (!this.has(value)) {
|
|
9275
|
+
const index = this.values.length;
|
|
9276
|
+
this.values.push(value);
|
|
9277
|
+
this.valueToValueIndex[value] = index;
|
|
9278
|
+
}
|
|
9279
|
+
}
|
|
9280
|
+
remove(value) {
|
|
9281
|
+
if (this.has(value)) {
|
|
9282
|
+
const lastValue = this.values.pop();
|
|
9283
|
+
if (value !== lastValue) {
|
|
9284
|
+
const indexOfValue = this.valueToValueIndex[value];
|
|
9285
|
+
this.values[indexOfValue] = lastValue;
|
|
9286
|
+
this.valueToValueIndex[lastValue] = indexOfValue;
|
|
9287
|
+
// 跟一般的实现不同, 直接删除值的索引.
|
|
9288
|
+
this.valueToValueIndex[value] = undefined;
|
|
9289
|
+
}
|
|
9290
|
+
}
|
|
9291
|
+
}
|
|
9292
|
+
}
|
|
9293
|
+
|
|
9294
|
+
export { BadEventError, Box, Emitter, ExpirableMap, FiniteStateMachine, HashMap, HashSet, LRUMap, ObservableFiniteStateMachine, Queue, SparseSet, TLRUMap, TrieMap, convertArrayToCons, convertConsToArray };
|
|
9260
9295
|
//# sourceMappingURL=index.mjs.map
|