@woosh/meep-engine 2.105.0 → 2.106.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 (79) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/build/bundle-worker-terrain.js +1 -1
  3. package/build/meep.cjs +358 -188
  4. package/build/meep.min.js +1 -1
  5. package/build/meep.module.js +358 -188
  6. package/package.json +1 -1
  7. package/src/core/assert.d.ts.map +1 -1
  8. package/src/core/assert.js +3 -1
  9. package/src/core/cache/Cache.d.ts.map +1 -1
  10. package/src/core/cache/Cache.js +23 -19
  11. package/src/core/collection/array/array_copy.spec.d.ts +2 -0
  12. package/src/core/collection/array/array_copy.spec.d.ts.map +1 -0
  13. package/src/core/collection/array/array_copy.spec.js +19 -0
  14. package/src/core/collection/list/List.d.ts.map +1 -1
  15. package/src/core/collection/list/List.js +55 -30
  16. package/src/core/collection/list/List.spec.js +101 -0
  17. package/src/core/collection/list/ListForwarder.d.ts.map +1 -1
  18. package/src/core/collection/list/ListForwarder.js +49 -53
  19. package/src/core/collection/list/ListForwarder.spec.js +2 -0
  20. package/src/core/collection/list/SortedListProjection.d.ts +4 -1
  21. package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
  22. package/src/core/collection/list/SortedListProjection.js +4 -1
  23. package/src/core/collection/map/AbstractAsyncMap.d.ts.map +1 -1
  24. package/src/core/collection/map/AbstractAsyncMap.js +0 -3
  25. package/src/core/collection/map/AsyncMapWrapper.d.ts +6 -10
  26. package/src/core/collection/map/AsyncMapWrapper.d.ts.map +1 -1
  27. package/src/core/collection/map/AsyncMapWrapper.js +14 -9
  28. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  29. package/src/core/collection/map/HashMap.js +30 -3
  30. package/src/core/collection/map/ObservedMap.d.ts +12 -3
  31. package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
  32. package/src/core/collection/map/ObservedMap.js +14 -4
  33. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  34. package/src/core/collection/queue/Deque.js +100 -95
  35. package/src/core/collection/set/ArraySet.d.ts.map +1 -0
  36. package/src/core/collection/set/{Set.js → ArraySet.js} +2 -2
  37. package/src/core/collection/set/set_remove.d.ts +3 -3
  38. package/src/core/collection/set/set_remove.d.ts.map +1 -1
  39. package/src/core/collection/set/set_remove.js +5 -5
  40. package/src/core/color/oklab/find_gamut_intersection.js +1 -1
  41. package/src/core/geom/2d/Rectangle.d.ts +54 -5
  42. package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
  43. package/src/core/geom/2d/Rectangle.js +70 -3
  44. package/src/core/geom/2d/circle/Circle.d.ts +1 -1
  45. package/src/core/geom/2d/circle/Circle.js +1 -1
  46. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
  47. package/src/core/geom/2d/compute_triangle_area_2d.js +7 -1
  48. package/src/core/geom/2d/shape/AbstractShape.d.ts +2 -0
  49. package/src/core/geom/2d/shape/AbstractShape.d.ts.map +1 -1
  50. package/src/core/geom/2d/shape/AbstractShape.js +8 -2
  51. package/src/core/geom/2d/shape/CircleShape.d.ts +14 -0
  52. package/src/core/geom/2d/shape/CircleShape.d.ts.map +1 -1
  53. package/src/core/geom/2d/shape/CircleShape.js +64 -22
  54. package/src/core/geom/2d/uv_map_circle_to_square.d.ts +8 -0
  55. package/src/core/geom/2d/uv_map_circle_to_square.d.ts.map +1 -0
  56. package/src/core/geom/2d/{UvUtils.js → uv_map_circle_to_square.js} +2 -17
  57. package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts +2 -0
  58. package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts.map +1 -0
  59. package/src/core/geom/2d/uv_map_circle_to_square.spec.js +28 -0
  60. package/src/core/geom/2d/uv_map_square_to_circle.d.ts +8 -0
  61. package/src/core/geom/2d/uv_map_square_to_circle.d.ts.map +1 -0
  62. package/src/core/geom/2d/uv_map_square_to_circle.js +14 -0
  63. package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts +2 -0
  64. package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts.map +1 -0
  65. package/src/core/geom/2d/uv_map_square_to_circle.spec.js +30 -0
  66. package/src/core/geom/Vector3.d.ts +13 -4
  67. package/src/core/geom/Vector3.d.ts.map +1 -1
  68. package/src/core/geom/Vector3.js +83 -36
  69. package/src/core/geom/Vector3.spec.js +113 -12
  70. package/src/core/collection/set/Set.d.ts.map +0 -1
  71. package/src/core/geom/2d/Geometry2D.d.ts +0 -31
  72. package/src/core/geom/2d/Geometry2D.d.ts.map +0 -1
  73. package/src/core/geom/2d/Geometry2D.js +0 -59
  74. package/src/core/geom/2d/UvUtils.d.ts +0 -15
  75. package/src/core/geom/2d/UvUtils.d.ts.map +0 -1
  76. package/src/core/geom/2d/UvUtils.spec.d.ts +0 -2
  77. package/src/core/geom/2d/UvUtils.spec.d.ts.map +0 -1
  78. package/src/core/geom/2d/UvUtils.spec.js +0 -55
  79. /package/src/core/collection/set/{Set.d.ts → ArraySet.d.ts} +0 -0
