@blackglory/structures 0.10.17 → 0.10.18

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.
@@ -6218,12 +6218,13 @@ class BitSet {
6218
6218
  this.bitsPerElement = bitsPerElement;
6219
6219
  this.array = [];
6220
6220
  this.length = 0;
6221
+ this._size = 0;
6221
6222
  }
6222
6223
  get [Symbol.toStringTag]() {
6223
6224
  return this.constructor.name;
6224
6225
  }
6225
6226
  get size() {
6226
- return this.length;
6227
+ return this._size;
6227
6228
  }
6228
6229
  [Symbol.iterator]() {
6229
6230
  return this.values();
@@ -6277,14 +6278,23 @@ class BitSet {
6277
6278
  this.length = value + 1;
6278
6279
  }
6279
6280
  const [index, mask] = this.getPosition(value);
6280
- this.array[index] = ((_a = this.array[index]) !== null && _a !== void 0 ? _a : 0) | mask;
6281
+ const element = (_a = this.array[index]) !== null && _a !== void 0 ? _a : 0;
6282
+ this.array[index] = element | mask;
6283
+ const added = (element & mask) !== mask;
6284
+ if (added) {
6285
+ this._size++;
6286
+ }
6281
6287
  }
6282
6288
  delete(value) {
6283
6289
  var _a;
6284
6290
  const [index, mask] = this.getPosition(value);
6285
6291
  const element = ((_a = this.array[index]) !== null && _a !== void 0 ? _a : 0);
6286
6292
  this.array[index] = element & ~mask;
6287
- return (element & mask) === mask;
6293
+ const deleted = (element & mask) === mask;
6294
+ if (deleted) {
6295
+ this._size--;
6296
+ }
6297
+ return deleted;
6288
6298
  }
6289
6299
  clear() {
6290
6300
  for (let i = this.array.length; i--;) {
@@ -6309,12 +6319,13 @@ class TypedBitSet {
6309
6319
  this.array = array;
6310
6320
  this.bitsPerElement = this.array.internalTypedArray.BYTES_PER_ELEMENT * 8;
6311
6321
  this.length = 0;
6322
+ this._size = 0;
6312
6323
  }
6313
6324
  get [Symbol.toStringTag]() {
6314
6325
  return this.constructor.name;
6315
6326
  }
6316
6327
  get size() {
6317
- return this.length;
6328
+ return this._size;
6318
6329
  }
6319
6330
  [Symbol.iterator]() {
6320
6331
  return this.values();
@@ -6368,14 +6379,23 @@ class TypedBitSet {
6368
6379
  this.length = value + 1;
6369
6380
  }
6370
6381
  const [index, mask] = this.getPosition(value);
6371
- this.array.set(index, ((_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0) | mask);
6382
+ const element = (_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0;
6383
+ this.array.set(index, element | mask);
6384
+ const added = (element & mask) !== mask;
6385
+ if (added) {
6386
+ this._size++;
6387
+ }
6372
6388
  }
6373
6389
  delete(value) {
6374
6390
  var _a;
6375
6391
  const [index, mask] = this.getPosition(value);
6376
6392
  const element = ((_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0);
6377
6393
  this.array.set(index, element & ~mask);
6378
- return (element & mask) === mask;
6394
+ const deleted = (element & mask) === mask;
6395
+ if (deleted) {
6396
+ this._size--;
6397
+ }
6398
+ return deleted;
6379
6399
  }
6380
6400
  clear() {
6381
6401
  for (let i = this.array.length; i--;) {