@blackglory/structures 0.6.7 → 0.6.10

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.
@@ -9649,10 +9649,8 @@ class SparseSet {
9649
9649
  get [Symbol.toStringTag]() {
9650
9650
  return this.constructor.name;
9651
9651
  }
9652
- *[Symbol.iterator]() {
9653
- for (const value of this.values) {
9654
- yield value;
9655
- }
9652
+ [Symbol.iterator]() {
9653
+ return this.values[Symbol.iterator]();
9656
9654
  }
9657
9655
  has(value) {
9658
9656
  // 跟一般的实现不同, 不需要访问values数组.
@@ -9668,7 +9666,10 @@ class SparseSet {
9668
9666
  remove(value) {
9669
9667
  if (this.has(value)) {
9670
9668
  const lastValue = this.values.pop();
9671
- if (value !== lastValue) {
9669
+ if (value === lastValue) {
9670
+ this.valueToValueIndex[value] = undefined;
9671
+ }
9672
+ else {
9672
9673
  const indexOfValue = this.valueToValueIndex[value];
9673
9674
  this.values[indexOfValue] = lastValue;
9674
9675
  this.valueToValueIndex[lastValue] = indexOfValue;