@fluidframework/matrix 2.0.0-dev.5.2.0.169897 → 2.0.0-dev.6.4.0.191258

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 (84) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +4 -3
  3. package/dist/handlecache.js +3 -3
  4. package/dist/handlecache.js.map +1 -1
  5. package/dist/handletable.d.ts +8 -1
  6. package/dist/handletable.d.ts.map +1 -1
  7. package/dist/handletable.js +11 -3
  8. package/dist/handletable.js.map +1 -1
  9. package/dist/matrix.d.ts.map +1 -1
  10. package/dist/matrix.js +17 -18
  11. package/dist/matrix.js.map +1 -1
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/permutationvector.d.ts +1 -2
  16. package/dist/permutationvector.d.ts.map +1 -1
  17. package/dist/permutationvector.js +11 -8
  18. package/dist/permutationvector.js.map +1 -1
  19. package/dist/serialization.js +2 -2
  20. package/dist/serialization.js.map +1 -1
  21. package/dist/sparsearray2d.d.ts.map +1 -1
  22. package/dist/sparsearray2d.js +1 -0
  23. package/dist/sparsearray2d.js.map +1 -1
  24. package/dist/undoprovider.js +8 -9
  25. package/dist/undoprovider.js.map +1 -1
  26. package/lib/handlecache.js +1 -1
  27. package/lib/handlecache.js.map +1 -1
  28. package/lib/handletable.d.ts +8 -1
  29. package/lib/handletable.d.ts.map +1 -1
  30. package/lib/handletable.js +11 -3
  31. package/lib/handletable.js.map +1 -1
  32. package/lib/matrix.d.ts.map +1 -1
  33. package/lib/matrix.js +3 -4
  34. package/lib/matrix.js.map +1 -1
  35. package/lib/packageVersion.d.ts +1 -1
  36. package/lib/packageVersion.js +1 -1
  37. package/lib/packageVersion.js.map +1 -1
  38. package/lib/permutationvector.d.ts +1 -2
  39. package/lib/permutationvector.d.ts.map +1 -1
  40. package/lib/permutationvector.js +6 -3
  41. package/lib/permutationvector.js.map +1 -1
  42. package/lib/serialization.js +1 -1
  43. package/lib/serialization.js.map +1 -1
  44. package/lib/sparsearray2d.d.ts.map +1 -1
  45. package/lib/sparsearray2d.js +1 -0
  46. package/lib/sparsearray2d.js.map +1 -1
  47. package/lib/undoprovider.js +5 -6
  48. package/lib/undoprovider.js.map +1 -1
  49. package/package.json +29 -33
  50. package/src/handlecache.ts +1 -1
  51. package/src/handletable.ts +22 -2
  52. package/src/matrix.ts +2 -1
  53. package/src/packageVersion.ts +1 -1
  54. package/src/permutationvector.ts +4 -6
  55. package/src/serialization.ts +1 -1
  56. package/src/sparsearray2d.ts +1 -0
  57. package/src/undoprovider.ts +1 -1
  58. package/dist/bspSet.d.ts +0 -125
  59. package/dist/bspSet.d.ts.map +0 -1
  60. package/dist/bspSet.js +0 -425
  61. package/dist/bspSet.js.map +0 -1
  62. package/dist/productSet.d.ts +0 -61
  63. package/dist/productSet.d.ts.map +0 -1
  64. package/dist/productSet.js +0 -679
  65. package/dist/productSet.js.map +0 -1
  66. package/dist/split.d.ts +0 -41
  67. package/dist/split.d.ts.map +0 -1
  68. package/dist/split.js +0 -127
  69. package/dist/split.js.map +0 -1
  70. package/lib/bspSet.d.ts +0 -125
  71. package/lib/bspSet.d.ts.map +0 -1
  72. package/lib/bspSet.js +0 -402
  73. package/lib/bspSet.js.map +0 -1
  74. package/lib/productSet.d.ts +0 -61
  75. package/lib/productSet.d.ts.map +0 -1
  76. package/lib/productSet.js +0 -665
  77. package/lib/productSet.js.map +0 -1
  78. package/lib/split.d.ts +0 -41
  79. package/lib/split.d.ts.map +0 -1
  80. package/lib/split.js +0 -116
  81. package/lib/split.js.map +0 -1
  82. package/src/bspSet.ts +0 -722
  83. package/src/productSet.ts +0 -1038
  84. package/src/split.ts +0 -171
