@blackglory/structures 0.8.0 → 0.10.1

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 (66) hide show
  1. package/README.md +59 -21
  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 +415 -96
  5. package/dist/es2015/index.mjs.map +1 -1
  6. package/dist/es2015/index.umd.js +417 -95
  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 +415 -96
  13. package/dist/es2018/index.mjs.map +1 -1
  14. package/dist/es2018/index.umd.js +417 -95
  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/dynamic-typed-array.d.ts +1 -1
  19. package/lib/es2015/dynamic-typed-array.js +25 -20
  20. package/lib/es2015/dynamic-typed-array.js.map +1 -1
  21. package/lib/es2015/index.d.ts +3 -0
  22. package/lib/es2015/index.js +3 -0
  23. package/lib/es2015/index.js.map +1 -1
  24. package/lib/es2015/sorted-set.d.ts +10 -0
  25. package/lib/es2015/sorted-set.js +32 -0
  26. package/lib/es2015/sorted-set.js.map +1 -0
  27. package/lib/es2015/sparse-map.d.ts +5 -12
  28. package/lib/es2015/sparse-map.js +25 -26
  29. package/lib/es2015/sparse-map.js.map +1 -1
  30. package/lib/es2015/sparse-set.d.ts +4 -8
  31. package/lib/es2015/sparse-set.js +24 -13
  32. package/lib/es2015/sparse-set.js.map +1 -1
  33. package/lib/es2015/typed-sparse-map.d.ts +16 -0
  34. package/lib/es2015/typed-sparse-map.js +70 -0
  35. package/lib/es2015/typed-sparse-map.js.map +1 -0
  36. package/lib/es2015/typed-sparse-set.d.ts +13 -0
  37. package/lib/es2015/typed-sparse-set.js +49 -0
  38. package/lib/es2015/typed-sparse-set.js.map +1 -0
  39. package/lib/es2015/utils/skip-list.d.ts +24 -0
  40. package/lib/es2015/utils/skip-list.js +155 -0
  41. package/lib/es2015/utils/skip-list.js.map +1 -0
  42. package/lib/es2018/dynamic-typed-array.d.ts +1 -1
  43. package/lib/es2018/dynamic-typed-array.js +25 -20
  44. package/lib/es2018/dynamic-typed-array.js.map +1 -1
  45. package/lib/es2018/index.d.ts +3 -0
  46. package/lib/es2018/index.js +3 -0
  47. package/lib/es2018/index.js.map +1 -1
  48. package/lib/es2018/sorted-set.d.ts +10 -0
  49. package/lib/es2018/sorted-set.js +32 -0
  50. package/lib/es2018/sorted-set.js.map +1 -0
  51. package/lib/es2018/sparse-map.d.ts +5 -12
  52. package/lib/es2018/sparse-map.js +25 -26
  53. package/lib/es2018/sparse-map.js.map +1 -1
  54. package/lib/es2018/sparse-set.d.ts +4 -8
  55. package/lib/es2018/sparse-set.js +24 -13
  56. package/lib/es2018/sparse-set.js.map +1 -1
  57. package/lib/es2018/typed-sparse-map.d.ts +16 -0
  58. package/lib/es2018/typed-sparse-map.js +70 -0
  59. package/lib/es2018/typed-sparse-map.js.map +1 -0
  60. package/lib/es2018/typed-sparse-set.d.ts +13 -0
  61. package/lib/es2018/typed-sparse-set.js +49 -0
  62. package/lib/es2018/typed-sparse-set.js.map +1 -0
  63. package/lib/es2018/utils/skip-list.d.ts +24 -0
  64. package/lib/es2018/utils/skip-list.js +155 -0
  65. package/lib/es2018/utils/skip-list.js.map +1 -0
  66. package/package.json +1 -1
@@ -9641,6 +9641,227 @@ class ObservableFiniteStateMachine extends FiniteStateMachine {
9641
9641
  }
9642
9642
  }
9643
9643
 
