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