package/lib/bspSet.js DELETED
@@ -1,402 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { __assign } from "tslib";
6
- export const pair = (left, right) => [left, right];
7
- // using this polyfill, because `Object.assign` is not supported in IE.
8
- const ObjectAssign = __assign;
9
- export var SetKind;
10
- (function (SetKind) {
11
- SetKind[SetKind["Dense"] = 0] = "Dense";
12
- SetKind[SetKind["Empty"] = 1] = "Empty";
13
- })(SetKind || (SetKind = {}));
14
- export const dense = SetKind.Dense;
15
- export const empty = SetKind.Empty;
16
- export const cacheKeySplitting = (splitFunction, top, maxDepth = 10) => (key) => {
17
- if (key.split !== undefined) {
18
- return key.split;
19
- }
20
- const split = splitFunction(key);
21
- const depth = key === top ? 0 : key.depth;
22
- if (depth !== undefined && depth < maxDepth) {
23
- key.split = split;
24
- split[0][0].depth = depth + 1;
25
- split[1][0].depth = depth + 1;
26
- }
27
- return split;
28
- };
29
- export function fromUntyped(setOperations, root) {
30
- if (root === empty || root === dense) {
31
- return root;
32
- }
33
- return { setOperations, root };
34
- }
35
- const sparse = (left, right, pathKey, key, isExact) => ({ key, pathKey, left, right, isExact });
36
- function fromKey(pathKey, key, isExact) {
37
- if (isExact) {
38
- return sparse(undefined, undefined, pathKey, key, true);
39
- }
40
- return sparse(undefined, undefined, pathKey, key, false);
41
- }
42
- export function lazy(setOperations, pathKey, key) {
43
- if (!setOperations.meets(pathKey, key)) {
44
- return empty;
45
- }
46
- const cmp = setOperations.compare(pathKey, key);
47
- if (cmp !== undefined) {
48
- if (cmp <= 0) {
49
- return dense;
50
- }
51
- return fromKey(pathKey, key, true);
52
- }
53
- // this is not exactly necessary, but increases the amount of exact nodes and thus we can often
54
- // prune earlier.
55
- // Also, having intersect always work guarantees exact nodes, thus allowing for more efficient
56
- // storage and computation.
57
- const newKey = setOperations.intersect(pathKey, key);
58
- if (newKey !== undefined) {
59
- return fromKey(pathKey, newKey, true);
60
- }
61
- return fromKey(pathKey, key, false);
62
- }
63
- export function createFromKey(uncachedSetOperations) {
64
- const setOperations = Object.assign(Object.assign({}, uncachedSetOperations), { split: cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top) });
65
- return (key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));
66
- }
67
- function unionExact(setOperations, left, right) {
68
- const { pathKey, key: leftKey } = left;
69
- const { key: rightKey } = right;
70
- const cmp = setOperations.compare(leftKey, rightKey);
71
- if (cmp !== undefined) {
72
- return cmp < 0 ? right : left;
73
- }
74
- const combinedKey = setOperations.union(leftKey, rightKey);
75
- if (combinedKey !== undefined) {
76
- const combinedCmp = setOperations.compare(combinedKey, pathKey);
77
- if (combinedCmp !== undefined && combinedCmp === 0) {
78
- return dense;
79
- }
80
- return fromKey(pathKey, combinedKey, true);
81
- }
82
- return undefined;
83
- }
84
- /** This is an local combination, not a proper union. We use it to have simpler code elsewhere */
85
- function combineChildren(left, right) {
86
- if (left === empty) {
87
- if (right === empty) {
88
- return empty;
89
- }
90
- return sparse(left, right, undefined, undefined, false);
91
- }
92
- if (right === empty) {
93
- return sparse(left, right, undefined, undefined, false);
94
- }
95
- if (left === dense) {
96
- if (right === dense) {
97
- return dense;
98
- }
99
- return sparse(left, right, undefined, undefined, false);
100
- }
101
- return sparse(left, right, undefined, undefined, false);
102
- }
103
- function materialize(setOperations, set) {
104
- if (set.left !== undefined) {
105
- return set;
106
- }
107
- const [[left], [right]] = setOperations.split(set.pathKey);
108
- const lChild = lazy(setOperations, left, set.key);
109
- const rChild = lazy(setOperations, right, set.key);
110
- const res = combineChildren(lChild, rChild);
111
- if (res === empty || res === dense) {
112
- throw new Error("incorrect set operations implementation");
113
- }
114
- // first check, that res actually has the desired type
115
- const typeCheck = res;
116
- const setAlias = set;
117
- return ObjectAssign(setAlias, {
118
- left: typeCheck.left,
119
- right: typeCheck.right,
120
- });
121
- }
122
- export function unionUntyped(setOperations, left, right) {
123
- if (right === empty) {
124
- return left;
125
- }
126
- if (right === dense) {
127
- return right;
128
- }
129
- if (left === empty) {
130
- return right;
131
- }
132
- if (left === dense) {
133
- return left;
134
- }
135
- if (left.isExact && right.isExact) {
136
- const res = unionExact(setOperations, left, right);
137
- if (res !== undefined) {
138
- return res;
139
- }
140
- }
141
- const newLeft = materialize(setOperations, left);
142
- const newRight = materialize(setOperations, right);
143
- const lChild = unionUntyped(setOperations, newLeft.left, newRight.left);
144
- const rChild = unionUntyped(setOperations, newLeft.right, newRight.right);
145
- return combineChildren(lChild, rChild);
146
- }
147
- export function union(left, right) {
148
- if (right === empty) {
149
- return left;
150
- }
151
- if (right === dense) {
152
- return right;
153
- }
154
- if (left === empty) {
155
- return right;
156
- }
157
- if (left === dense) {
158
- return left;
159
- }
160
- return fromUntyped(left.setOperations, unionUntyped(left.setOperations, left.root, right.root));
161
- }
162
- function intersectExact(setOperations, left, right) {
163
- const { pathKey, key: leftKey } = left;
164
- const { key: rightKey } = right;
165
- if (!setOperations.meets(leftKey, rightKey)) {
166
- return empty;
167
- }
168
- const cmp = setOperations.compare(leftKey, rightKey);
169
- if (cmp !== undefined) {
170
- return cmp < 0 ? left : right;
171
- }
172
- const combinedKey = setOperations.intersect(leftKey, rightKey);
173
- if (combinedKey !== undefined) {
174
- return fromKey(pathKey, combinedKey, true);
175
- }
176
- return undefined;
177
- }
178
- export function intersectUntyped(setOperations, left, right) {
179
- if (left === empty) {
180
- return left;
181
- }
182
- if (right === empty) {
183
- return right;
184
- }
185
- if (left === dense) {
186
- return right;
187
- }
188
- if (right === dense) {
189
- return left;
190
- }
191
- if (left.isExact && right.isExact) {
192
- const res = intersectExact(setOperations, left, right);
193
- if (res !== undefined) {
194
- return res;
195
- }
196
- }
197
- const newLeft = materialize(setOperations, left);
198
- const newRight = materialize(setOperations, right);
199
- const lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);
200
- const rChild = intersectUntyped(setOperations, newLeft.right, newRight.right);
201
- return combineChildren(lChild, rChild);
202
- }
203
- export function intersect(left, right) {
204
- if (left === empty) {
205
- return left;
206
- }
207
- if (right === empty) {
208
- return right;
209
- }
210
- if (left === dense) {
211
- return right;
212
- }
213
- if (right === dense) {
214
- return left;
215
- }
216
- return fromUntyped(left.setOperations, intersectUntyped(left.setOperations, left.root, right.root));
217
- }
218
- export function meetsUntyped(setOperations, left, right) {
219
- if (left === empty || right === empty) {
220
- return false;
221
- }
222
- if (left === dense || right === dense) {
223
- return true;
224
- }
225
- if (left.isExact && right.isExact) {
226
- return setOperations.meets(left.key, right.key);
227
- }
228
- const newLeft = materialize(setOperations, left);
229
- const newRight = materialize(setOperations, right);
230
- return (meetsUntyped(setOperations, newLeft.left, newRight.left) ||
231
- meetsUntyped(setOperations, newLeft.right, newRight.right));
232
- }
233
- export function meets(left, right) {
234
- if (left === empty || right === empty) {
235
- return false;
236
- }
237
- if (left === dense || right === dense) {
238
- return true;
239
- }
240
- return meetsUntyped(left.setOperations, left.root, right.root);
241
- }
242
- function exceptExact(setOperations, left, right) {
243
- const { pathKey, key: leftKey } = left;
244
- const { key: rightKey } = right;
245
- if (!setOperations.meets(leftKey, rightKey)) {
246
- return left;
247
- }
248
- const combinedKey = setOperations.except(leftKey, rightKey);
249
- if (combinedKey !== undefined) {
250
- return fromKey(pathKey, combinedKey, true);
251
- }
252
- return undefined;
253
- }
254
- export function exceptUntyped(setOperations, left, right) {
255
- if (left === empty) {
256
- return left;
257
- }
258
- if (right === empty) {
259
- return left;
260
- }
261
- if (right === dense) {
262
- return empty;
263
- }
264
- if (left === dense) {
265
- const newRight_inner = materialize(setOperations, right);
266
- const lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);
267
- const rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);
268
- return combineChildren(lChild_inner, rChild_inner);
269
- }
270
- if (left.isExact && right.isExact) {
271
- const res = exceptExact(setOperations, left, right);
272
- if (res !== undefined) {
273
- return res;
274
- }
275
- }
276
- const newLeft = materialize(setOperations, left);
277
- const newRight = materialize(setOperations, right);
278
- const lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);
279
- const rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);
280
- return combineChildren(lChild, rChild);
281
- }
282
- export function except(left, right) {
283
- if (left === empty) {
284
- return left;
285
- }
286
- if (right === empty) {
287
- return left;
288
- }
289
- if (right === dense) {
290
- return empty;
291
- }
292
- if (left === dense) {
293
- return fromUntyped(right.setOperations, exceptUntyped(right.setOperations, left, right.root));
294
- }
295
- return fromUntyped(left.setOperations, exceptUntyped(left.setOperations, left.root, right.root));
296
- }
297
- const compareExact = (setOperations, left, right) => setOperations.compare(left.key, right.key);
298
- export function combineCmp(left, right) {
299
- if (left === undefined || right === undefined) {
300
- return undefined;
301
- }
302
- if (left === 0) {
303
- return right;
304
- }
305
- if (right === 0) {
306
- return left;
307
- }
308
- return left === right ? left : undefined;
309
- }
310
- export function compareUntyped(setOperations, left, right) {
311
- if (left === right) {
312
- return 0;
313
- }
314
- if (left === empty) {
315
- return -1;
316
- }
317
- if (right === empty) {
318
- return 1;
319
- }
320
- if (left === dense) {
321
- if (right === dense) {
322
- return 0;
323
- }
324
- return 1;
325
- }
326
- if (right === dense) {
327
- return -1;
328
- }
329
- if (left.isExact && right.isExact) {
330
- return compareExact(setOperations, left, right);
331
- }
332
- const newLeft = materialize(setOperations, left);
333
- const newRight = materialize(setOperations, right);
334
- const lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);
335
- if (lCmp === undefined) {
336
- return undefined;
337
- }
338
- const rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);
339
- if (rCmp === undefined) {
340
- return undefined;
341
- }
342
- return combineCmp(lCmp, rCmp);
343
- }
344
- export function compare(left, right) {
345
- if (left === right) {
346
- return 0;
347
- }
348
- if (left === empty) {
349
- return -1;
350
- }
351
- if (right === empty) {
352
- return 1;
353
- }
354
- if (left === dense) {
355
- if (right === dense) {
356
- return 0;
357
- }
358
- return 1;
359
- }
360
- if (right === dense) {
361
- return -1;
362
- }
363
- return compareUntyped(left.setOperations, left.root, right.root);
364
- }
365
- export const symmetricDiff = (left, right) => union(except(left, right), except(right, left));
366
- export const complement = (set) => except(dense, set);
367
- function getNodeCountUntyped(set) {
368
- if (set === undefined || set === empty || set === dense) {
369
- return 0;
370
- }
371
- return getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;
372
- }
373
- export function getNodeCount(set) {
374
- if (set === empty || set === dense) {
375
- return 0;
376
- }
377
- return getNodeCountUntyped(set.root);
378
- }
379
- function forEachKeyUntyped(setOperations, set, f) {
380
- function loop(pathKey, set_inner) {
381
- if (set_inner === empty) {
382
- return true;
383
- }
384
- if (set_inner === dense) {
385
- return f(pathKey);
386
- }
387
- if (set_inner.isExact) {
388
- return f(set_inner.key);
389
- }
390
- const newSet = materialize(setOperations, set_inner);
391
- const [[left], [right]] = setOperations.split(pathKey);
392
- return loop(left, newSet.left) && loop(right, newSet.right);
393
- }
394
- return loop(setOperations.top, set);
395
- }
396
- export function forEachKey(set, f) {
397
- if (set === empty) {
398
- return true;
399
- }
400
- return forEachKeyUntyped(set.setOperations, set.root, f);
401
- }
402
- //# sourceMappingURL=bspSet.js.map
package/lib/bspSet.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAIjC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,QAAQ,CAAC;AAEpD,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IAClB,uCAAK,CAAA;IACL,uCAAK,CAAA;AACN,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB;AAsBD,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACnC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAuGnC,MAAM,CAAC,MAAM,iBAAiB,GAC7B,CACC,aAA0E,EAC1E,GAAmB,EACn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AK,EAAE;YACxB,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;SAClB;QACD,IAAI,SAAS,CAAC,OAAO,EAAE;YACtB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SACxB;QAED,MAAM,MAAM,GAAG,WAAW,CAAU,aAAa,EAAE,SAAS,CAAC,CAAC;QAC9D,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CACzB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,KAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { __assign } from \"tslib\";\n/** An interface for representing a readonly pair */\nexport type Pair<S, T = S> = readonly [S, T];\n\nexport const pair = <S, T = S>(left: S, right: T): Pair<S, T> => [left, right];\n\n// using this polyfill, because `Object.assign` is not supported in IE.\nconst ObjectAssign: typeof Object.assign = __assign;\n\nexport enum SetKind {\n\tDense,\n\tEmpty,\n}\n\ninterface TreeNode<Left, Right> {\n\treadonly left: Left;\n\treadonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n\treadonly key: Key;\n\treadonly pathKey: Key;\n\treadonly isExact: Exact;\n}\n\nexport type Empty = SetKind.Empty;\n\n/** The term *Dense* means that a given subset contains all the elements of its particular\n * bounds. E.g. the whole set would be dense w.r.t. the bounds of the whole space. Or\n * if a set represents an interval [a, b), then it would be dense, if there are no holes in it,\n * i.e. the set is represented exactly using the current bounds.\n */\nexport type Dense = SetKind.Dense;\n\nexport const dense = SetKind.Dense;\nexport const empty = SetKind.Empty;\n\ntype KeyUnexact<Key> = KeyNode<Key, false>;\n\n/** In the BSP-set, each node carries with it implicit bounds just by the position in the tree.\n * Furthermore, it can carry around a key. The key can either be an approximation, i.e. an upper bound\n * or it can be *exact*. Exact means, that the whole set can be exactly represented in terms of just the key.\n *\n * One might wonder, why we don't prune the tree at this point. This has to do with the fact that we are\n * representing arbitrary sets and so even though one of two sets could be represented exactly the other\n * might not be able to yet. In this case we need to unfold the key by splitting further. In order to avoid\n * excessive splitting and pruning, we just carry around the key but allow the tree to also be materialized, on-demand.\n */\ntype KeyExact<Key> = KeyNode<Key, true>;\n\ntype KeyUndefined = KeyNode<undefined, false>;\ntype KeyDefined<Key> = KeyUnexact<Key> | KeyExact<Key>;\n\ntype BalancePropertyHelper<Key, Left, Right> = TreeNode<\n\tUntypedSparse<Key> | Left,\n\tUntypedSparse<Key> | Right\n>;\n\ntype TreeDefined<Key> =\n\t| BalancePropertyHelper<Key, Empty, Dense>\n\t| BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n\t| (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n\t| (KeyDefined<Key> & TreeUndefined);\n/** The term *untyped* refers to the tree representation of a BSP set. Because BSP set trees are only compared in terms\n * of their structure, we need to ensure that cuts occur at the same exact points across all possible sets. This is\n * enforced by the fact, that at construction time, we attach an `Id` to each BSP set and only allow operations to\n * occur on sets with the same `Id`.\n *\n * The BSP set becomes *untyped*, when we drop that `Id`; now it is possible to operate on sets that are incompatible.\n * Doing this, however, allows us to store the set operations only once per set as opposed to carrying them around with\n * every node.\n */\nexport type UntypedBspSet<Key> = Empty | Dense | UntypedSparse<Key>;\n\n/** A set is considred *sparse*, if we know that w.r.t. to it's bounds it is neither empty, nor dense. */\ninterface Sparse<Key extends Cachable<Key>, Id> {\n\tsetOperations: SetOperations<Key, Id>;\n\troot: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> = Empty | Dense | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n\tdepth?: number;\n\tsplit?: Pair<Pair<CachedKey<T>, number>>;\n}\nexport type CachedKey<T> = T & KeyCache<T>;\nexport type Cachable<T> = Disjoint<keyof T, keyof KeyCache<T>>;\n\nexport type Disjoint<T, U> = [T, U] extends [Exclude<T, U>, Exclude<U, T>] ? any : never;\nexport type RequireAtLeastOne<T> = {\n\t[K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n\n/** This is a concrete set operations implementation, tagged with an arbitrary id. */\nexport interface SetOperations<Key extends Cachable<Key>, Id> {\n\t/** Id here is just a phantom type, so that we can associate the various set instances together */\n\treadonly id: Id;\n\n\t/** Split the key into two. This will only be called when the current key is incomparable with an element.\n\t * E.g. this would never be called if the key is already a 1x1 rectangle. */\n\treadonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n\t/** Tells, if a given key can be split further */\n\treadonly canSplit: (key: CachedKey<Key>) => boolean;\n\n\t/** Tells if two keys overlap at all. */\n\treadonly meets: (key1: Key, key2: Key) => boolean;\n\n\t/** Intersect the keys, if it is possible to exactly respresent their intersection.\n\t * An implementation is never required to compute the intersection as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n\t */\n\treadonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Unions the keys, if it is possible to exactly represent their union.\n\t * An implementation is never required to compute the union as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys are incomparable.\n\t */\n\treadonly union: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n\t * An implementation is never required to compute the difference as this is just an optimization.\n\t * Precondition: It is guaranteed that the keys meet.\n\t */\n\treadonly except: (key1: Key, key2: Key) => Key | undefined;\n\n\t/** Compare two keys */\n\treadonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n\t/** The top element of the set. */\n\treadonly top: Key;\n}\n\nexport const cacheKeySplitting =\n\t<Key>(\n\t\tsplitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n\t\ttop: CachedKey<Key>,\n\t\tmaxDepth: number = 10,\n\t) =>\n\t(key: CachedKey<Key>) => {\n\t\tif (key.split !== undefined) {\n\t\t\treturn key.split;\n\t\t}\n\n\t\tconst split = splitFunction(key);\n\t\tconst depth = key === top ? 0 : key.depth;\n\t\tif (depth !== undefined && depth < maxDepth) {\n\t\t\tkey.split = split;\n\t\t\tsplit[0][0].depth = depth + 1;\n\t\t\tsplit[1][0].depth = depth + 1;\n\t\t}\n\n\t\treturn split;\n\t};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\troot: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n\tif (root === empty || root === dense) {\n\t\treturn root;\n\t}\n\treturn { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n\tleft: Left,\n\tright: Right,\n\tpathKey: Key,\n\tkey: Key,\n\tisExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(pathKey: Key, key: Key, isExact: boolean): UntypedSparse<Key> {\n\tif (isExact) {\n\t\treturn sparse(undefined, undefined, pathKey, key, true as const);\n\t}\n\n\treturn sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tpathKey: Key,\n\tkey: Key,\n): UntypedBspSet<Key> {\n\tif (!setOperations.meets(pathKey, key)) {\n\t\treturn empty;\n\t}\n\tconst cmp = setOperations.compare(pathKey, key);\n\tif (cmp !== undefined) {\n\t\tif (cmp <= 0) {\n\t\t\treturn dense;\n\t\t}\n\n\t\treturn fromKey(pathKey, key, true);\n\t}\n\n\t// this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n\t// prune earlier.\n\t// Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n\t// storage and computation.\n\tconst newKey = setOperations.intersect(pathKey, key);\n\n\tif (newKey !== undefined) {\n\t\treturn fromKey(pathKey, newKey, true);\n\t}\n\n\treturn fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n\tuncachedSetOperations: SetOperations<Key, Id>,\n) {\n\tconst setOperations = {\n\t\t...uncachedSetOperations,\n\t\tsplit: cacheKeySplitting(uncachedSetOperations.split, uncachedSetOperations.top),\n\t};\n\treturn (key: Key) => fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? right : left;\n\t}\n\n\tconst combinedKey = setOperations.union(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\tconst combinedCmp = setOperations.compare(combinedKey, pathKey);\n\t\tif (combinedCmp !== undefined && combinedCmp === 0) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\treturn undefined;\n}\n\n/** This is an local combination, not a proper union. We use it to have simpler code elsewhere */\nfunction combineChildren<Key>(\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n\tif (left === empty) {\n\t\tif (right === empty) {\n\t\t\treturn empty;\n\t\t}\n\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (right === empty) {\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn dense;\n\t\t}\n\t\treturn sparse(left, right, undefined, undefined, false as const);\n\t}\n\n\treturn sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n\tif (set.left !== undefined) {\n\t\treturn set;\n\t}\n\n\tconst [[left], [right]] = setOperations.split(set.pathKey);\n\tconst lChild = lazy(setOperations, left, set.key);\n\tconst rChild = lazy(setOperations, right, set.key);\n\n\tconst res = combineChildren<Key>(lChild, rChild);\n\n\tif (res === empty || res === dense) {\n\t\tthrow new Error(\"incorrect set operations implementation\");\n\t}\n\n\t// first check, that res actually has the desired type\n\tconst typeCheck: TreeDefined<Key> = res;\n\n\tconst setAlias: UntypedSparse<Key> = set;\n\treturn ObjectAssign(setAlias, {\n\t\tleft: typeCheck.left,\n\t\tright: typeCheck.right,\n\t});\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = unionExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn right;\n\t}\n\tif (left === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tunionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key> & KeyExact<Key>,\n\tright: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn empty;\n\t}\n\n\tconst cmp = setOperations.compare(leftKey, rightKey);\n\tif (cmp !== undefined) {\n\t\treturn cmp < 0 ? left : right;\n\t}\n\n\tconst combinedKey = setOperations.intersect(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\tconst res = intersectExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = intersectUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn right;\n\t}\n\tif (left === dense) {\n\t\treturn right;\n\t}\n\tif (right === dense) {\n\t\treturn left;\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\tintersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\tif (left.isExact && right.isExact) {\n\t\treturn setOperations.meets(left.key, right.key);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\treturn (\n\t\tmeetsUntyped(setOperations, newLeft.left, newRight.left) ||\n\t\tmeetsUntyped(setOperations, newLeft.right, newRight.right)\n\t);\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): boolean {\n\tif (left === empty || right === empty) {\n\t\treturn false;\n\t}\n\tif (left === dense || right === dense) {\n\t\treturn true;\n\t}\n\treturn meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedSparse<Key> & KeyExact<Key>,\n\tright: KeyExact<Key>,\n) {\n\tconst { pathKey, key: leftKey } = left;\n\tconst { key: rightKey } = right;\n\n\tif (!setOperations.meets(leftKey, rightKey)) {\n\t\treturn left;\n\t}\n\n\tconst combinedKey = setOperations.except(leftKey, rightKey);\n\tif (combinedKey !== undefined) {\n\t\treturn fromKey(pathKey, combinedKey, true);\n\t}\n\n\treturn undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\tconst newRight_inner = materialize<Key, Id>(setOperations, right);\n\t\tconst lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n\t\tconst rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n\t\treturn combineChildren(lChild_inner, rChild_inner);\n\t}\n\tif (left.isExact && right.isExact) {\n\t\tconst res = exceptExact<Key, Id>(setOperations, left, right);\n\t\tif (res !== undefined) {\n\t\t\treturn res;\n\t\t}\n\t}\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\n\tconst lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n\tconst rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n\treturn combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n\tif (left === empty) {\n\t\treturn left;\n\t}\n\tif (right === empty) {\n\t\treturn left;\n\t}\n\tif (right === dense) {\n\t\treturn empty;\n\t}\n\tif (left === dense) {\n\t\treturn fromUntyped(\n\t\t\tright.setOperations,\n\t\t\texceptUntyped<Key, Id>(right.setOperations, left, right.root),\n\t\t);\n\t}\n\n\treturn fromUntyped(\n\t\tleft.setOperations,\n\t\texceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n\t);\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: KeyExact<Key>,\n\tright: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(left: -1 | 0 | 1 | undefined, right: -1 | 0 | 1 | undefined) {\n\tif (left === undefined || right === undefined) {\n\t\treturn undefined;\n\t}\n\tif (left === 0) {\n\t\treturn right;\n\t}\n\tif (right === 0) {\n\t\treturn left;\n\t}\n\treturn left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tleft: UntypedBspSet<Key>,\n\tright: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\tif (left.isExact && right.isExact) {\n\t\treturn compareExact(setOperations, left, right);\n\t}\n\n\tconst newLeft = materialize<Key, Id>(setOperations, left);\n\tconst newRight = materialize<Key, Id>(setOperations, right);\n\tconst lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n\tif (lCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\tconst rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n\tif (rCmp === undefined) {\n\t\treturn undefined;\n\t}\n\n\treturn combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) {\n\tif (left === right) {\n\t\treturn 0;\n\t}\n\n\tif (left === empty) {\n\t\treturn -1;\n\t}\n\n\tif (right === empty) {\n\t\treturn 1;\n\t}\n\n\tif (left === dense) {\n\t\tif (right === dense) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn 1;\n\t}\n\n\tif (right === dense) {\n\t\treturn -1;\n\t}\n\n\treturn compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n\tleft: BspSet<Key, Id>,\n\tright: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) =>\n\texcept(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n\tif (set === undefined || set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\n\treturn getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(set: BspSet<Key, Id>) {\n\tif (set === empty || set === dense) {\n\t\treturn 0;\n\t}\n\treturn getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n\tsetOperations: SetOperations<Key, Id>,\n\tset: UntypedBspSet<Key>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tfunction loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n\t\tif (set_inner === empty) {\n\t\t\treturn true;\n\t\t}\n\t\tif (set_inner === dense) {\n\t\t\treturn f(pathKey);\n\t\t}\n\t\tif (set_inner.isExact) {\n\t\t\treturn f(set_inner.key);\n\t\t}\n\n\t\tconst newSet = materialize<Key, Id>(setOperations, set_inner);\n\t\tconst [[left], [right]] = setOperations.split(pathKey);\n\t\treturn loop(left, newSet.left) && loop(right, newSet.right);\n\t}\n\n\treturn loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n\tset: Empty | Sparse<Key, Id>,\n\tf: (key: Key) => boolean,\n): boolean {\n\tif (set === empty) {\n\t\treturn true;\n\t}\n\treturn forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
@@ -1,61 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { BspSet, Empty, Dense, SetOperations, UntypedSparse } from "./bspSet";
6
- declare type Restrict<T, Props extends (keyof T)[]> = {
7
- [Prop in Props[number]]: T[Prop];
8
- };
9
- export declare type Product<T> = {
10
- readonly [dim in keyof T]: T[dim] extends BspSet<infer _TKey, infer _TId> ? T[dim] : never;
11
- };
12
- declare type UntypedProduct<T> = {
13
- readonly [dim in keyof T]?: T[dim] extends BspSet<infer TKey, infer _TId> ? UntypedSparse<TKey> : never;
14
- };
15
- declare type ProductOperations<T> = {
16
- readonly [dim in keyof T]: T[dim] extends BspSet<infer TKey, infer TId> ? SetOperations<TKey, TId> : never;
17
- };
18
- /** Given a cartesian product, a subspace is a subset of said space, such that it is also a cartesian product
19
- * and all the dimensions form subsets of the original cartesian product.
20
- *
21
- * This is a generalized notion of something like hyper-rectangles. Examples include:
22
- * - Rectangles
23
- * - Individual cells in a grid
24
- * - Rectangular ranges with missing rows and/or columns
25
- *
26
- * For the actual definition and properties, please read the document about *Operations on Cartesian Products*.
27
- */
28
- interface Subspace<T> {
29
- readonly isSubspace: true;
30
- readonly bounds: UntypedProduct<T>;
31
- }
32
- interface Union<T> {
33
- readonly isSubspace: false;
34
- readonly left: UntypedSparseProduct<T>;
35
- readonly right: UntypedSparseProduct<T>;
36
- readonly bounds: UntypedProduct<T>;
37
- readonly subspaceCount: number;
38
- }
39
- declare type UntypedSparseProduct<T> = Subspace<T> | Union<T>;
40
- interface SparseProduct<T> {
41
- readonly productOperations: ProductOperations<T>;
42
- readonly root: UntypedSparseProduct<T>;
43
- }
44
- export declare type ProductSet<T> = Empty | Dense | SparseProduct<T>;
45
- export declare const createFromProduct: <T>(product: Product<T>) => ProductSet<T>;
46
- declare type Compatible<T, U> = {
47
- [dim in keyof T & keyof U]: T[dim];
48
- };
49
- export declare function project<T, Props extends (keyof T)[]>(set: ProductSet<T>, ...dims: Props): ProductSet<Restrict<T, Props>>;
50
- export declare function unionProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(left: ProductSet<T>, right: ProductSet<U>): ProductSet<T & U>;
51
- export declare function intersectProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(left: ProductSet<T>, right: ProductSet<U>): ProductSet<T & U>;
52
- export declare function exceptProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(left: ProductSet<T>, right: ProductSet<U>): ProductSet<T & U>;
53
- export declare function compareProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(left: ProductSet<T>, right: ProductSet<U>): 0 | 1 | -1 | undefined;
54
- export declare function meetsProduct<T extends Compatible<U, T>, U extends Compatible<T, U>>(left: ProductSet<T>, right: ProductSet<U>): boolean;
55
- export declare const complementProduct: <T>(set: ProductSet<T>) => ProductSet<Compatible<T, unknown> & T>;
56
- export declare const symmetricDiffProduct: <T>(left: ProductSet<T>, right: ProductSet<T>) => ProductSet<T>;
57
- export declare function getSubspaces<T>(set: ProductSet<T>): UntypedProduct<T>[];
58
- export declare function forEachProduct<T, Props extends (keyof T)[]>(set: ProductSet<T>, f: (product: Product<Restrict<T, Props>>) => boolean, ...dims: Props): boolean;
59
- export declare function getSubspaceCount<T>(set: ProductSet<T>): number;
60
- export {};
61
- //# sourceMappingURL=productSet.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"productSet.d.ts","sourceRoot":"","sources":["../src/productSet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EAGN,KAAK,EACL,KAAK,EAEL,aAAa,EAQb,aAAa,EAIb,MAAM,UAAU,CAAC;AAElB,aAAK,QAAQ,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,MAAM,CAAC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