@@ -5,9 +5,6 @@
5
5
  * @template Key,Value
6
6
  */
7
7
  export class AbstractAsyncMap {
8
- constructor() {
9
-
10
- }
11
8
 
12
9
  /**
13
10
  *
@@ -1,20 +1,16 @@
1
1
  /**
2
2
  * Wraps synchronous {@link Map}-implementing object
3
+ * @template K,V
3
4
  */
4
- export class AsyncMapWrapper extends AbstractAsyncMap<any, any> {
5
+ export class AsyncMapWrapper<K, V> extends AbstractAsyncMap<any, any> {
5
6
  /**
6
7
  *
7
- * @param {Map} [source]
8
+ * @param {Map<K,V>} [source]
8
9
  */
9
- constructor(source?: Map<any, any>);
10
- /**
11
- *
12
- * @type {Map}
13
- * @private
14
- */
15
- private _source;
16
- get(key: any): Promise<any>;
10
+ constructor(source?: Map<K, V>);
11
+ get(key: any): Promise<V>;
17
12
  set(key: any, value: any): Promise<void>;
13
+ #private;
18
14
  }
19
15
  import { AbstractAsyncMap } from "./AbstractAsyncMap.js";
20
16
  //# sourceMappingURL=AsyncMapWrapper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncMapWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/AsyncMapWrapper.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI;;;OAGG;IACH,oCAQC;IANG;;;;OAIG;IACH,gBAAqB;IAGzB,4BAEC;IAED,yCAEC;CACJ;iCA3BgC,uBAAuB"}
1
+ {"version":3,"file":"AsyncMapWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/AsyncMapWrapper.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IAUI;;;OAGG;IACH,qBAFW,IAAI,CAAC,EAAC,CAAC,CAAC,EAKlB;IAED,0BAEC;IAED,yCAEC;;CACJ;iCAhCgC,uBAAuB"}
@@ -2,27 +2,32 @@ import { AbstractAsyncMap } from "./AbstractAsyncMap.js";
2
2
 
3
3
  /**
4
4
  * Wraps synchronous {@link Map}-implementing object
5
+ * @template K,V
5
6
  */
6
7
  export class AsyncMapWrapper extends AbstractAsyncMap {
8
+
9
+ /**
10
+ *
11
+ * @type {Map<K,V>}
12
+ * @private
13
+ */
14
+ #source = null;
15
+
16
+
7
17
  /**
8
18
  *
9
- * @param {Map} [source]
19
+ * @param {Map<K,V>} [source]
10
20
  */
11
21
  constructor(source = new Map()) {
12
22
  super();
13
- /**
14
- *
15
- * @type {Map}
16
- * @private
17
- */
18
- this._source = source;
23
+ this.#source = source;
19
24
  }
20
25
 
21
26
  async get(key) {
22
- return this._source.get(key);
27
+ return this.#source.get(key);
23
28
  }
24
29
 
25
30
  async set(key, value) {
26
- this._source.set(key, value);
31
+ this.#source.set(key, value);
27
32
  }
28
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AA8FD;;;;;;;GAOG;AACH;IA+DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAkJD;;;;OAIG;IACH,SAHW,CAAC,SACD,CAAC,QAsEX;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CA+BvB;IAED;;;;;;;;OAQG;IACH,kBALW,CAAC,kBACQ,CAAC,KAAE,CAAC,0BAEZ,CAAC,CAcZ;IAED;;;;;OAKG;IACH,cAJW,CAAC,SACD,CAAC,GACA,CAAC,CAYZ;IAuBD;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CA+CnB;IAED;;;;;OAKG;IACH,4CAFa,OAAO,CA+BnB;IAOD;;OAEG;IACH,gBAkDC;IAmBD,2CAwBC;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,OAAO,CAInB;IAED;;OAEG;IACH,cA6BC;IA+BD;;;OAGG;IACH,UAFa,SAAS,CAAC,CAAC,CAOvB;IAED;;;OAGG;IACH,QAFa,SAAS,CAAC,CAAC,CAMvB;IAhDD,yDA2BC;;CAsBJ"}
1
+ {"version":3,"file":"HashMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/HashMap.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;GAYG;AACH,uFAIC;AA8FD;;;;;;;GAOG;AACH;IA+DI;;;;;;OAMG;IACH,4FALuB,MAAM,EAsC5B;IAlBG;;;;;OAKG;IACH,iCAAsC;IACtC;;;;;OAKG;IACH,qCAA8C;IAOlD,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAiKD;;;;OAIG;IACH,SAHW,CAAC,SACD,CAAC,QA0EX;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CA+BvB;IAED;;;;;;;;OAQG;IACH,kBALW,CAAC,kBACQ,CAAC,KAAE,CAAC,0BAEZ,CAAC,CAgBZ;IAED;;;;;OAKG;IACH,cAJW,CAAC,SACD,CAAC,GACA,CAAC,CAYZ;IAuBD;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CA+CnB;IAED;;;;;OAKG;IACH,4CAFa,OAAO,CA+BnB;IAOD;;OAEG;IACH,gBAsDC;IAmBD,2CA0BC;IAED;;;;OAIG;IACH,SAHW,CAAC,GACC,OAAO,CAInB;IAED;;OAEG;IACH,cA6BC;IA+BD;;;OAGG;IACH,UAFa,SAAS,CAAC,CAAC,CAOvB;IAED;;;OAGG;IACH,QAFa,SAAS,CAAC,CAAC,CAMvB;IAhDD,yDA2BC;;CAsBJ"}
@@ -271,6 +271,8 @@ export class HashMap {
271
271
  this.#bin_count = 2 ** this.#bin_count_power_of_two;
272
272
  this.#bin_count_mask = this.#bin_count - 1;
273
273
 
274
+ const old_entry_allocation_count = this.#entries_allocated_count;
275
+
274
276
  this.#entries_allocated_count = 2 ** this.#entries_count_power_of_two;
275
277
 
276
278
  const BinsArray = UintArrayForCount(this.#entries_allocated_count + ENTRY_BASE);
@@ -282,7 +284,7 @@ export class HashMap {
282
284
 
283
285
  this.#entries = new_entries;
284
286
 
285
- array_copy(old_entries, 0, new_entries, 0, min2(old_entries.length, this.#entries_allocated_count));
287
+ array_copy(old_entries, 0, new_entries, 0, min2(old_entry_allocation_count, this.#entries_allocated_count));
286
288
 
287
289
  if (this.#size > 0) {
288
290
  // re-hash
@@ -316,6 +318,8 @@ export class HashMap {
316
318
  #build_key_hash(key) {
317
319
  const original = this.keyHashFunction(key);
318
320
 
321
+ assert.isInteger(original, 'hash');
322
+
319
323
  return original === RESERVED_HASH ? RESERVED_HASH_SUBSTITUTE : original;
320
324
  }
321
325
 
@@ -356,12 +360,23 @@ export class HashMap {
356
360
  this.#entries_bound++;
357
361
 
358
362
  if (this.#entries[i] !== undefined) {
363
+
364
+ // entry exists, let's reuse it
365
+
359
366
  const entry = this.#entries[i];
367
+
368
+ assert.equal(entry.hash, RESERVED_HASH, 'Entry is occupied');
369
+
360
370
  entry.hash = hash;
361
371
  entry.key = k;
362
372
  entry.value = v;
373
+
363
374
  } else {
375
+
376
+ // entry slot is empty
377
+
364
378
  this.#entries[i] = new HashMapEntry(k, v, hash);
379
+
365
380
  }
366
381
 
367
382
  return i;
@@ -441,7 +456,11 @@ export class HashMap {
441
456
  assert.equal(this.#entries[entry_index].value, value, 'entry.value');
442
457
  assert.equal(this.#entries[entry_index].key, key, 'entry.key');
443
458
 
444
- this.#bins[bin_index] = entry_index + ENTRY_BASE;
459
+ const bin_value = entry_index + ENTRY_BASE;
460
+
461
+ this.#bins[bin_index] = bin_value;
462
+
463
+ assert.equal(bin_value, this.#bins[bin_index], 'Bin value write error');
445
464
 
446
465
  break;
447
466
 
@@ -516,6 +535,8 @@ export class HashMap {
516
535
  * @return {V}
517
536
  */
518
537
  getOrCompute(key, compute, compute_context) {
538
+ assert.isFunction(compute, 'compute');
539
+
519
540
  const existing = this.get(key);
520
541
 
521
542
  if (existing !== undefined) {
@@ -675,7 +696,11 @@ export class HashMap {
675
696
 
676
697
  let written_entries = 0;
677
698
 
678
- for (let existing_entry_index = this.#entries_start; existing_entry_index < entries_bound; existing_entry_index++) {
699
+ for (
700
+ let existing_entry_index = this.#entries_start;
701
+ existing_entry_index < entries_bound;
702
+ existing_entry_index++
703
+ ) {
679
704
  const entry = entries[existing_entry_index];
680
705
 
681
706
  const hash = entry.hash;
@@ -735,6 +760,8 @@ export class HashMap {
735
760
  }
736
761
 
737
762
  forEach(callback, thisArg) {
763
+ assert.isFunction(callback, 'callback');
764
+
738
765
  const count = this.#bin_count;
739
766
  const entries = this.#entries;
740
767
  const bins = this.#bins;
@@ -8,9 +8,18 @@ export class ObservedMap<K, V> {
8
8
  * @constructor
9
9
  */
10
10
  constructor(source?: Map<any, any>);
11
- on: {
12
- set: Signal<any, any, any, any, any, any, any, any>;
13
- deleted: Signal<any, any, any, any, any, any, any, any>;
11
+ /**
12
+ * @readonly
13
+ */
14
+ readonly on: {
15
+ /**
16
+ * @type {Signal}
17
+ */
18
+ set: Signal;
19
+ /**
20
+ * @type {Signal}
21
+ */
22
+ deleted: Signal;
14
23
  };
15
24
  /**
16
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ObservedMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/ObservedMap.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACI;;;OAGG;IACH,oCAWC;IAVG;;;MAGC;IAED;;;OAGG;IACH,oBAAkB;IAGtB;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CAIvB;IAED;;;;;OAKG;IACH,SAJW,CAAC,SACD,CAAC,yBAQX;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CAUnB;IAED;;;;OAIG;IACH,iDAEC;IAED;;;OAGG;IACH,mBAEC;CACJ;mBA7EkB,+BAA+B"}
1
+ {"version":3,"file":"ObservedMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/ObservedMap.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IAeI;;;OAGG;IACH,oCAOC;IAzBD;;OAEG;IACH;QACI;;WAEG;aADO,MAAM;QAGhB;;WAEG;iBADO,MAAM;MAGlB;IAQE;;;OAGG;IACH,oBAAkB;IAGtB;;;;OAIG;IACH,SAHW,CAAC,GACC,CAAC,GAAC,SAAS,CAIvB;IAED;;;;;OAKG;IACH,SAJW,CAAC,SACD,CAAC,yBAQX;IAED;;;;OAIG;IACH,YAHW,CAAC,GACC,OAAO,CAUnB;IAED;;;;OAIG;IACH,iDAEC;IAED;;;OAGG;IACH,mBAEC;CACJ;mBAvFkB,+BAA+B"}
@@ -5,15 +5,25 @@ import Signal from "../../events/signal/Signal.js";
5
5
  * @template K,V
6
6
  */
7
7
  export class ObservedMap {
8
+ /**
9
+ * @readonly
10
+ */
11
+ on = {
12
+ /**
13
+ * @type {Signal}
14
+ */
15
+ set: new Signal(),
16
+ /**
17
+ * @type {Signal}
18
+ */
19
+ deleted: new Signal()
20
+ };
21
+
8
22
  /**
9
23
  * @template K,V
10
24
  * @constructor
11
25
  */
12
26
  constructor(source = new Map()) {
13
- this.on = {
14
- set: new Signal(),
15
- deleted: new Signal()
16
- };
17
27
 
18
28
  /**
19
29
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAYA;;;GAGG;AACH;IACI;;;OAGG;IACH,uBAFW,MAAM,EAoChB;IA5BG;;;;;;OAMG;IACH,eAA6B;IAE7B;;;;OAIG;IACH,eAAe;IACf;;;;OAIG;IACH,eAAe;IAEf;;;;OAIG;IACH,iBAA4B;IAGhC;;;;OAIG;IACH,oBASC;IAED;;;;;OAKG;IACH,iCAMC;IAED;;;;;OAKG;IACH,qCAGC;IAED,2BAwCC;IAED;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IAED;;;;;OAKG;IACH,0BAqCC;IAED;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IAED;;;;;OAKG;IACH,mBAiBC;IAED;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAOL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;CAblB"}
1
+ {"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IA8BI;;;OAGG;IACH,uBAFW,MAAM,EAUhB;IAqFD;;;OAGG;IACH,WAFY,OAAO,CAIlB;IAED,cAeC;IAED;;OAEG;IACH,QAFa,MAAM,CAalB;IA+CD;;;;OAIG;IACH,UAHW,CAAC,GACC,OAAO,CAYnB;IA2BD;;;;OAIG;IACH,WAFa,OAAO,CAInB;IAED;;;OAGG;IACH,YAFW,CAAC,QAOX;IAED;;;OAGG;IACH,eAFa,CAAC,GAAC,SAAS,CAQvB;IAED;;;OAGG;IACH,YAFa,CAAC,GAAC,SAAS,CAIvB;IAED;;;OAGG;IACH,WAFW,CAAC,QAOX;IAED;;;OAGG;IACH,cAFa,CAAC,CASb;IAGD;;;OAGG;IACH,WAFa,CAAC,GAAC,SAAS,CAKvB;IAOL,gBAAoB;IACpB,uBAAoB;IACpB,eAAmB;IAEnB;;OAEG;IACH,sBAAmB;;CAblB"}
@@ -10,11 +10,42 @@ const STATUS_FULL = 0;
10
10
  const STATUS_EMPTY = 1;
11
11
  const STATUS_NORMAL = 2;
12
12
 
13
+ const EMPTY_ARRAY = new Array(0);
14
+
13
15
  /**
14
16
  * Double-ended queue backed by an array
15
17
  * @template T
16
18
  */
17
19
  export class Deque {
20
+
21
+ /**
22
+ * Using static array allocator to preserve data locality.
23
+ * Initialization via "[]" would give us a dynamically sized array,
24
+ * but it would have unpredictable locality as array may or may not have it's elements stored next to each other in memory
25
+ * @type {T[]}
26
+ * @private
27
+ */
28
+ #data=EMPTY_ARRAY;
29
+ /**
30
+ *
31
+ * @type {number}
32
+ * @private
33
+ */
34
+ #head = 0;
35
+ /**
36
+ *
37
+ * @type {number}
38
+ * @private
39
+ */
40
+ #tail = 0;
41
+
42
+ /**
43
+ *
44
+ * @type {number}
45
+ * @private
46
+ */
47
+ #status = STATUS_EMPTY;
48
+
18
49
  /**
19
50
  * @template T
20
51
  * @param {number} [min_size]
@@ -25,34 +56,8 @@ export class Deque {
25
56
 
26
57
  const size = ceilPowerOfTwo(max2(1, min_size));
27
58
 
28
- /**
29
- * Using static array allocator to preserve data locality.
30
- * Initialization via "[]" would give us a dynamically sized array,
31
- * but it would have unpredictable locality as array may or may not have it's elements stored next to each other in memory
32
- * @type {T[]}
33
- * @private
34
- */
35
- this.__data = new Array(size);
36
-
37
- /**
38
- *
39
- * @type {number}
40
- * @private
41
- */
42
- this.__head = 0;
43
- /**
44
- *
45
- * @type {number}
46
- * @private
47
- */
48
- this.__tail = 0;
59
+ this.#data = new Array(size);
49
60
 
50
- /**
51
- *
52
- * @type {number}
53
- * @private
54
- */
55
- this.__status = STATUS_EMPTY;
56
61
  }
57
62
 
58
63
  /**
@@ -60,14 +65,14 @@ export class Deque {
60
65
  * @param {boolean} adding
61
66
  * @private
62
67
  */
63
- resetStatus(adding) {
64
- const head = this.__head;
65
- const tail = this.__tail;
68
+ #reset_status(adding) {
69
+ const head = this.#head;
70
+ const tail = this.#tail;
66
71
 
67
72
  if (head === tail) {
68
- this.__status = adding ? STATUS_FULL : STATUS_EMPTY;
73
+ this.#status = adding ? STATUS_FULL : STATUS_EMPTY;
69
74
  } else {
70
- this.__status = STATUS_NORMAL;
75
+ this.#status = STATUS_NORMAL;
71
76
  }
72
77
  }
73
78
 
@@ -77,10 +82,10 @@ export class Deque {
77
82
  * @returns {number}
78
83
  * @private
79
84
  */
80
- __circular_next_position(current) {
85
+ #circular_next_position(current) {
81
86
  const next = current + 1;
82
87
 
83
- const length = this.__data.length;
88
+ const length = this.#data.length;
84
89
 
85
90
  return (next >= length) ? 0 : next;
86
91
  }
@@ -91,20 +96,20 @@ export class Deque {
91
96
  * @returns {number}
92
97
  * @private
93
98
  */
94
- __circular_previous_position(current) {
99
+ #circular_previous_position(current) {
95
100
  const prev = current - 1;
96
- return (prev < 0) ? (this.__data.length - 1) : prev;
101
+ return (prev < 0) ? (this.#data.length - 1) : prev;
97
102
  }
98
103
 
99
- __check_and_expand() {
100
- const status = this.__status;
104
+ #check_and_expand() {
105
+ const status = this.#status;
101
106
 
102
107
  if (status !== STATUS_FULL) {
103
108
  // queue still has space, we're done
104
109
  return;
105
110
  }
106
111
 
107
- const length = this.__data.length;
112
+ const length = this.#data.length;
108
113
 
109
114
  if (UINT32_MAX === length) {
110
115
  throw new Error('Maximum array size exceeded');
@@ -123,19 +128,19 @@ export class Deque {
123
128
  */
124
129
  const new_data = new Array(new_length);
125
130
 
126
- const head = this.__head;
131
+ const head = this.#head;
127
132
 
128
133
  // copy the front portion
129
- array_copy(this.__data, head, new_data, 0, length - head);
134
+ array_copy(this.#data, head, new_data, 0, length - head);
130
135
  // copy the remainder
131
- array_copy(this.__data, 0, new_data, length - head, head);
136
+ array_copy(this.#data, 0, new_data, length - head, head);
132
137
 
133
- this.__head = 0;
134
- this.__tail = length;
138
+ this.#head = 0;
139
+ this.#tail = length;
135
140
 
136
- this.__status = STATUS_NORMAL;
141
+ this.#status = STATUS_NORMAL;
137
142
 
138
- this.__data = new_data;
143
+ this.#data = new_data;
139
144
  }
140
145
 
141
146
  /**
@@ -147,34 +152,34 @@ export class Deque {
147
152
  }
148
153
 
149
154
  clear() {
150
- if (this.__status !== STATUS_EMPTY) {
151
- let cursor = this.__head;
152
- const tail = this.__tail;
155
+ if (this.#status !== STATUS_EMPTY) {
156
+ let cursor = this.#head;
157
+ const tail = this.#tail;
153
158
 
154
159
  do {
155
- this.__data[cursor] = undefined;
156
- cursor = this.__circular_next_position(cursor);
160
+ this.#data[cursor] = undefined;
161
+ cursor = this.#circular_next_position(cursor);
157
162
  } while (cursor !== tail);
158
163
 
159
- this.__status = STATUS_EMPTY;
164
+ this.#status = STATUS_EMPTY;
160
165
  }
161
166
 
162
- this.__head = 0;
163
- this.__tail = 0;
167
+ this.#head = 0;
168
+ this.#tail = 0;
164
169
  }
165
170
 
166
171
  /**
167
172
  * @returns {number}
168
173
  */
169
174
  size() {
170
- const data = this.__data;
175
+ const data = this.#data;
171
176
 
172
- if (this.__status === STATUS_FULL) {
177
+ if (this.#status === STATUS_FULL) {
173
178
  return data.length;
174
179
  }
175
180
 
176
- const head = this.__head;
177
- const tail = this.__tail;
181
+ const head = this.#head;
182
+ const tail = this.#tail;
178
183
 
179
184
  return (head <= tail) ? (tail - head) : (tail + data.length - head);
180
185
  }
@@ -185,43 +190,43 @@ export class Deque {
185
190
  * @param {boolean} shift_front should we shift elements before the removed element or after?
186
191
  * @private
187
192
  */
188
- __remove_internal(current, shift_front) {
193
+ #remove_internal(current, shift_front) {
189
194
  let cursor = current;
190
195
 
191
196
  if (shift_front) {
192
197
 
193
198
  // shift towards tail
194
199
 
195
- const head = this.__head;
200
+ const head = this.#head;
196
201
 
197
202
  while (cursor !== head) {
198
- const next = this.__circular_previous_position(cursor);
199
- this.__data[cursor] = this.__data[next];
203
+ const next = this.#circular_previous_position(cursor);
204
+ this.#data[cursor] = this.#data[next];
200
205
  cursor = next;
201
206
  }
202
207
 
203
- this.__head = this.__circular_next_position(head);
208
+ this.#head = this.#circular_next_position(head);
204
209
 
205
210
  } else {
206
211
 
207
212
  // shift towards head
208
213
 
209
- const tail = this.__tail;
214
+ const tail = this.#tail;
210
215
 
211
216
  while (cursor !== tail) {
212
- const next = this.__circular_next_position(cursor);
213
- this.__data[cursor] = this.__data[next];
217
+ const next = this.#circular_next_position(cursor);
218
+ this.#data[cursor] = this.#data[next];
214
219
  cursor = next;
215
220
  }
216
221
 
217
- this.__tail = this.__circular_previous_position(tail);
222
+ this.#tail = this.#circular_previous_position(tail);
218
223
 
219
224
  }
220
225
 
221
226
  // fill in slot of last moved element
222
- this.__data[cursor] = undefined;
227
+ this.#data[cursor] = undefined;
223
228
 
224
- this.resetStatus(false);
229
+ this.#reset_status(false);
225
230
  }
226
231
 
227
232
  /**
@@ -230,13 +235,13 @@ export class Deque {
230
235
  * @returns {boolean}
231
236
  */
232
237
  remove(e) {
233
- const i = this.__index_of(e);
238
+ const i = this.#index_of(e);
234
239
 
235
240
  if (i === -1) {
236
241
  return false;
237
242
  }
238
243
 
239
- this.__remove_internal(i, true);
244
+ this.#remove_internal(i, true);
240
245
 
241
246
  return true;
242
247
  }
@@ -247,14 +252,14 @@ export class Deque {
247
252
  * @returns {number}
248
253
  * @private
249
254
  */
250
- __index_of(e) {
255
+ #index_of(e) {
251
256
  const size = this.size();
252
257
 
253
- const data = this.__data;
258
+ const data = this.#data;
254
259
  const capacity = data.length;
255
260
 
256
261
  for (let i = 0; i < size; i++) {
257
- const index = (this.__head + i) % capacity;
262
+ const index = (this.#head + i) % capacity;
258
263
 
259
264
  const el = data[index];
260
265
 
@@ -272,7 +277,7 @@ export class Deque {
272
277
  * @returns {boolean}
273
278
  */
274
279
  has(e) {
275
- return this.__index_of(e) !== -1;
280
+ return this.#index_of(e) !== -1;
276
281
  }
277
282
 
278
283
  /**
@@ -280,10 +285,10 @@ export class Deque {
280
285
  * @param {T} e
281
286
  */
282
287
  addFirst(e) {
283
- this.__check_and_expand();
284
- this.__head = this.__circular_previous_position(this.__head);
285
- this.__data[this.__head] = e;
286
- this.resetStatus(true);
288
+ this.#check_and_expand();
289
+ this.#head = this.#circular_previous_position(this.#head);
290
+ this.#data[this.#head] = e;
291
+ this.#reset_status(true);
287
292
  }
288
293
 
289
294
  /**
@@ -291,10 +296,10 @@ export class Deque {
291
296
  * @returns {T|undefined}
292
297
  */
293
298
  removeFirst() {
294
- const element = this.__data[this.__head];
295
- this.__data[this.__head] = undefined;
296
- this.__head = this.__circular_next_position(this.__head);
297
- this.resetStatus(false);
299
+ const element = this.#data[this.#head];
300
+ this.#data[this.#head] = undefined;
301
+ this.#head = this.#circular_next_position(this.#head);
302
+ this.#reset_status(false);
298
303
  return element;
299
304
  }
300
305
 
@@ -303,7 +308,7 @@ export class Deque {
303
308
  * @returns {T|undefined}
304
309
  */
305
310
  getFirst() {
306
- return this.__data[this.__head];
311
+ return this.#data[this.#head];
307
312
  }
308
313
 
309
314
  /**
@@ -311,10 +316,10 @@ export class Deque {
311
316
  * @param {T} e
312
317
  */
313
318
  addLast(e) {
314
- this.__check_and_expand();
315
- this.__data[this.__tail] = e;
316
- this.__tail = this.__circular_next_position(this.__tail);
317
- this.resetStatus(true);
319
+ this.#check_and_expand();
320
+ this.#data[this.#tail] = e;
321
+ this.#tail = this.#circular_next_position(this.#tail);
322
+ this.#reset_status(true);
318
323
  }
319
324
 
320
325
  /**
@@ -322,11 +327,11 @@ export class Deque {
322
327
  * @returns {T}
323
328
  */
324
329
  removeLast() {
325
- const last = this.__circular_previous_position(this.__tail);
326
- const element = this.__data[last];
327
- this.__data[last] = undefined;
328
- this.__tail = last;
329
- this.resetStatus(false);
330
+ const last = this.#circular_previous_position(this.#tail);
331
+ const element = this.#data[last];
332
+ this.#data[last] = undefined;
333
+ this.#tail = last;
334
+ this.#reset_status(false);
330
335
  return element;
331
336
  }
332
337
 
@@ -336,8 +341,8 @@ export class Deque {
336
341
  * @returns {T|undefined}
337
342
  */
338
343
  getLast() {
339
- const last = this.__circular_previous_position(this.__tail);
340
- return this.__data[last];
344
+ const last = this.#circular_previous_position(this.#tail);
345
+ return this.#data[last];
341
346
  }
342
347
  }
343
348
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArraySet.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/ArraySet.js"],"names":[],"mappings":";AAOA;;GAEG;AACH;IAiBI;;;;;;OAMG;IACH,yBAIC;IA3BD;;OAEG;IACH;;;MAGE;IAEF;;;OAGG;IACH,aAAU;IAEV,eAAW;IAeX;;;OAGG;IACH,yBAEC;IAED;;;OAGG;IACH,oBAWC;IAED;;;OAGG;IACH,uBAWC;IAED;;;;;OAKG;IACH,wBAIC;IAED;;;OAGG;IACH,WAFa,OAAO,CAInB;IAED;;OAEG;IACH,cAIC;IAED;;;OAGG;IACH,iBAFW,QAAS,QAMnB;IAED;;;OAGG;IACH,qBAFW,QAAS,QAuBnB;IAED;;;;OAIG;IACH,2CAIC;IAED;;;OAGG;IACH,WAFa,GAAG,CAIf;CACJ;mBAjKkB,+BAA+B"}
@@ -8,7 +8,7 @@ import Signal from "../../events/signal/Signal.js";
8
8
  /**
9
9
  * Structure with event signals for observing changes.
10
10
  */
11
- class Set {
11
+ class ArraySet {
12
12
  /**
13
13
  * @readonly
14
14
  */
@@ -167,4 +167,4 @@ class Set {
167
167
  }
168
168
 
169
169
 
170
- export default Set;
170
+ export default ArraySet;
@@ -2,8 +2,8 @@
2
2
  * Remove all elements of B from A.
3
3
  * This operation mutates A
4
4
  * @template T
5
- * @param {Set<T>} a
6
- * @param {Set<T>} b
5
+ * @param {Set<T>} from
6
+ * @param {Set<T>} to_be_removed
7
7
  */
8
- export function set_remove<T>(a: Set<T>, b: Set<T>): void;
8
+ export function set_remove<T>(from: Set<T>, to_be_removed: Set<T>): void;
9
9
  //# sourceMappingURL=set_remove.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"set_remove.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/set_remove.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,0DASC"}
1
+ {"version":3,"file":"set_remove.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/set_remove.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,yEASC"}