9644
+ class SparseSet {
9645
+ constructor(array = []) {
9646
+ this.indexToValue = [];
9647
+ const valueToIndex = [];
9648
+ if (array.length > 0) {
9649
+ for (const [index, value] of array.entries()) {
9650
+ valueToIndex[value] = index;
9651
+ }
9652
+ }
9653
+ this.valueToIndex = valueToIndex;
9654
+ }
9655
+ get [Symbol.toStringTag]() {
9656
+ return this.constructor.name;
9657
+ }
9658
+ [Symbol.iterator]() {
9659
+ return this.indexToValue[Symbol.iterator]();
9660
+ }
9661
+ values() {
9662
+ return this.indexToValue[Symbol.iterator]();
9663
+ }
9664
+ has(value) {
9665
+ // 跟一般的实现不同, 不需要访问values数组.
9666
+ return value in this.valueToIndex;
9667
+ }
9668
+ add(value) {
9669
+ if (!this.has(value)) {
9670
+ const index = this.indexToValue.length;
9671
+ this.indexToValue.push(value);
9672
+ this.valueToIndex[value] = index;
9673
+ }
9674
+ }
9675
+ delete(value) {
9676
+ if (this.has(value)) {
9677
+ const lastValue = this.indexToValue.pop();
9678
+ if (value === lastValue) {
9679
+ delete this.valueToIndex[value];
9680
+ }
9681
+ else {
9682
+ const index = this.valueToIndex[value];
9683
+ this.indexToValue[index] = lastValue;
9684
+ this.valueToIndex[lastValue] = index;
9685
+ // 跟一般的实现不同, 直接删除值的索引.
9686
+ delete this.valueToIndex[value];
9687
+ }
9688
+ }
9689
+ }
9690
+ }
9691
+
9692
+ class SparseMap {
9693
+ constructor() {
9694
+ this.keyToIndex = [];
9695
+ this.indexToKey = [];
9696
+ this.indexToValue = [];
9697
+ }
9698
+ get [Symbol.toStringTag]() {
9699
+ return this.constructor.name;
9700
+ }
9701
+ *entries() {
9702
+ for (let i = 0; i < this.indexToKey.length; i++) {
9703
+ yield [this.indexToKey[i], this.indexToValue[i]];
9704
+ }
9705
+ }
9706
+ keys() {
9707
+ return this.indexToKey.values();
9708
+ }
9709
+ values() {
9710
+ return this.indexToValue.values();
9711
+ }
9712
+ has(key) {
9713
+ // 跟一般的稀疏集实现不同, 不需要访问values数组.
9714
+ return key in this.keyToIndex;
9715
+ }
9716
+ get(key) {
9717
+ if (this.has(key)) {
9718
+ const index = this.keyToIndex[key];
9719
+ return this.indexToValue[index];
9720
+ }
9721
+ else {
9722
+ return undefined;
9723
+ }
9724
+ }
9725
+ set(key, value) {
9726
+ if (this.has(key)) {
9727
+ const index = this.keyToIndex[key];
9728
+ this.indexToValue[index] = value;
9729
+ }
9730
+ else {
9731
+ const index = this.indexToKey.length;
9732
+ this.indexToKey.push(key);
9733
+ this.indexToValue.push(value);
9734
+ this.keyToIndex[key] = index;
9735
+ }
9736
+ }
9737
+ delete(key) {
9738
+ if (this.has(key)) {
9739
+ const lastKey = this.indexToKey.pop();
9740
+ const lastValue = this.indexToValue.pop();
9741
+ if (key === lastKey) {
9742
+ delete this.keyToIndex[key];
9743
+ }
9744
+ else {
9745
+ const index = this.keyToIndex[key];
9746
+ this.indexToKey[index] = lastKey;
9747
+ this.indexToValue[index] = lastValue;
9748
+ this.keyToIndex[key] = index;
9749
+ delete this.keyToIndex[key];
9750
+ }
9751
+ }
9752
+ }
9753
+ }
9754
+
9755
+ class TypedSparseMap {
9756
+ constructor(array) {
9757
+ this.keyToIndex = [];
9758
+ this.indexToKey = [];
9759
+ es2018$d.assert(array.length === 0, 'array should be empty');
9760
+ this.indexToValue = array;
9761
+ }
9762
+ get [Symbol.toStringTag]() {
9763
+ return this.constructor.name;
9764
+ }
9765
+ *entries() {
9766
+ for (let i = 0; i < this.indexToKey.length; i++) {
9767
+ yield [
9768
+ this.indexToKey[i],
9769
+ this.indexToValue.internalTypedArray[i]
9770
+ ];
9771
+ }
9772
+ }
9773
+ keys() {
9774
+ return this.indexToKey.values();
9775
+ }
9776
+ *values() {
9777
+ for (let i = 0; i < this.indexToKey.length; i++) {
9778
+ yield this.indexToValue.internalTypedArray[i];
9779
+ }
9780
+ }
9781
+ has(key) {
9782
+ const index = this.keyToIndex[key];
9783
+ return this.indexToKey[index] === key;
9784
+ }
9785
+ get(key) {
9786
+ const index = this.keyToIndex[key];
9787
+ if (this.indexToKey[index] === key) {
9788
+ return this.indexToValue.internalTypedArray[index];
9789
+ }
9790
+ else {
9791
+ return undefined;
9792
+ }
9793
+ }
9794
+ set(key, value) {
9795
+ const index = this.keyToIndex[key];
9796
+ if (this.indexToKey[index] === key) {
9797
+ this.indexToValue.internalTypedArray[index] = value;
9798
+ }
9799
+ else {
9800
+ const index = this.indexToKey.length;
9801
+ this.indexToKey.push(key);
9802
+ this.indexToValue.push(value);
9803
+ this.keyToIndex[key] = index;
9804
+ }
9805
+ }
9806
+ delete(key) {
9807
+ const index = this.keyToIndex[key];
9808
+ if (this.indexToKey[index] === key) {
9809
+ const lastKey = this.indexToKey.pop();
9810
+ const lastValue = this.indexToValue.pop();
9811
+ if (key !== lastKey) {
9812
+ this.indexToKey[index] = lastKey;
9813
+ this.indexToValue.internalTypedArray[index] = lastValue;
9814
+ this.keyToIndex[lastKey] = index;
9815
+ }
9816
+ }
9817
+ }
9818
+ }
9819
+
9820
+ class TypedSparseSet {
9821
+ constructor(array) {
9822
+ const valueToIndex = [];
9823
+ if (array.length > 0) {
9824
+ for (const [index, value] of array.internalTypedArray.entries()) {
9825
+ valueToIndex[value] = index;
9826
+ }
9827
+ }
9828
+ this.indexToValue = array;
9829
+ this.valueToIndex = valueToIndex;
9830
+ }
9831
+ get [Symbol.toStringTag]() {
9832
+ return this.constructor.name;
9833
+ }
9834
+ [Symbol.iterator]() {
9835
+ return this.values();
9836
+ }
9837
+ *values() {
9838
+ for (let i = 0; i < this.indexToValue.length; i++) {
9839
+ yield this.indexToValue.internalTypedArray[i];
9840
+ }
9841
+ }
9842
+ has(value) {
9843
+ const index = this.valueToIndex[value];
9844
+ return this.indexToValue.internalTypedArray[index] === value;
9845
+ }
9846
+ add(value) {
9847
+ if (!this.has(value)) {
9848
+ const index = this.indexToValue.length;
9849
+ this.indexToValue.push(value);
9850
+ this.valueToIndex[value] = index;
9851
+ }
9852
+ }
9853
+ delete(value) {
9854
+ const index = this.valueToIndex[value];
9855
+ if (this.indexToValue.internalTypedArray[index] === value) {
9856
+ const lastValue = this.indexToValue.pop();
9857
+ if (value !== lastValue) {
9858
+ this.indexToValue.internalTypedArray[index] = lastValue;
9859
+ this.valueToIndex[lastValue] = index;
9860
+ }
9861
+ }
9862
+ }
9863
+ }
9864
+
9644
9865
  // 相关提案: https://github.com/tc39/proposal-resizablearraybuffer
