@blackglory/structures 0.10.17 → 0.10.19

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();
@@ -6241,20 +6242,20 @@
6241
6242
  - (maxArrayLength * this.bitsPerElement - this.length);
6242
6243
  const lastIndex = maxArrayLength - 1;
6243
6244
  for (let index = 0; index < lastIndex; index++) {
6244
- const element = this.array[index];
6245
+ let element = this.array[index];
6245
6246
  for (let bit = 0; bit < this.bitsPerElement; bit++) {
6246
- const mask = this.getMask(bit);
6247
- if ((element & mask) === mask) {
6247
+ if (element & 1) {
6248
6248
  yield index * this.bitsPerElement + bit;
6249
6249
  }
6250
+ element >>= 1;
6250
6251
  }
6251
6252
  }
6252
- const lastElement = this.array[maxArrayLength - 1];
6253
+ let lastElement = this.array[maxArrayLength - 1];
6253
6254
  for (let bit = 0; bit < remainder; bit++) {
6254
- const mask = this.getMask(bit);
6255
- if ((lastElement & mask) === mask) {
6255
+ if (lastElement & 1) {
6256
6256
  yield lastIndex * this.bitsPerElement + bit;
6257
6257
  }
6258
+ lastElement >>= 1;
6258
6259
  }
6259
6260
  }
6260
6261
  }
@@ -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();
@@ -6332,20 +6343,20 @@
6332
6343
  - (maxArrayLength * this.bitsPerElement - this.length);
6333
6344
  const lastIndex = maxArrayLength - 1;
6334
6345
  for (let index = 0; index < lastIndex; index++) {
6335
- const element = this.array.internalTypedArray[index];
6346
+ let element = this.array.internalTypedArray[index];
6336
6347
  for (let bit = 0; bit < this.bitsPerElement; bit++) {
6337
- const mask = this.getMask(bit);
6338
- if ((element & mask) === mask) {
6348
+ if (element & 1) {
6339
6349
  yield index * this.bitsPerElement + bit;
6340
6350
  }
6351
+ element >>= 1;
6341
6352
  }
6342
6353
  }
6343
- const lastElement = this.array.internalTypedArray[maxArrayLength - 1];
6354
+ let lastElement = this.array.internalTypedArray[maxArrayLength - 1];
6344
6355
  for (let bit = 0; bit < remainder; bit++) {
6345
- const mask = this.getMask(bit);
6346
- if ((lastElement & mask) === mask) {
6356
+ if (lastElement & 1) {
6347
6357
  yield lastIndex * this.bitsPerElement + bit;
6348
6358
  }
6359
+ lastElement >>= 1;
6349
6360
  }
6350
6361
  }
6351
6362
  }
@@ -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--;) {