@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.
@@ -6224,12 +6224,13 @@
6224
6224
  this.bitsPerElement = bitsPerElement;
6225
6225
  this.array = [];
6226
6226
  this.length = 0;
6227
+ this._size = 0;
6227
6228
  }
6228
6229
  get [Symbol.toStringTag]() {
6229
6230
  return this.constructor.name;
6230
6231
  }
6231
6232
  get size() {
6232
- return this.length;
6233
+ return this._size;
6233
6234
  }
6234
6235
  [Symbol.iterator]() {
6235
6236
  return this.values();
@@ -6283,14 +6284,23 @@
6283
6284
  this.length = value + 1;
6284
6285
  }
6285
6286
  const [index, mask] = this.getPosition(value);
6286
- this.array[index] = ((_a = this.array[index]) !== null && _a !== void 0 ? _a : 0) | mask;
6287
+ const element = (_a = this.array[index]) !== null && _a !== void 0 ? _a : 0;
6288
+ this.array[index] = element | mask;
6289
+ const added = (element & mask) !== mask;
6290
+ if (added) {
6291
+ this._size++;
6292
+ }
6287
6293
  }
6288
6294
  delete(value) {
6289
6295
  var _a;
6290
6296
  const [index, mask] = this.getPosition(value);
6291
6297
  const element = ((_a = this.array[index]) !== null && _a !== void 0 ? _a : 0);
6292
6298
  this.array[index] = element & ~mask;
6293
- return (element & mask) === mask;
6299
+ const deleted = (element & mask) === mask;
6300
+ if (deleted) {
6301
+ this._size--;
6302
+ }
6303
+ return deleted;
6294
6304
  }
6295
6305
  clear() {
6296
6306
  for (let i = this.array.length; i--;) {
@@ -6315,12 +6325,13 @@
6315
6325
  this.array = array;
6316
6326
  this.bitsPerElement = this.array.internalTypedArray.BYTES_PER_ELEMENT * 8;
6317
6327
  this.length = 0;
6328
+ this._size = 0;
6318
6329
  }
6319
6330
  get [Symbol.toStringTag]() {
6320
6331
  return this.constructor.name;
6321
6332
  }
6322
6333
  get size() {
6323
- return this.length;
6334
+ return this._size;
6324
6335
  }
6325
6336
  [Symbol.iterator]() {
6326
6337
  return this.values();
@@ -6374,14 +6385,23 @@
6374
6385
  this.length = value + 1;
6375
6386
  }
6376
6387
  const [index, mask] = this.getPosition(value);
6377
- this.array.set(index, ((_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0) | mask);
6388
+ const element = (_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0;
6389
+ this.array.set(index, element | mask);
6390
+ const added = (element & mask) !== mask;
6391
+ if (added) {
6392
+ this._size++;
6393
+ }
6378
6394
  }
6379
6395
  delete(value) {
6380
6396
  var _a;
6381
6397
  const [index, mask] = this.getPosition(value);
6382
6398
  const element = ((_a = this.array.get(index)) !== null && _a !== void 0 ? _a : 0);
6383
6399
  this.array.set(index, element & ~mask);
6384
- return (element & mask) === mask;
6400
+ const deleted = (element & mask) === mask;
6401
+ if (deleted) {
6402
+ this._size--;
6403
+ }
6404
+ return deleted;
6385
6405
  }
6386
6406
  clear() {
6387
6407
  for (let i = this.array.length; i--;) {