@woosh/meep-engine 2.97.0 → 2.98.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.
- package/build/bundle-worker-terrain.js +1 -1
- package/build/meep.cjs +861 -670
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +861 -670
- package/package.json +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +3 -2
- package/src/core/collection/array/arrayQuickSort.js +2 -2
- package/src/core/collection/array/array_compute_max.d.ts +9 -0
- package/src/core/collection/array/array_compute_max.d.ts.map +1 -0
- package/src/core/collection/array/{computeArrayMax.js → array_compute_max.js} +1 -1
- package/src/core/collection/array/array_compute_min.d.ts +9 -0
- package/src/core/collection/array/array_compute_min.d.ts.map +1 -0
- package/src/core/collection/array/{computeArrayMin.js → array_compute_min.js} +1 -1
- package/src/core/collection/array/array_compute_min_max.d.ts.map +1 -1
- package/src/core/collection/array/array_compute_min_max.js +1 -0
- package/src/core/collection/array/array_swap.d.ts.map +1 -1
- package/src/core/collection/array/array_swap.js +11 -8
- package/src/core/collection/array/array_swap_one.d.ts +8 -0
- package/src/core/collection/array/array_swap_one.d.ts.map +1 -0
- package/src/core/collection/array/{arraySwapElements.js → array_swap_one.js} +1 -1
- package/src/core/collection/array/iterator/AbstractArrayIterator.d.ts.map +1 -0
- package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts.map +1 -0
- package/src/core/collection/array/{ArrayIteratorRandom.js → iterator/ArrayIteratorRandom.js} +2 -2
- package/src/core/collection/array/iterator/ArrayIteratorSequential.d.ts.map +1 -0
- package/src/core/collection/array/randomizeArrayElementOrder.js +2 -2
- package/src/core/collection/map/HashMap.js +10 -10
- package/src/core/collection/map/ObservedMap.d.ts +7 -4
- package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
- package/src/core/collection/map/ObservedMap.js +4 -1
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +82 -36
- package/src/core/collection/set/compute_set_difference.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_difference.js +8 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_difference.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_difference.spec.js +45 -0
- package/src/core/collection/set/compute_set_intersection.d.ts +1 -0
- package/src/core/collection/set/compute_set_intersection.d.ts.map +1 -1
- package/src/core/collection/set/compute_set_intersection.js +9 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts +2 -0
- package/src/core/collection/set/compute_set_intersection.spec.d.ts.map +1 -0
- package/src/core/collection/set/compute_set_intersection.spec.js +45 -0
- package/src/core/collection/set/set_remove.d.ts +2 -0
- package/src/core/collection/set/set_remove.d.ts.map +1 -1
- package/src/core/collection/set/set_remove.js +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts +2 -0
- package/src/core/color/oklab/XYZ.spec.d.ts.map +1 -0
- package/src/core/color/oklab/XYZ.spec.js +17 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts +9 -0
- package/src/core/color/oklab/oklab_to_xyz.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.js +32 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts +2 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.d.ts.map +1 -0
- package/src/core/color/oklab/oklab_to_xyz.spec.js +31 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts +8 -0
- package/src/core/color/oklab/xyz_to_oklab.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.js +29 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts +2 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.d.ts.map +1 -0
- package/src/core/color/oklab/xyz_to_oklab.spec.js +31 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +16 -5
- package/src/core/color/sRGB/sRGB_to_linear.d.ts.map +1 -1
- package/src/core/color/sRGB/sRGB_to_linear.js +17 -5
- package/src/core/color/xyz/rgb_to_xyz.d.ts +1 -0
- package/src/core/color/xyz/rgb_to_xyz.d.ts.map +1 -1
- package/src/core/color/xyz/rgb_to_xyz.js +4 -3
- package/src/core/color/xyz/xyz_to_rgb.d.ts +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +4 -4
- package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +10 -10
- package/src/core/parser/simple/ParserError.d.ts +11 -6
- package/src/core/parser/simple/ParserError.d.ts.map +1 -1
- package/src/core/parser/simple/ParserError.js +51 -4
- package/src/core/parser/simple/Token.d.ts.map +1 -1
- package/src/core/parser/simple/Token.js +8 -2
- package/src/core/parser/simple/TokenType.d.ts +1 -5
- package/src/core/parser/simple/TokenType.d.ts.map +1 -1
- package/src/core/parser/simple/TokenType.js +1 -1
- package/src/core/parser/simple/readBooleanToken.d.ts.map +1 -1
- package/src/core/parser/simple/readBooleanToken.js +6 -1
- package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
- package/src/core/parser/simple/readHexToken.js +7 -2
- package/src/core/parser/simple/readIdentifierToken.d.ts.map +1 -1
- package/src/core/parser/simple/readIdentifierToken.js +6 -1
- package/src/core/parser/simple/readLiteralToken.d.ts.map +1 -1
- package/src/core/parser/simple/readLiteralToken.js +8 -3
- package/src/core/parser/simple/readNumberToken.d.ts.map +1 -1
- package/src/core/parser/simple/readNumberToken.js +7 -2
- package/src/core/parser/simple/readReferenceToken.d.ts.map +1 -1
- package/src/core/parser/simple/readReferenceToken.js +6 -1
- package/src/core/parser/simple/readStringToken.d.ts.map +1 -1
- package/src/core/parser/simple/readStringToken.js +6 -1
- package/src/core/parser/simple/readUnsignedIntegerToken.d.ts.map +1 -1
- package/src/core/parser/simple/readUnsignedIntegerToken.js +7 -2
- package/src/core/parser/simple/skipWhitespace.d.ts.map +1 -1
- package/src/core/parser/simple/skipWhitespace.js +8 -0
- package/src/core/primitives/strings/string_repeat.d.ts +9 -0
- package/src/core/primitives/strings/string_repeat.d.ts.map +1 -0
- package/src/core/primitives/strings/string_repeat.js +26 -0
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/development/performance/RingBufferMetric.d.ts.map +1 -1
- package/src/engine/development/performance/RingBufferMetric.js +5 -5
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/BuildLightTexture.js +15 -22
- package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +23 -16
- package/src/engine/graphics/filter/ImageFilter.d.ts +2 -2
- package/src/engine/graphics/filter/ImageFilter.d.ts.map +1 -1
- package/src/engine/graphics/filter/ImageFilter.js +3 -3
- package/src/engine/graphics/render/RendererPool.d.ts +14 -1
- package/src/engine/graphics/render/RendererPool.d.ts.map +1 -1
- package/src/engine/graphics/render/RendererPool.js +43 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +2 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +23 -50
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts +9 -0
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +53 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +3 -3
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +42 -36
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts +3 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.js +34 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts +10 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.js +89 -0
- package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.js → debug/prototypeSamplerFiltering.js} +105 -113
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +8 -8
- package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
- package/src/generation/markers/GridActionRuleSet.js +5 -5
- package/src/core/binary/byteArrayToString.d.ts +0 -9
- package/src/core/binary/byteArrayToString.d.ts.map +0 -1
- package/src/core/binary/byteArrayToString.js +0 -28
- package/src/core/collection/array/AbstractArrayIterator.d.ts.map +0 -1
- package/src/core/collection/array/ArrayIteratorRandom.d.ts.map +0 -1
- package/src/core/collection/array/ArrayIteratorSequential.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickMinElement.d.ts +0 -8
- package/src/core/collection/array/arrayPickMinElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickMinElement.js +0 -43
- package/src/core/collection/array/arraySwapElements.d.ts +0 -8
- package/src/core/collection/array/arraySwapElements.d.ts.map +0 -1
- package/src/core/collection/array/computeArrayMax.d.ts +0 -9
- package/src/core/collection/array/computeArrayMax.d.ts.map +0 -1
- package/src/core/collection/array/computeArrayMin.d.ts +0 -9
- package/src/core/collection/array/computeArrayMin.d.ts.map +0 -1
- package/src/core/color/hsluv/HSLuv.d.ts +0 -13
- package/src/core/color/hsluv/HSLuv.d.ts.map +0 -1
- package/src/core/color/hsluv/HSLuv.js +0 -187
- package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.d.ts.map +0 -1
- /package/src/core/collection/array/{AbstractArrayIterator.d.ts → iterator/AbstractArrayIterator.d.ts} +0 -0
- /package/src/core/collection/array/{AbstractArrayIterator.js → iterator/AbstractArrayIterator.js} +0 -0
- /package/src/core/collection/array/{ArrayIteratorRandom.d.ts → iterator/ArrayIteratorRandom.d.ts} +0 -0
- /package/src/core/collection/array/{ArrayIteratorSequential.d.ts → iterator/ArrayIteratorSequential.d.ts} +0 -0
- /package/src/core/collection/array/{ArrayIteratorSequential.js → iterator/ArrayIteratorSequential.js} +0 -0
- /package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.d.ts → debug/prototypeSamplerFiltering.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -76,8 +76,8 @@ export function bvh_query_leaves_ray(
|
|
|
76
76
|
if (child_1 !== NULL_NODE) {
|
|
77
77
|
|
|
78
78
|
// this is not a leaf node, push children onto traversal stack
|
|
79
|
-
stack[stack.pointer++] = child_1;
|
|
80
79
|
stack[stack.pointer++] = uint32[address + COLUMN_CHILD_2];
|
|
80
|
+
stack[stack.pointer++] = child_1;
|
|
81
81
|
|
|
82
82
|
} else {
|
|
83
83
|
// leaf node
|
|
@@ -65,8 +65,8 @@ export function bvh_query_user_data_generic(
|
|
|
65
65
|
const child2 = bvh.node_get_child2(node);
|
|
66
66
|
|
|
67
67
|
// write to stack in reverse order, so that fist child ends up being visited first
|
|
68
|
-
stack[stack.pointer++] = child1;
|
|
69
68
|
stack[stack.pointer++] = child2;
|
|
69
|
+
stack[stack.pointer++] = child1;
|
|
70
70
|
|
|
71
71
|
} else {
|
|
72
72
|
// leaf node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bvh_query_user_data_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bvh_query_user_data_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;GAaG;AACH,wDAXW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,GACJ,MAAM,CAwElB"}
|
|
@@ -4,7 +4,6 @@ import { COLUMN_CHILD_1, COLUMN_CHILD_2, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, N
|
|
|
4
4
|
|
|
5
5
|
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
*
|
|
10
9
|
* @param {BVH} bvh
|
|
@@ -76,8 +75,10 @@ export function bvh_query_user_data_ray(
|
|
|
76
75
|
if (child_1 !== NULL_NODE) {
|
|
77
76
|
|
|
78
77
|
// this is not a leaf node, push children onto traversal stack
|
|
78
|
+
const child_2 = uint32[address + COLUMN_CHILD_2];
|
|
79
|
+
|
|
80
|
+
stack[stack.pointer++] = child_2;
|
|
79
81
|
stack[stack.pointer++] = child_1;
|
|
80
|
-
stack[stack.pointer++] = uint32[address + COLUMN_CHILD_2];
|
|
81
82
|
|
|
82
83
|
} else {
|
|
83
84
|
// leaf node
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { array_swap_one } from "./array_swap_one.js";
|
|
2
2
|
|
|
3
3
|
const stack = [];
|
|
4
4
|
|
|
@@ -16,7 +16,7 @@ export function arrayQuickSort(
|
|
|
16
16
|
data,
|
|
17
17
|
score_function, score_function_context,
|
|
18
18
|
start, end,
|
|
19
|
-
swap_operator =
|
|
19
|
+
swap_operator = array_swap_one, swap_context = undefined
|
|
20
20
|
) {
|
|
21
21
|
if (start >= end) {
|
|
22
22
|
// section of 0 size, nothing to sort
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_compute_max.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compute_max.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wDAJW,MAAM,QACN,MAAM,GACL,MAAM,CAajB"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {number} [end]
|
|
6
6
|
* @return {number}
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
8
|
+
export function array_compute_max(data, start = 0, end = data.length) {
|
|
9
9
|
let result = Number.NEGATIVE_INFINITY;
|
|
10
10
|
|
|
11
11
|
for (let i = start; i < end; i++) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_compute_min.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compute_min.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wDAJW,MAAM,QACN,MAAM,GACL,MAAM,CAajB"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {number} [end]
|
|
6
6
|
* @return {number}
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
8
|
+
export function array_compute_min(data, start = 0, end = data.length) {
|
|
9
9
|
let result = Number.POSITIVE_INFINITY;
|
|
10
10
|
|
|
11
11
|
for (let i = start; i < end; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_compute_min_max.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compute_min_max.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,4CAHW,MAAM,EAAE,GACP,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"array_compute_min_max.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compute_min_max.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,4CAHW,MAAM,EAAE,GACP,MAAM,EAAE,CAcnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_swap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gDALW,MAAM,oBAEN,MAAM,UACN,MAAM,
|
|
1
|
+
{"version":3,"file":"array_swap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,gDALW,MAAM,oBAEN,MAAM,UACN,MAAM,QAkBhB"}
|
|
@@ -6,17 +6,20 @@
|
|
|
6
6
|
* @param {number} b_offset
|
|
7
7
|
* @param {number} length How many elements should be moved
|
|
8
8
|
*/
|
|
9
|
-
export function array_swap(
|
|
9
|
+
export function array_swap(
|
|
10
|
+
a, a_offset,
|
|
11
|
+
b, b_offset,
|
|
12
|
+
length
|
|
13
|
+
) {
|
|
10
14
|
|
|
11
|
-
let
|
|
15
|
+
for (let k = 0; k < length; k++) {
|
|
16
|
+
const i = a_offset + k;
|
|
17
|
+
const j = b_offset + k;
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
i = a_offset + k;
|
|
15
|
-
j = b_offset + k;
|
|
16
|
-
|
|
17
|
-
const t = b[j];
|
|
19
|
+
const swap = b[j];
|
|
18
20
|
|
|
19
21
|
b[j] = a[i];
|
|
20
|
-
a[i] =
|
|
22
|
+
a[i] = swap;
|
|
21
23
|
}
|
|
24
|
+
|
|
22
25
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_swap_one.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap_one.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sDAHW,MAAM,UACN,MAAM,QAOhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractArrayIterator.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/iterator/AbstractArrayIterator.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;IACI;;;OAGG;IACH,iBAFW,CAAC,EAAE,QASb;IANG;;;;OAIG;IACH,kBAHU,CAAC,EAAE,CAGK;IAGtB;;OAEG;IACH,aAFW;QAAC,KAAK,EAAC,CAAC,CAAC;QAAC,IAAI,EAAC,OAAO,CAAA;KAAC,QAIjC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayIteratorRandom.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/iterator/ArrayIteratorRandom.js"],"names":[],"mappings":"AAIA;IACI,cAOC;IAJG,YAAY;IACZ,kBAAoB;IAEpB,uBAA+B;IAGnC;;;OAGG;IACH,WAFW,MAAM,QAIhB;IAED,4BAYC;IAED,wBAgBC;CACJ;sCAnDqC,4BAA4B"}
|
package/src/core/collection/array/{ArrayIteratorRandom.js → iterator/ArrayIteratorRandom.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { seededRandom } from "
|
|
1
|
+
import { seededRandom } from "../../../math/random/seededRandom.js";
|
|
2
|
+
import { randomizeArrayElementOrder } from "../randomizeArrayElementOrder.js";
|
|
2
3
|
import { AbstractArrayIterator } from "./AbstractArrayIterator.js";
|
|
3
|
-
import { randomizeArrayElementOrder } from "./randomizeArrayElementOrder.js";
|
|
4
4
|
|
|
5
5
|
export class ArrayIteratorRandom extends AbstractArrayIterator {
|
|
6
6
|
constructor() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayIteratorSequential.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/iterator/ArrayIteratorSequential.js"],"names":[],"mappings":"AAEA;IACI,cAIC;IADG,YAAY;IAGhB,4BAIC;IAED,wBAcC;CACJ;sCA9BqC,4BAA4B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
|
|
2
|
-
import {
|
|
2
|
+
import { array_swap_one } from "./array_swap_one.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Randomly re-orders of items in-place
|
|
@@ -19,6 +19,6 @@ export function randomizeArrayElementOrder(random, array) {
|
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
array_swap_one(array, i, t);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -6,7 +6,7 @@ import { min2 } from "../../math/min2.js";
|
|
|
6
6
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
7
7
|
import { invokeObjectHash } from "../../model/object/invokeObjectHash.js";
|
|
8
8
|
import { array_copy } from "../array/array_copy.js";
|
|
9
|
-
import {
|
|
9
|
+
import { array_swap_one } from "../array/array_swap_one.js";
|
|
10
10
|
import { UintArrayForCount } from "../array/typed/uint_array_for_count.js";
|
|
11
11
|
|
|
12
12
|
/*
|
|
@@ -38,7 +38,7 @@ export function generate_next_linear_congruential_index(index, mask) {
|
|
|
38
38
|
/**
|
|
39
39
|
* @template K,V
|
|
40
40
|
*/
|
|
41
|
-
class
|
|
41
|
+
class HashMapEntry {
|
|
42
42
|
/**
|
|
43
43
|
*
|
|
44
44
|
* @param {K} key
|
|
@@ -126,7 +126,7 @@ const UNDEFINED_BIN_INDEX = ~0;
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* @template K,V
|
|
129
|
-
* @param {
|
|
129
|
+
* @param {HashMapEntry<K,V>} record
|
|
130
130
|
* @param {number} hash
|
|
131
131
|
* @param {K} key
|
|
132
132
|
* @param {function(a:K,b:K):boolean} equality_op
|
|
@@ -168,7 +168,7 @@ export class HashMap {
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* Note that dead entries are marked as such with a special reserved hash values, so records can be reused for new entries
|
|
171
|
-
* @type {Array<
|
|
171
|
+
* @type {Array<HashMapEntry<K,V>>}
|
|
172
172
|
*/
|
|
173
173
|
#entries = new Array(0);
|
|
174
174
|
|
|
@@ -358,7 +358,7 @@ export class HashMap {
|
|
|
358
358
|
entry.key = k;
|
|
359
359
|
entry.value = v;
|
|
360
360
|
} else {
|
|
361
|
-
this.#entries[i] = new
|
|
361
|
+
this.#entries[i] = new HashMapEntry(k, v, hash);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
return i;
|
|
@@ -366,7 +366,7 @@ export class HashMap {
|
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
*
|
|
369
|
-
* @param {
|
|
369
|
+
* @param {HashMapEntry<K,V>} entry
|
|
370
370
|
*/
|
|
371
371
|
#deallocate(entry) {
|
|
372
372
|
|
|
@@ -634,7 +634,7 @@ export class HashMap {
|
|
|
634
634
|
}
|
|
635
635
|
|
|
636
636
|
/**
|
|
637
|
-
* @type {
|
|
637
|
+
* @type {HashMapEntry<K,V>}
|
|
638
638
|
*/
|
|
639
639
|
const entry = this.#entries[bin - ENTRY_BASE];
|
|
640
640
|
|
|
@@ -685,7 +685,7 @@ export class HashMap {
|
|
|
685
685
|
|
|
686
686
|
if (new_index !== existing_entry_index) {
|
|
687
687
|
// move entries to the new position, compacting holes
|
|
688
|
-
|
|
688
|
+
array_swap_one(entries, new_index, existing_entry_index);
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
let bin_index = this.#compute_bin_index(hash);
|
|
@@ -746,7 +746,7 @@ export class HashMap {
|
|
|
746
746
|
}
|
|
747
747
|
|
|
748
748
|
/**
|
|
749
|
-
* @type {
|
|
749
|
+
* @type {HashMapEntry<K,V>}
|
|
750
750
|
*/
|
|
751
751
|
const entry = entries[bin - ENTRY_BASE];
|
|
752
752
|
|
|
@@ -818,7 +818,7 @@ export class HashMap {
|
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
/**
|
|
821
|
-
* @type {
|
|
821
|
+
* @type {HashMapEntry<K,V>}
|
|
822
822
|
*/
|
|
823
823
|
const entry = entries[bin - ENTRY_BASE];
|
|
824
824
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Decorator that wraps another map and lets you observe mutations
|
|
3
|
+
* @template K,V
|
|
4
|
+
*/
|
|
5
|
+
export class ObservedMap<K, V> {
|
|
2
6
|
/**
|
|
3
7
|
* @template K,V
|
|
4
8
|
* @constructor
|
|
5
|
-
* @property {number} size
|
|
6
9
|
*/
|
|
7
10
|
constructor(source?: Map<any, any>);
|
|
8
11
|
on: {
|
|
@@ -13,7 +16,7 @@ export class ObservedMap {
|
|
|
13
16
|
*
|
|
14
17
|
* @type {Map<K, V>}
|
|
15
18
|
*/
|
|
16
|
-
data: Map<
|
|
19
|
+
data: Map<K_1, V_1>;
|
|
17
20
|
/**
|
|
18
21
|
*
|
|
19
22
|
* @param {K} key
|
|
@@ -26,7 +29,7 @@ export class ObservedMap {
|
|
|
26
29
|
* @param {V} value
|
|
27
30
|
* @returns {ObservedMap}
|
|
28
31
|
*/
|
|
29
|
-
set(key: K, value: V): ObservedMap
|
|
32
|
+
set(key: K, value: V): ObservedMap<any, any>;
|
|
30
33
|
/**
|
|
31
34
|
*
|
|
32
35
|
* @param {K} key
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservedMap.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/map/ObservedMap.js"],"names":[],"mappings":"AAEA;IACI
|
|
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,10 +1,13 @@
|
|
|
1
1
|
import Signal from "../../events/signal/Signal.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Decorator that wraps another map and lets you observe mutations
|
|
5
|
+
* @template K,V
|
|
6
|
+
*/
|
|
3
7
|
export class ObservedMap {
|
|
4
8
|
/**
|
|
5
9
|
* @template K,V
|
|
6
10
|
* @constructor
|
|
7
|
-
* @property {number} size
|
|
8
11
|
*/
|
|
9
12
|
constructor(source = new Map()) {
|
|
10
13
|
this.on = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deque.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/queue/Deque.js"],"names":[],"mappings":"
|
|
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,7 +1,8 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
1
2
|
import { ceilPowerOfTwo } from "../../binary/operations/ceilPowerOfTwo.js";
|
|
3
|
+
import { UINT32_MAX } from "../../binary/UINT32_MAX.js";
|
|
2
4
|
import { max2 } from "../../math/max2.js";
|
|
3
5
|
import { array_copy } from "../array/array_copy.js";
|
|
4
|
-
import { assert } from "../../assert.js";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_SIZE = 16;
|
|
7
8
|
|
|
@@ -16,12 +17,13 @@ const STATUS_NORMAL = 2;
|
|
|
16
17
|
export class Deque {
|
|
17
18
|
/**
|
|
18
19
|
* @template T
|
|
20
|
+
* @param {number} [min_size]
|
|
19
21
|
*/
|
|
20
|
-
constructor(
|
|
22
|
+
constructor(min_size = DEFAULT_SIZE) {
|
|
21
23
|
|
|
22
|
-
assert.isNonNegativeInteger(
|
|
24
|
+
assert.isNonNegativeInteger(min_size, 'minSize');
|
|
23
25
|
|
|
24
|
-
const size = ceilPowerOfTwo(max2(1,
|
|
26
|
+
const size = ceilPowerOfTwo(max2(1, min_size));
|
|
25
27
|
|
|
26
28
|
/**
|
|
27
29
|
* Using static array allocator to preserve data locality.
|
|
@@ -32,15 +34,31 @@ export class Deque {
|
|
|
32
34
|
*/
|
|
33
35
|
this.__data = new Array(size);
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @type {number}
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
35
42
|
this.__head = 0;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {number}
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
36
48
|
this.__tail = 0;
|
|
37
49
|
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @type {number}
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
38
55
|
this.__status = STATUS_EMPTY;
|
|
39
56
|
}
|
|
40
57
|
|
|
41
58
|
/**
|
|
42
59
|
*
|
|
43
60
|
* @param {boolean} adding
|
|
61
|
+
* @private
|
|
44
62
|
*/
|
|
45
63
|
resetStatus(adding) {
|
|
46
64
|
const head = this.__head;
|
|
@@ -59,11 +77,12 @@ export class Deque {
|
|
|
59
77
|
* @returns {number}
|
|
60
78
|
* @private
|
|
61
79
|
*/
|
|
62
|
-
|
|
63
|
-
// TODO this can be done faster using mod operator (%)
|
|
80
|
+
__circular_next_position(current) {
|
|
64
81
|
const next = current + 1;
|
|
65
82
|
|
|
66
|
-
|
|
83
|
+
const length = this.__data.length;
|
|
84
|
+
|
|
85
|
+
return (next >= length) ? 0 : next;
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
/**
|
|
@@ -72,43 +91,57 @@ export class Deque {
|
|
|
72
91
|
* @returns {number}
|
|
73
92
|
* @private
|
|
74
93
|
*/
|
|
75
|
-
|
|
94
|
+
__circular_previous_position(current) {
|
|
76
95
|
const prev = current - 1;
|
|
77
96
|
return (prev < 0) ? (this.__data.length - 1) : prev;
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
|
|
99
|
+
__check_and_expand() {
|
|
81
100
|
const status = this.__status;
|
|
101
|
+
|
|
82
102
|
if (status !== STATUS_FULL) {
|
|
103
|
+
// queue still has space, we're done
|
|
83
104
|
return;
|
|
84
105
|
}
|
|
106
|
+
|
|
85
107
|
const length = this.__data.length;
|
|
86
108
|
|
|
87
|
-
if (
|
|
109
|
+
if (UINT32_MAX === length) {
|
|
88
110
|
throw new Error('Maximum array size exceeded');
|
|
89
111
|
}
|
|
90
112
|
|
|
91
|
-
let
|
|
113
|
+
let new_length = length * 2;
|
|
114
|
+
|
|
92
115
|
// bigger than Integer.MAX_VALUE
|
|
93
|
-
if (
|
|
94
|
-
|
|
116
|
+
if (new_length > UINT32_MAX) {
|
|
117
|
+
new_length = UINT32_MAX;
|
|
95
118
|
}
|
|
96
119
|
|
|
97
|
-
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @type {T[]}
|
|
123
|
+
*/
|
|
124
|
+
const new_data = new Array(new_length);
|
|
98
125
|
|
|
99
|
-
// copy front portion of data
|
|
100
126
|
const head = this.__head;
|
|
101
127
|
|
|
102
|
-
|
|
103
|
-
array_copy(this.__data,
|
|
128
|
+
// copy the front portion
|
|
129
|
+
array_copy(this.__data, head, new_data, 0, length - head);
|
|
130
|
+
// copy the remainder
|
|
131
|
+
array_copy(this.__data, 0, new_data, length - head, head);
|
|
104
132
|
|
|
105
133
|
this.__head = 0;
|
|
106
134
|
this.__tail = length;
|
|
135
|
+
|
|
107
136
|
this.__status = STATUS_NORMAL;
|
|
108
137
|
|
|
109
|
-
this.__data =
|
|
138
|
+
this.__data = new_data;
|
|
110
139
|
}
|
|
111
140
|
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @return {boolean}
|
|
144
|
+
*/
|
|
112
145
|
isEmpty() {
|
|
113
146
|
return this.size() === 0;
|
|
114
147
|
}
|
|
@@ -120,7 +153,7 @@ export class Deque {
|
|
|
120
153
|
|
|
121
154
|
do {
|
|
122
155
|
this.__data[cursor] = undefined;
|
|
123
|
-
cursor = this.
|
|
156
|
+
cursor = this.__circular_next_position(cursor);
|
|
124
157
|
} while (cursor !== tail);
|
|
125
158
|
|
|
126
159
|
this.__status = STATUS_EMPTY;
|
|
@@ -149,32 +182,45 @@ export class Deque {
|
|
|
149
182
|
/**
|
|
150
183
|
*
|
|
151
184
|
* @param {number} current
|
|
152
|
-
* @param {boolean}
|
|
185
|
+
* @param {boolean} shift_front should we shift elements before the removed element or after?
|
|
153
186
|
* @private
|
|
154
187
|
*/
|
|
155
|
-
|
|
188
|
+
__remove_internal(current, shift_front) {
|
|
156
189
|
let cursor = current;
|
|
157
|
-
|
|
190
|
+
|
|
191
|
+
if (shift_front) {
|
|
192
|
+
|
|
193
|
+
// shift towards tail
|
|
194
|
+
|
|
158
195
|
const head = this.__head;
|
|
196
|
+
|
|
159
197
|
while (cursor !== head) {
|
|
160
|
-
const next = this.
|
|
198
|
+
const next = this.__circular_previous_position(cursor);
|
|
161
199
|
this.__data[cursor] = this.__data[next];
|
|
162
200
|
cursor = next;
|
|
163
201
|
}
|
|
164
|
-
|
|
202
|
+
|
|
203
|
+
this.__head = this.__circular_next_position(head);
|
|
204
|
+
|
|
165
205
|
} else {
|
|
206
|
+
|
|
207
|
+
// shift towards head
|
|
208
|
+
|
|
166
209
|
const tail = this.__tail;
|
|
167
210
|
|
|
168
211
|
while (cursor !== tail) {
|
|
169
|
-
const next = this.
|
|
212
|
+
const next = this.__circular_next_position(cursor);
|
|
170
213
|
this.__data[cursor] = this.__data[next];
|
|
171
214
|
cursor = next;
|
|
172
215
|
}
|
|
173
216
|
|
|
174
|
-
this.__tail = this.
|
|
217
|
+
this.__tail = this.__circular_previous_position(tail);
|
|
218
|
+
|
|
175
219
|
}
|
|
176
220
|
|
|
221
|
+
// fill in slot of last moved element
|
|
177
222
|
this.__data[cursor] = undefined;
|
|
223
|
+
|
|
178
224
|
this.resetStatus(false);
|
|
179
225
|
}
|
|
180
226
|
|
|
@@ -190,7 +236,7 @@ export class Deque {
|
|
|
190
236
|
return false;
|
|
191
237
|
}
|
|
192
238
|
|
|
193
|
-
this.
|
|
239
|
+
this.__remove_internal(i, true);
|
|
194
240
|
|
|
195
241
|
return true;
|
|
196
242
|
}
|
|
@@ -234,20 +280,20 @@ export class Deque {
|
|
|
234
280
|
* @param {T} e
|
|
235
281
|
*/
|
|
236
282
|
addFirst(e) {
|
|
237
|
-
this.
|
|
238
|
-
this.__head = this.
|
|
283
|
+
this.__check_and_expand();
|
|
284
|
+
this.__head = this.__circular_previous_position(this.__head);
|
|
239
285
|
this.__data[this.__head] = e;
|
|
240
286
|
this.resetStatus(true);
|
|
241
287
|
}
|
|
242
288
|
|
|
243
289
|
/**
|
|
244
290
|
* Remove element from the front of the queue
|
|
245
|
-
* @returns {T}
|
|
291
|
+
* @returns {T|undefined}
|
|
246
292
|
*/
|
|
247
293
|
removeFirst() {
|
|
248
294
|
const element = this.__data[this.__head];
|
|
249
295
|
this.__data[this.__head] = undefined;
|
|
250
|
-
this.__head = this.
|
|
296
|
+
this.__head = this.__circular_next_position(this.__head);
|
|
251
297
|
this.resetStatus(false);
|
|
252
298
|
return element;
|
|
253
299
|
}
|
|
@@ -265,9 +311,9 @@ export class Deque {
|
|
|
265
311
|
* @param {T} e
|
|
266
312
|
*/
|
|
267
313
|
addLast(e) {
|
|
268
|
-
this.
|
|
314
|
+
this.__check_and_expand();
|
|
269
315
|
this.__data[this.__tail] = e;
|
|
270
|
-
this.__tail = this.
|
|
316
|
+
this.__tail = this.__circular_next_position(this.__tail);
|
|
271
317
|
this.resetStatus(true);
|
|
272
318
|
}
|
|
273
319
|
|
|
@@ -276,7 +322,7 @@ export class Deque {
|
|
|
276
322
|
* @returns {T}
|
|
277
323
|
*/
|
|
278
324
|
removeLast() {
|
|
279
|
-
const last = this.
|
|
325
|
+
const last = this.__circular_previous_position(this.__tail);
|
|
280
326
|
const element = this.__data[last];
|
|
281
327
|
this.__data[last] = undefined;
|
|
282
328
|
this.__tail = last;
|
|
@@ -287,10 +333,10 @@ export class Deque {
|
|
|
287
333
|
|
|
288
334
|
/**
|
|
289
335
|
* Peek element from the end of the queue without removing it
|
|
290
|
-
* @returns {T}
|
|
336
|
+
* @returns {T|undefined}
|
|
291
337
|
*/
|
|
292
338
|
getLast() {
|
|
293
|
-
const last = this.
|
|
339
|
+
const last = this.__circular_previous_position(this.__tail);
|
|
294
340
|
return this.__data[last];
|
|
295
341
|
}
|
|
296
342
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compute_set_difference.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_difference.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compute_set_difference.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/compute_set_difference.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,0EA+BC"}
|