9645
9866
  class DynamicTypedArray {
9646
9867
  constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
@@ -9648,7 +9869,7 @@ class DynamicTypedArray {
9648
9869
  this._length = 0;
9649
9870
  es2018$d.assert(Number.isInteger(capacity), 'capacity must be an integer');
9650
9871
  es2018$d.assert(capacity >= 0, 'capacity must be greater than or equal to 0');
9651
- es2018$d.assert(growthFactor > 1, 'growthFactory must be greater than or equal to 1');
9872
+ es2018$d.assert(growthFactor >= 1, 'growthFactory must be greater than or equal to 1');
9652
9873
  this.array = new typedArrayConstructor(capacity);
9653
9874
  this.growthFactor = growthFactor;
9654
9875
  }
@@ -9727,135 +9948,233 @@ class DynamicTypedArray {
9727
9948
  }
9728
9949
  }
9729
9950
  function computeNewCapacity(oldCapacity, targetLength, growthFactor) {
9730
- if (oldCapacity === targetLength) {
9951
+ if (growthFactor === 1) {
9731
9952
  return targetLength;
9732
9953
  }
9733
- else if (oldCapacity < targetLength) {
9734
- // 增加容量以适配targetLength
9735
- let newCapacity = Math.max(oldCapacity, 1);
9736
- while (newCapacity < targetLength) {
9737
- newCapacity *= growthFactor;
9738
- }
9739
- return Math.floor(newCapacity);
9740
- }
9741
9954
  else {
9742
- // 尝试减少容量以适配targetLength
9743
- // `targetLength = 0`是特殊情况,
9744
- // 此时无论怎么将oldCapacity除以growthFactory几次, 都不可能得到比targetLength小的结果.
9745
- if (targetLength === 0) {
9746
- return 0;
9955
+ if (oldCapacity === targetLength) {
9956
+ return targetLength;
9957
+ }
9958
+ else if (oldCapacity < targetLength) {
9959
+ // 增加容量以适配targetLength
9960
+ let newCapacity = Math.max(oldCapacity, 1);
9961
+ while (newCapacity < targetLength) {
9962
+ newCapacity *= growthFactor;
9963
+ }
9964
+ return Math.floor(newCapacity);
9747
9965
  }
9748
9966
  else {
9749
- let newCapacity = oldCapacity;
9750
- while (true) {
9751
- const temp = newCapacity / growthFactor;
9752
- if (temp < targetLength) {
9753
- break;
9754
- }
9755
- else {
9756
- newCapacity = temp;
9967
+ // 尝试减少容量以适配targetLength
9968
+ // `targetLength = 0`是特殊情况,
9969
+ // 此时无论怎么将oldCapacity除以growthFactory几次, 都不可能得到比targetLength小的结果.
9970
+ if (targetLength === 0) {
9971
+ return 0;
9972
+ }
9973
+ else {
9974
+ let newCapacity = oldCapacity;
9975
+ while (true) {
9976
+ const temp = newCapacity / growthFactor;
9977
+ if (temp < targetLength) {
9978
+ break;
9979
+ }
9980
+ else {
9981
+ newCapacity = temp;
9982
+ }
9757
9983
  }
9984
+ return Math.floor(newCapacity);
9758
9985
  }
9759
- return Math.floor(newCapacity);
9760
9986
  }
9761
9987
  }
9762
9988
  }
9763
9989
 
9764
- class SparseSet {
9765
- constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
9766
- this.indexToValue = new DynamicTypedArray(typedArrayConstructor, { capacity, growthFactor });
9767
- this.valueToIndex = new DynamicTypedArray(Uint32Array, { capacity, growthFactor });
9990
+ class SkipListNode {
9991
+ constructor(value) {
9992
+ this.value = value;
9993
+ this.previous = null;
9994
+ this.next = null;
9995
+ this.up = null;
9996
+ this.down = null;
9997
+ }
9998
+ }
9999
+ class SkipList {
10000
+ constructor(compare) {
10001
+ this.compare = compare;
10002
+ // 最顶层的首个节点
10003
+ this.head = new SkipListNode(null);
10004
+ // 最顶层的最后一个节点
10005
+ this.tail = new SkipListNode(null);
10006
+ this.height = 0;
10007
+ this._size = 0;
10008
+ this.head.next = this.tail;
10009
+ this.tail.previous = this.head;
10010
+ }
10011
+ // 元素数量
10012
+ get size() {
10013
+ return this._size;
9768
10014
  }
9769
- get [Symbol.toStringTag]() {
9770
- return this.constructor.name;
10015
+ *elements() {
10016
+ let currentNode = this.head;
10017
+ while (currentNode.down) {
10018
+ currentNode = currentNode.down;
10019
+ }
10020
+ while (currentNode.next && es2018$e.isntNull(currentNode.next.value)) {
10021
+ currentNode = currentNode.next;
10022
+ yield currentNode;
10023
+ }
9771
10024
  }
9772
- [Symbol.iterator]() {
9773
- return this.indexToValue.internalTypedArray[Symbol.iterator]();
10025
+ dumpList() {
10026
+ const result = [];
10027
+ let head = this.head;
10028
+ do {
10029
+ result.push([]);
10030
+ let currentNode = head;
10031
+ do {
10032
+ result[result.length - 1].push(currentNode.value);
10033
+ currentNode = currentNode.next;
10034
+ } while (currentNode);
10035
+ } while (head = head.down);
10036
+ return result;
10037
+ }
10038
+ delete(value) {
10039
+ let currentNode = this.findNode(value);
10040
+ while (currentNode) {
10041
+ // 被删除的节点肯定不会是head或tail, 因此一定有previous
10042
+ currentNode.previous.next = currentNode.next;
10043
+ // 被删除的节点肯定不会是head或tail, 因此一定有next
10044
+ currentNode.next.previous = currentNode.previous;
10045
+ currentNode = currentNode.down;
10046
+ }
10047
+ this._size--;
9774
10048
  }
9775
10049
  has(value) {
9776
- const index = this.valueToIndex.internalTypedArray[value];
9777
- return this.indexToValue.internalTypedArray[index] === value;
10050
+ return es2018$e.isntNull(this.findNode(value));
9778
10051
  }
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);
10052
+ findNode(value) {
10053
+ let currentNode = this.head;
10054
+ while (true) {
10055
+ while (currentNode.next && es2018$e.isntNull(currentNode.next.value)) {
10056
+ const result = this.compare(currentNode.next.value, value);
10057
+ if (result === 0) {
10058
+ return currentNode.next;
10059
+ }
10060
+ else if (result < 0) {
10061
+ currentNode = currentNode.next;
10062
+ }
10063
+ else {
10064
+ break;
10065
+ }
10066
+ }
10067
+ if (currentNode.down) {
10068
+ currentNode = currentNode.down;
10069
+ }
10070
+ else {
10071
+ return null;
10072
+ }
9784
10073
  }
9785
10074
  }
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;
10075
+ add(value) {
10076
+ let previousNode = this.findPreviousNode(value);
10077
+ // 如果previousNode.next.value等于value, 则说明value已经存在
10078
+ if (previousNode.next &&
10079
+ es2018$e.isntNull(previousNode.next.value) &&
10080
+ this.compare(previousNode.next.value, value) === 0) {
10081
+ return;
10082
+ }
10083
+ let newNode = new SkipListNode(value);
10084
+ // 在底层加入新节点
10085
+ if (previousNode.next) {
10086
+ newNode.next = previousNode.next;
10087
+ previousNode.next.previous = newNode;
10088
+ }
10089
+ previousNode.next = newNode;
10090
+ newNode.previous = previousNode;
10091
+ // 在高层加入新节点, 具体加到多高是随机的, 从第一层(将其视作索引值0)开始建造
10092
+ // 层数非常高是极为罕见的, 因为每次建造层都会导致下一层被建造的概率减半.
10093
+ let level = 0;
10094
+ while (Math.random() < 0.5) {
10095
+ // currentLevel的索引与当前跳跃列表的高度相同, 需要在这之上建立一个新层
10096
+ if (level === this.height) {
10097
+ const newHead = new SkipListNode(null);
10098
+ const newTail = new SkipListNode(null);
10099
+ newHead.next = newTail;
10100
+ newHead.down = this.head;
10101
+ newTail.previous = newHead;
10102
+ newTail.down = this.tail;
10103
+ this.head.up = newHead;
10104
+ this.tail.up = newTail;
10105
+ this.head = newHead;
10106
+ this.tail = newTail;
10107
+ this.height++;
10108
+ }
10109
+ // 从新节点的前一个节点遍历, 直到找到能够通往上层的节点
10110
+ while (!previousNode.up) {
10111
+ // head节点必然会有up, 所以不可能访问进入循环体, 不可能访问`head.previous`
10112
+ previousNode = previousNode.previous;
10113
+ }
10114
+ // 上一层的对应节点
10115
+ previousNode = previousNode.up;
10116
+ // 创建新节点的上层节点
10117
+ const upperNewNode = new SkipListNode(value);
10118
+ if (previousNode.next) {
10119
+ upperNewNode.next = previousNode.next;
10120
+ previousNode.next.previous = upperNewNode;
10121
+ }
10122
+ previousNode.next = upperNewNode;
10123
+ upperNewNode.previous = previousNode;
10124
+ upperNewNode.down = newNode;
10125
+ newNode.up = upperNewNode;
10126
+ newNode = upperNewNode;
10127
+ level++;
10128
+ }
10129
+ this._size++;
10130
+ }
10131
+ findPreviousNode(value) {
10132
+ let currentNode = this.head;
10133
+ while (true) {
10134
+ while (currentNode.next && es2018$e.isntNull(currentNode.next.value)) {
10135
+ const result = this.compare(currentNode.next.value, value);
10136
+ if (result >= 0) {
10137
+ break;
10138
+ }
10139
+ else {
10140
+ currentNode = currentNode.next;
10141
+ }
10142
+ }
10143
+ if (currentNode.down) {
10144
+ currentNode = currentNode.down;
10145
+ }
10146
+ else {
10147
+ return currentNode;
9793
10148
  }
9794
10149
  }
9795
10150
  }
9796
10151
  }
9797
10152
 
9798
- class SparseMap {
9799
- constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
9800
- this.indexToValue = new DynamicTypedArray(typedArrayConstructor, { capacity, growthFactor });
9801
- this.keyToIndex = new DynamicTypedArray(Uint32Array, { capacity, growthFactor });
9802
- this.indexToKey = new DynamicTypedArray(Uint32Array, { capacity, growthFactor });
10153
+ class SortedSet {
10154
+ constructor(compare) {
10155
+ this.skipList = new SkipList(compare);
9803
10156
  }
9804
10157
  get [Symbol.toStringTag]() {
9805
10158
  return this.constructor.name;
9806
10159
  }
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
- ];
10160
+ *[Symbol.iterator]() {
10161
+ for (const value of this.values()) {
10162
+ yield value;
9813
10163
  }
9814
10164
  }
9815
- keys() {
9816
- return this.indexToKey.internalTypedArray.values();
9817
- }
9818
10165
  values() {
9819
- return this.indexToValue.internalTypedArray.values();
10166
+ return es2018$4.map(this.skipList.elements(), node => node.value);
9820
10167
  }
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
- }
10168
+ has(value) {
10169
+ return this.skipList.has(value);
9833
10170
  }
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
- }
10171
+ add(value) {
10172
+ this.skipList.add(value);
9845
10173
  }
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
- }
10174
+ delete(value) {
10175
+ this.skipList.delete(value);
9857
10176
  }
9858
10177
  }
9859
10178
 
9860
- export { BadEventError, Box, DynamicTypedArray, Emitter, ExpirableMap, FiniteStateMachine, HashMap, HashSet, LRUMap, ObservableFiniteStateMachine, Queue, SparseMap, SparseSet, TLRUMap, TrieMap, convertArrayToCons, convertConsToArray };
10179
+ export { BadEventError, Box, DynamicTypedArray, Emitter, ExpirableMap, FiniteStateMachine, HashMap, HashSet, LRUMap, ObservableFiniteStateMachine, Queue, SortedSet, SparseMap, SparseSet, TLRUMap, TrieMap, TypedSparseMap, TypedSparseSet, convertArrayToCons, convertConsToArray };
9861
10180
  //# sourceMappingURL=index.mjs.map