@blackglory/structures 0.6.0 → 0.6.3

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.
Files changed (44) hide show
  1. package/README.md +20 -5
  2. package/dist/es2015/index.min.mjs +2 -2
  3. package/dist/es2015/index.min.mjs.map +1 -1
  4. package/dist/es2015/index.mjs +54 -1
  5. package/dist/es2015/index.mjs.map +1 -1
  6. package/dist/es2015/index.umd.js +54 -0
  7. package/dist/es2015/index.umd.js.map +1 -1
  8. package/dist/es2015/index.umd.min.js +2 -2
  9. package/dist/es2015/index.umd.min.js.map +1 -1
  10. package/dist/es2018/index.min.mjs +2 -2
  11. package/dist/es2018/index.min.mjs.map +1 -1
  12. package/dist/es2018/index.mjs +54 -1
  13. package/dist/es2018/index.mjs.map +1 -1
  14. package/dist/es2018/index.umd.js +54 -0
  15. package/dist/es2018/index.umd.js.map +1 -1
  16. package/dist/es2018/index.umd.min.js +2 -2
  17. package/dist/es2018/index.umd.min.js.map +1 -1
  18. package/lib/es2015/hash-map.d.ts +2 -2
  19. package/lib/es2015/hash-map.js.map +1 -1
  20. package/lib/es2015/hash-set.d.ts +2 -2
  21. package/lib/es2015/hash-set.js.map +1 -1
  22. package/lib/es2015/index.d.ts +1 -0
  23. package/lib/es2015/index.js +1 -0
  24. package/lib/es2015/index.js.map +1 -1
  25. package/lib/es2015/sparse-set.d.ts +8 -0
  26. package/lib/es2015/sparse-set.js +37 -0
  27. package/lib/es2015/sparse-set.js.map +1 -0
  28. package/lib/es2015/trie-map.d.ts +4 -2
  29. package/lib/es2015/trie-map.js +19 -0
  30. package/lib/es2015/trie-map.js.map +1 -1
  31. package/lib/es2018/hash-map.d.ts +2 -2
  32. package/lib/es2018/hash-map.js.map +1 -1
  33. package/lib/es2018/hash-set.d.ts +2 -2
  34. package/lib/es2018/hash-set.js.map +1 -1
  35. package/lib/es2018/index.d.ts +1 -0
  36. package/lib/es2018/index.js +1 -0
  37. package/lib/es2018/index.js.map +1 -1
  38. package/lib/es2018/sparse-set.d.ts +8 -0
  39. package/lib/es2018/sparse-set.js +37 -0
  40. package/lib/es2018/sparse-set.js.map +1 -0
  41. package/lib/es2018/trie-map.d.ts +4 -2
  42. package/lib/es2018/trie-map.js +19 -0
  43. package/lib/es2018/trie-map.js.map +1 -1
  44. package/package.json +1 -1
@@ -7558,6 +7558,24 @@ class TrieMap {
7558
7558
  get [Symbol.toStringTag]() {
7559
7559
  return this.constructor.name;
7560
7560
  }
7561
+ *entries() {
7562
+ yield* dfs(this.root, []);
7563
+ function* dfs(node, paths) {
7564
+ for (const [path, childNode] of node.children) {
7565
+ const newPaths = [...paths, path];
7566
+ if (es2018$2.isntUndefined(childNode.value)) {
7567
+ yield [newPaths, childNode.value];
7568
+ }
7569
+ yield* dfs(childNode, newPaths);
7570
+ }
7571
+ }
7572
+ }
7573
+ keys() {
7574
+ return es2018$4.map(this.entries(), ([key]) => key);
7575
+ }
7576
+ values() {
7577
+ return es2018$4.map(this.entries(), ([_, value]) => value);
7578
+ }
7561
7579
  set(key, value) {
7562
7580
  let node = this.root;
7563
7581
  for (const part of key) {
@@ -9238,5 +9256,40 @@ class ObservableFiniteStateMachine extends FiniteStateMachine {
9238
9256
  }
9239
9257
  }
9240
9258
 
9241
- export { BadEventError, Box, Emitter, ExpirableMap, FiniteStateMachine, HashMap, HashSet, LRUMap, ObservableFiniteStateMachine, Queue, TLRUMap, TrieMap, convertArrayToCons, convertConsToArray };
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 this.valueToValueIndex[value] !== undefined;
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 };
9242
9295
  //# sourceMappingURL=index.mjs.map