@woosh/meep-engine 2.106.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.
- package/build/meep.cjs +320 -165
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +320 -165
- package/package.json +1 -1
- package/src/core/collection/array/array_copy.spec.d.ts +2 -0
- package/src/core/collection/array/array_copy.spec.d.ts.map +1 -0
- package/src/core/collection/array/array_copy.spec.js +19 -0
- package/src/core/collection/list/List.d.ts.map +1 -1
- package/src/core/collection/list/List.js +55 -30
- package/src/core/collection/list/List.spec.js +101 -0
- package/src/core/collection/list/ListForwarder.d.ts.map +1 -1
- package/src/core/collection/list/ListForwarder.js +49 -53
- package/src/core/collection/list/ListForwarder.spec.js +2 -0
- package/src/core/collection/list/SortedListProjection.d.ts +4 -1
- package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
- package/src/core/collection/list/SortedListProjection.js +4 -1
- package/src/core/collection/map/AbstractAsyncMap.d.ts.map +1 -1
- package/src/core/collection/map/AbstractAsyncMap.js +0 -3
- package/src/core/collection/map/AsyncMapWrapper.d.ts +6 -10
- package/src/core/collection/map/AsyncMapWrapper.d.ts.map +1 -1
- package/src/core/collection/map/AsyncMapWrapper.js +14 -9
- package/src/core/collection/map/HashMap.d.ts.map +1 -1
- package/src/core/collection/map/HashMap.js +14 -0
- package/src/core/collection/map/ObservedMap.d.ts +12 -3
- package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
- package/src/core/collection/map/ObservedMap.js +14 -4
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +100 -95
- package/src/core/collection/set/ArraySet.d.ts.map +1 -0
- package/src/core/collection/set/{Set.js → ArraySet.js} +2 -2
- package/src/core/collection/set/set_remove.d.ts +3 -3
- package/src/core/collection/set/set_remove.d.ts.map +1 -1
- package/src/core/collection/set/set_remove.js +5 -5
- package/src/core/color/oklab/find_gamut_intersection.js +1 -1
- package/src/core/geom/2d/Rectangle.d.ts +54 -5
- package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
- package/src/core/geom/2d/Rectangle.js +70 -3
- package/src/core/geom/2d/circle/Circle.d.ts +1 -1
- package/src/core/geom/2d/circle/Circle.js +1 -1
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
- package/src/core/geom/2d/compute_triangle_area_2d.js +7 -1
- package/src/core/geom/2d/shape/AbstractShape.d.ts +2 -0
- package/src/core/geom/2d/shape/AbstractShape.d.ts.map +1 -1
- package/src/core/geom/2d/shape/AbstractShape.js +8 -2
- package/src/core/geom/2d/shape/CircleShape.d.ts +14 -0
- package/src/core/geom/2d/shape/CircleShape.d.ts.map +1 -1
- package/src/core/geom/2d/shape/CircleShape.js +64 -22
- package/src/core/geom/2d/uv_map_circle_to_square.d.ts +8 -0
- package/src/core/geom/2d/uv_map_circle_to_square.d.ts.map +1 -0
- package/src/core/geom/2d/{UvUtils.js → uv_map_circle_to_square.js} +2 -17
- package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts +2 -0
- package/src/core/geom/2d/uv_map_circle_to_square.spec.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_circle_to_square.spec.js +28 -0
- package/src/core/geom/2d/uv_map_square_to_circle.d.ts +8 -0
- package/src/core/geom/2d/uv_map_square_to_circle.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_square_to_circle.js +14 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts +2 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.d.ts.map +1 -0
- package/src/core/geom/2d/uv_map_square_to_circle.spec.js +30 -0
- package/src/core/geom/Vector3.d.ts +13 -4
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +83 -36
- package/src/core/geom/Vector3.spec.js +113 -12
- package/src/core/collection/set/Set.d.ts.map +0 -1
- package/src/core/geom/2d/Geometry2D.d.ts +0 -31
- package/src/core/geom/2d/Geometry2D.d.ts.map +0 -1
- package/src/core/geom/2d/Geometry2D.js +0 -59
- package/src/core/geom/2d/UvUtils.d.ts +0 -15
- package/src/core/geom/2d/UvUtils.d.ts.map +0 -1
- package/src/core/geom/2d/UvUtils.spec.d.ts +0 -2
- package/src/core/geom/2d/UvUtils.spec.d.ts.map +0 -1
- package/src/core/geom/2d/UvUtils.spec.js +0 -55
- /package/src/core/collection/set/{Set.d.ts → ArraySet.d.ts} +0 -0
|
@@ -318,6 +318,8 @@ export class HashMap {
|
|
|
318
318
|
#build_key_hash(key) {
|
|
319
319
|
const original = this.keyHashFunction(key);
|
|
320
320
|
|
|
321
|
+
assert.isInteger(original, 'hash');
|
|
322
|
+
|
|
321
323
|
return original === RESERVED_HASH ? RESERVED_HASH_SUBSTITUTE : original;
|
|
322
324
|
}
|
|
323
325
|
|
|
@@ -358,6 +360,9 @@ export class HashMap {
|
|
|
358
360
|
this.#entries_bound++;
|
|
359
361
|
|
|
360
362
|
if (this.#entries[i] !== undefined) {
|
|
363
|
+
|
|
364
|
+
// entry exists, let's reuse it
|
|
365
|
+
|
|
361
366
|
const entry = this.#entries[i];
|
|
362
367
|
|
|
363
368
|
assert.equal(entry.hash, RESERVED_HASH, 'Entry is occupied');
|
|
@@ -365,8 +370,13 @@ export class HashMap {
|
|
|
365
370
|
entry.hash = hash;
|
|
366
371
|
entry.key = k;
|
|
367
372
|
entry.value = v;
|
|
373
|
+
|
|
368
374
|
} else {
|
|
375
|
+
|
|
376
|
+
// entry slot is empty
|
|
377
|
+
|
|
369
378
|
this.#entries[i] = new HashMapEntry(k, v, hash);
|
|
379
|
+
|
|
370
380
|
}
|
|
371
381
|
|
|
372
382
|
return i;
|
|
@@ -525,6 +535,8 @@ export class HashMap {
|
|
|
525
535
|
* @return {V}
|
|
526
536
|
*/
|
|
527
537
|
getOrCompute(key, compute, compute_context) {
|
|
538
|
+
assert.isFunction(compute, 'compute');
|
|
539
|
+
|
|
528
540
|
const existing = this.get(key);
|
|
529
541
|
|
|
530
542
|
if (existing !== undefined) {
|
|
@@ -748,6 +760,8 @@ export class HashMap {
|
|
|
748
760
|
}
|
|
749
761
|
|
|
750
762
|
forEach(callback, thisArg) {
|
|
763
|
+
assert.isFunction(callback, 'callback');
|
|
764
|
+
|
|
751
765
|
const count = this.#bin_count;
|
|
752
766
|
const entries = this.#entries;
|
|
753
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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;
|
|
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":"
|
|
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
|
-
|
|
64
|
-
const head = this
|
|
65
|
-
const tail = this
|
|
68
|
+
#reset_status(adding) {
|
|
69
|
+
const head = this.#head;
|
|
70
|
+
const tail = this.#tail;
|
|
66
71
|
|
|
67
72
|
if (head === tail) {
|
|
68
|
-
this
|
|
73
|
+
this.#status = adding ? STATUS_FULL : STATUS_EMPTY;
|
|
69
74
|
} else {
|
|
70
|
-
this
|
|
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
|
-
|
|
85
|
+
#circular_next_position(current) {
|
|
81
86
|
const next = current + 1;
|
|
82
87
|
|
|
83
|
-
const length = this.
|
|
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
|
-
|
|
99
|
+
#circular_previous_position(current) {
|
|
95
100
|
const prev = current - 1;
|
|
96
|
-
return (prev < 0) ? (this.
|
|
101
|
+
return (prev < 0) ? (this.#data.length - 1) : prev;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
const status = this
|
|
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.
|
|
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
|
|
131
|
+
const head = this.#head;
|
|
127
132
|
|
|
128
133
|
// copy the front portion
|
|
129
|
-
array_copy(this
|
|
134
|
+
array_copy(this.#data, head, new_data, 0, length - head);
|
|
130
135
|
// copy the remainder
|
|
131
|
-
array_copy(this
|
|
136
|
+
array_copy(this.#data, 0, new_data, length - head, head);
|
|
132
137
|
|
|
133
|
-
this
|
|
134
|
-
this
|
|
138
|
+
this.#head = 0;
|
|
139
|
+
this.#tail = length;
|
|
135
140
|
|
|
136
|
-
this
|
|
141
|
+
this.#status = STATUS_NORMAL;
|
|
137
142
|
|
|
138
|
-
this
|
|
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
|
|
151
|
-
let cursor = this
|
|
152
|
-
const tail = this
|
|
155
|
+
if (this.#status !== STATUS_EMPTY) {
|
|
156
|
+
let cursor = this.#head;
|
|
157
|
+
const tail = this.#tail;
|
|
153
158
|
|
|
154
159
|
do {
|
|
155
|
-
this
|
|
156
|
-
cursor = this
|
|
160
|
+
this.#data[cursor] = undefined;
|
|
161
|
+
cursor = this.#circular_next_position(cursor);
|
|
157
162
|
} while (cursor !== tail);
|
|
158
163
|
|
|
159
|
-
this
|
|
164
|
+
this.#status = STATUS_EMPTY;
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
this
|
|
163
|
-
this
|
|
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
|
|
175
|
+
const data = this.#data;
|
|
171
176
|
|
|
172
|
-
if (this
|
|
177
|
+
if (this.#status === STATUS_FULL) {
|
|
173
178
|
return data.length;
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
const head = this
|
|
177
|
-
const tail = this
|
|
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
|
-
|
|
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
|
|
200
|
+
const head = this.#head;
|
|
196
201
|
|
|
197
202
|
while (cursor !== head) {
|
|
198
|
-
const next = this
|
|
199
|
-
this
|
|
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
|
|
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
|
|
214
|
+
const tail = this.#tail;
|
|
210
215
|
|
|
211
216
|
while (cursor !== tail) {
|
|
212
|
-
const next = this
|
|
213
|
-
this
|
|
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
|
|
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
|
|
227
|
+
this.#data[cursor] = undefined;
|
|
223
228
|
|
|
224
|
-
this
|
|
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
|
|
238
|
+
const i = this.#index_of(e);
|
|
234
239
|
|
|
235
240
|
if (i === -1) {
|
|
236
241
|
return false;
|
|
237
242
|
}
|
|
238
243
|
|
|
239
|
-
this
|
|
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
|
-
|
|
255
|
+
#index_of(e) {
|
|
251
256
|
const size = this.size();
|
|
252
257
|
|
|
253
|
-
const data = this
|
|
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
|
|
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
|
|
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
|
|
284
|
-
this
|
|
285
|
-
this
|
|
286
|
-
this
|
|
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
|
|
295
|
-
this
|
|
296
|
-
this
|
|
297
|
-
this
|
|
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
|
|
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
|
|
315
|
-
this
|
|
316
|
-
this
|
|
317
|
-
this
|
|
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
|
|
326
|
-
const element = this
|
|
327
|
-
this
|
|
328
|
-
this
|
|
329
|
-
this
|
|
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
|
|
340
|
-
return this
|
|
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
|
|
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
|
|
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>}
|
|
6
|
-
* @param {Set<T>}
|
|
5
|
+
* @param {Set<T>} from
|
|
6
|
+
* @param {Set<T>} to_be_removed
|
|
7
7
|
*/
|
|
8
|
-
export function set_remove<T>(
|
|
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,
|
|
1
|
+
{"version":3,"file":"set_remove.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/set/set_remove.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,yEASC"}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Remove all elements of B from A.
|
|
3
3
|
* This operation mutates A
|
|
4
4
|
* @template T
|
|
5
|
-
* @param {Set<T>}
|
|
6
|
-
* @param {Set<T>}
|
|
5
|
+
* @param {Set<T>} from
|
|
6
|
+
* @param {Set<T>} to_be_removed
|
|
7
7
|
*/
|
|
8
|
-
export function set_remove(
|
|
9
|
-
const bs = Array.from(
|
|
8
|
+
export function set_remove(from, to_be_removed) {
|
|
9
|
+
const bs = Array.from(to_be_removed);
|
|
10
10
|
|
|
11
11
|
const n = bs.length;
|
|
12
12
|
for (let i = 0; i < n; i++) {
|
|
13
13
|
const t = bs[i];
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
from.delete(t);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -20,7 +20,7 @@ export function find_gamut_intersection(a, b, L1, C1, L0) {
|
|
|
20
20
|
// Find the cusp of the gamut triangle
|
|
21
21
|
find_cusp(cusp, a, b);
|
|
22
22
|
|
|
23
|
-
// Find the intersection for upper and lower half
|
|
23
|
+
// Find the intersection for upper and lower half separately
|
|
24
24
|
let t;
|
|
25
25
|
if (((L1 - L0) * cusp[1] - (cusp[0] - L0) * C1) <= 0.) {
|
|
26
26
|
// Lower half
|
|
@@ -19,6 +19,26 @@ declare class Rectangle {
|
|
|
19
19
|
* @type {Vector2}
|
|
20
20
|
*/
|
|
21
21
|
readonly size: Vector2;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @return {number}
|
|
25
|
+
*/
|
|
26
|
+
get x0(): number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @return {number}
|
|
30
|
+
*/
|
|
31
|
+
get x1(): number;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @return {number}
|
|
35
|
+
*/
|
|
36
|
+
get y0(): number;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @return {number}
|
|
40
|
+
*/
|
|
41
|
+
get y1(): number;
|
|
22
42
|
/**
|
|
23
43
|
*
|
|
24
44
|
* @param {number} x
|
|
@@ -61,11 +81,40 @@ declare class Rectangle {
|
|
|
61
81
|
* @returns {boolean}
|
|
62
82
|
*/
|
|
63
83
|
_overlaps(x0: number, y0: number, x1: number, y1: number): boolean;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @param {Rectangle} other
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
overlaps(other: Rectangle): boolean;
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {number} x0
|
|
93
|
+
* @param {number} y0
|
|
94
|
+
* @param {number} x1
|
|
95
|
+
* @param {number} y1
|
|
96
|
+
*/
|
|
97
|
+
_resizeToFit(x0: number, y0: number, x1: number, y1: number): void;
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
* @param {Rectangle} other
|
|
101
|
+
*/
|
|
102
|
+
resizeToFit(other: Rectangle): void;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @param {number} x0
|
|
106
|
+
* @param {number} y0
|
|
107
|
+
* @param {number} x1
|
|
108
|
+
* @param {number} y1
|
|
109
|
+
* @returns {boolean}
|
|
110
|
+
*/
|
|
111
|
+
_contains(x0: number, y0: number, x1: number, y1: number): boolean;
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {Rectangle} other
|
|
115
|
+
* @returns {boolean}
|
|
116
|
+
*/
|
|
117
|
+
contains(other: Rectangle): boolean;
|
|
69
118
|
/**
|
|
70
119
|
*
|
|
71
120
|
* @param {Vector2} result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";AAUA;IACI;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,EAgBhB;IAXG;;;OAGG;IACH,mBAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEqB;IAG1C;;;;;;OAMG;IACH,OALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAKhB;IAED;;;OAGG;IACH,SAFa,SAAS,
|
|
1
|
+
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";AAUA;IACI;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,EAgBhB;IAXG;;;OAGG;IACH,mBAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEqB;IAG1C;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;;;;OAMG;IACH,OALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAKhB;IAED;;;OAGG;IACH,SAFa,SAAS,CAUrB;IAED;;;OAGG;IACH,YAFW,SAAS,QAKnB;IAED;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,kBAHW,SAAS,GACP,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CAQnB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAyBhB;IAED;;;OAGG;IACH,mBAFW,SAAS,QASnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAYnB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CASnB;IAED;;;OAGG;IACH,sBAFW,OAAO,QAUjB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,gBAHW,MAAO,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,GAAC,UAAU,iBACnD,MAAM,QAOhB;IAED;;;MAKC;IAED,0BAGC;IAGL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;oBAxRmB,eAAe"}
|