@fluidframework/matrix 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0
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/.eslintrc.js +20 -21
- package/.mocharc.js +2 -2
- package/README.md +21 -21
- package/api-extractor.json +2 -2
- package/bench/bsp-set-optimizations.md +5 -5
- package/bench/src/index.ts +38 -20
- package/bench/src/read/map.ts +16 -10
- package/bench/src/read/nativearray.ts +16 -10
- package/bench/src/read/test.ts +17 -19
- package/bench/src/read/tiled.ts +240 -181
- package/bench/src/util.ts +19 -18
- package/bench/tsconfig.json +8 -13
- package/dist/bspSet.d.ts.map +1 -1
- package/dist/bspSet.js.map +1 -1
- package/dist/handlecache.d.ts.map +1 -1
- package/dist/handlecache.js +1 -3
- package/dist/handlecache.js.map +1 -1
- package/dist/handletable.d.ts.map +1 -1
- package/dist/handletable.js +7 -3
- package/dist/handletable.js.map +1 -1
- package/dist/matrix.d.ts +1 -1
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +28 -19
- package/dist/matrix.js.map +1 -1
- package/dist/ops.d.ts.map +1 -1
- package/dist/ops.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/permutationvector.d.ts.map +1 -1
- package/dist/permutationvector.js +15 -8
- package/dist/permutationvector.js.map +1 -1
- package/dist/productSet.d.ts.map +1 -1
- package/dist/productSet.js +6 -3
- package/dist/productSet.js.map +1 -1
- package/dist/range.d.ts.map +1 -1
- package/dist/range.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js.map +1 -1
- package/dist/sparsearray2d.d.ts.map +1 -1
- package/dist/sparsearray2d.js +12 -12
- package/dist/sparsearray2d.js.map +1 -1
- package/dist/split.d.ts.map +1 -1
- package/dist/split.js +5 -3
- package/dist/split.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/undoprovider.d.ts.map +1 -1
- package/dist/undoprovider.js.map +1 -1
- package/lib/bspSet.d.ts.map +1 -1
- package/lib/bspSet.js.map +1 -1
- package/lib/handlecache.d.ts.map +1 -1
- package/lib/handlecache.js +1 -3
- package/lib/handlecache.js.map +1 -1
- package/lib/handletable.d.ts.map +1 -1
- package/lib/handletable.js +7 -3
- package/lib/handletable.js.map +1 -1
- package/lib/matrix.d.ts +1 -1
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +29 -20
- package/lib/matrix.js.map +1 -1
- package/lib/ops.d.ts.map +1 -1
- package/lib/ops.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/permutationvector.d.ts.map +1 -1
- package/lib/permutationvector.js +15 -8
- package/lib/permutationvector.js.map +1 -1
- package/lib/productSet.d.ts.map +1 -1
- package/lib/productSet.js +6 -3
- package/lib/productSet.js.map +1 -1
- package/lib/range.d.ts.map +1 -1
- package/lib/range.js.map +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/serialization.d.ts.map +1 -1
- package/lib/serialization.js.map +1 -1
- package/lib/sparsearray2d.d.ts.map +1 -1
- package/lib/sparsearray2d.js +12 -12
- package/lib/sparsearray2d.js.map +1 -1
- package/lib/split.d.ts.map +1 -1
- package/lib/split.js +5 -3
- package/lib/split.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/undoprovider.d.ts.map +1 -1
- package/lib/undoprovider.js +1 -1
- package/lib/undoprovider.js.map +1 -1
- package/package.json +117 -116
- package/prettier.config.cjs +1 -1
- package/src/bspSet.ts +507 -434
- package/src/handlecache.ts +114 -112
- package/src/handletable.ts +66 -62
- package/src/matrix.ts +781 -710
- package/src/ops.ts +11 -11
- package/src/packageVersion.ts +1 -1
- package/src/permutationvector.ts +425 -368
- package/src/productSet.ts +852 -788
- package/src/range.ts +8 -8
- package/src/runtime.ts +35 -35
- package/src/serialization.ts +13 -9
- package/src/sparsearray2d.ts +196 -192
- package/src/split.ts +111 -90
- package/src/types.ts +3 -3
- package/src/undoprovider.ts +161 -144
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/dist/bspSet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAiC;AAI1B,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAlE,QAAA,IAAI,QAA8D;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,gBAAQ,CAAC;AAEpD,IAAY,OAGX;AAHD,WAAY,OAAO;IACf,uCAAK,CAAA;IACL,uCAAK,CAAA;AACT,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAsBY,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AA0G5B,MAAM,iBAAiB,GAAG,CAC7B,aAA0E,EAC1E,GAAmB,EACnB,WAAmB,EAAE,EACvB,EAAE,CAAC,CAAC,GAAmB,EAAE,EAAE;IACzB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE;QACzB,OAAO,GAAG,CAAC,KAAK,CAAC;KACpB;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAC1C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,Q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I,SAAS,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAAE;QAEnD,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;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED,SAAgB,UAAU,CACtB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACnC,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAND,gCAMC","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 Dense,\n Empty,\n}\n\ninterface TreeNode<Left, Right> {\n readonly left: Left;\n readonly right: Right;\n}\n\ninterface KeyNode<Key, Exact> {\n readonly key: Key;\n readonly pathKey: Key;\n readonly 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<UntypedSparse<Key> | Left, UntypedSparse<Key> | Right>;\n\ntype TreeDefined<Key> =\n | BalancePropertyHelper<Key, Empty, Dense>\n | BalancePropertyHelper<Key, Dense, Empty>;\ntype TreeUndefined = TreeNode<undefined, undefined>;\n\ntype KeyDefinednessProperty<Key> = KeyDefined<Key> | KeyUndefined;\n\nexport type UntypedSparse<Key> =\n | (KeyDefinednessProperty<Key> & TreeDefined<Key>)\n | (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 setOperations: SetOperations<Key, Id>;\n root: UntypedSparse<Key>;\n}\nexport type BspSet<Key extends Cachable<Key>, Id> =\n | Empty\n | Dense\n | Sparse<Key, Id>;\n\nexport interface KeyCache<T> {\n depth?: number;\n split?: 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>]\n ? any\n : never;\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> &\n 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 /** Id here is just a phantom type, so that we can associate the various set instances together */\n readonly id: Id;\n\n /** Split the key into two. This will only be called when the current key is incomparable with an element.\n * E.g. this would never be called if the key is already a 1x1 rectangle. */\n readonly split: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>;\n\n /** Tells, if a given key can be split further */\n readonly canSplit: (key: CachedKey<Key>) => boolean;\n\n /** Tells if two keys overlap at all. */\n readonly meets: (key1: Key, key2: Key) => boolean;\n\n /** Intersect the keys, if it is possible to exactly respresent their intersection.\n * An implementation is never required to compute the intersection as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet and that they are incomparable.\n */\n readonly intersect: (key1: Key, key2: Key) => Key | undefined;\n\n /** Unions the keys, if it is possible to exactly represent their union.\n * An implementation is never required to compute the union as this is just an optimization.\n * Precondition: It is guaranteed that the keys are incomparable.\n */\n readonly union: (key1: Key, key2: Key) => Key | undefined;\n\n /** Computes the set difference between two keys, if it is possible to exactly represent their set difference.\n * An implementation is never required to compute the difference as this is just an optimization.\n * Precondition: It is guaranteed that the keys meet.\n */\n readonly except: (key1: Key, key2: Key) => Key | undefined;\n\n /** Compare two keys */\n readonly compare: (key1: Key, key2: Key) => -1 | 0 | 1 | undefined;\n\n /** The top element of the set. */\n readonly top: Key;\n}\n\nexport const cacheKeySplitting = <Key>(\n splitFunction: (key: CachedKey<Key>) => Pair<Pair<CachedKey<Key>, number>>,\n top: CachedKey<Key>,\n maxDepth: number = 10,\n) => (key: CachedKey<Key>) => {\n if (key.split !== undefined) {\n return key.split;\n }\n\n const split = splitFunction(key);\n const depth = key === top ? 0 : key.depth;\n if (depth !== undefined && depth < maxDepth) {\n key.split = split;\n split[0][0].depth = depth + 1;\n split[1][0].depth = depth + 1;\n }\n\n return split;\n};\n\nexport function fromUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n root: UntypedBspSet<Key>,\n): BspSet<Key, Id> {\n if (root === empty || root === dense) { return root; }\n return { setOperations, root };\n}\n\nconst sparse = <Key, Exact, Left, Right>(\n left: Left,\n right: Right,\n pathKey: Key,\n key: Key,\n isExact: Exact,\n) => ({ key, pathKey, left, right, isExact });\n\nfunction fromKey<Key>(\n pathKey: Key,\n key: Key,\n isExact: boolean,\n): UntypedSparse<Key> {\n if (isExact) {\n return sparse(undefined, undefined, pathKey, key, true as const);\n }\n\n return sparse(undefined, undefined, pathKey, key, false as const);\n}\n\nexport function lazy<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n pathKey: Key,\n key: Key,\n): UntypedBspSet<Key> {\n if (!setOperations.meets(pathKey, key)) { return empty; }\n const cmp = setOperations.compare(pathKey, key);\n if (cmp !== undefined) {\n if (cmp <= 0) { return dense; }\n\n return fromKey(pathKey, key, true);\n }\n\n // this is not exactly necessary, but increases the amount of exact nodes and thus we can often\n // prune earlier.\n // Also, having intersect always work guarantees exact nodes, thus allowing for more efficient\n // storage and computation.\n const newKey = setOperations.intersect(pathKey, key);\n\n if (newKey !== undefined) {\n return fromKey(pathKey, newKey, true);\n }\n\n return fromKey(pathKey, key, false);\n}\n\nexport function createFromKey<Key extends Cachable<Key>, Id>(\n uncachedSetOperations: SetOperations<Key, Id>,\n) {\n const setOperations = {\n ...uncachedSetOperations,\n split: cacheKeySplitting(\n uncachedSetOperations.split,\n uncachedSetOperations.top,\n ),\n };\n return (key: Key) =>\n fromUntyped(setOperations, lazy(setOperations, setOperations.top, key));\n}\n\nfunction unionExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? right : left;\n }\n\n const combinedKey = setOperations.union(leftKey, rightKey);\n if (combinedKey !== undefined) {\n const combinedCmp = setOperations.compare(combinedKey, pathKey);\n if (combinedCmp !== undefined && combinedCmp === 0) { return dense; }\n return fromKey(pathKey, combinedKey, true);\n }\n return 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 left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): Empty | Dense | (UntypedSparse<Key> & TreeDefined<Key>) {\n if (left === empty) {\n if (right === empty) {\n return empty;\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (right === empty) {\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n if (left === dense) {\n if (right === dense) {\n return dense;\n }\n return sparse(left, right, undefined, undefined, false as const);\n }\n\n return sparse(left, right, undefined, undefined, false as const);\n}\n\nfunction materialize<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedSparse<Key>,\n): UntypedSparse<Key> & TreeDefined<Key> {\n if (set.left !== undefined) {\n return set;\n }\n\n const [[left], [right]] = setOperations.split(set.pathKey);\n const lChild = lazy(setOperations, left, set.key);\n const rChild = lazy(setOperations, right, set.key);\n\n const res = combineChildren<Key>(lChild, rChild);\n\n if (res === empty || res === dense) {\n throw new Error(\"incorrect set operations implementation\");\n }\n\n // first check, that res actually has the desired type\n const typeCheck: TreeDefined<Key> = res;\n\n const setAlias: UntypedSparse<Key> = set;\n return ObjectAssign(setAlias, {\n left: typeCheck.left,\n right: typeCheck.right,\n });\n}\n\nexport function unionUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = unionExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = unionUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = unionUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function union<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (right === empty) { return left; }\n if (right === dense) { return right; }\n if (left === empty) { return right; }\n if (left === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n unionUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nfunction intersectExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key> & KeyExact<Key>,\n right: UntypedBspSet<Key> & KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return empty;\n }\n\n const cmp = setOperations.compare(leftKey, rightKey);\n if (cmp !== undefined) {\n return cmp < 0 ? left : right;\n }\n\n const combinedKey = setOperations.intersect(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function intersectUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n if (left.isExact && right.isExact) {\n const res = intersectExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = intersectUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = intersectUntyped(\n setOperations,\n newLeft.right,\n newRight.right,\n );\n\n return combineChildren(lChild, rChild);\n}\n\nexport function intersect<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return right; }\n if (left === dense) { return right; }\n if (right === dense) { return left; }\n\n return fromUntyped(\n left.setOperations,\n intersectUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nexport function meetsUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n if (left.isExact && right.isExact) { return setOperations.meets(left.key, right.key); }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n return (\n meetsUntyped(setOperations, newLeft.left, newRight.left) ||\n meetsUntyped(setOperations, newLeft.right, newRight.right)\n );\n}\n\nexport function meets<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): boolean {\n if (left === empty || right === empty) { return false; }\n if (left === dense || right === dense) { return true; }\n return meetsUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nfunction exceptExact<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedSparse<Key> & KeyExact<Key>,\n right: KeyExact<Key>,\n) {\n const { pathKey, key: leftKey } = left;\n const { key: rightKey } = right;\n\n if (!setOperations.meets(leftKey, rightKey)) {\n return left;\n }\n\n const combinedKey = setOperations.except(leftKey, rightKey);\n if (combinedKey !== undefined) {\n return fromKey(pathKey, combinedKey, true);\n }\n\n return undefined;\n}\n\nexport function exceptUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): UntypedBspSet<Key> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n const newRight_inner = materialize<Key, Id>(setOperations, right);\n const lChild_inner = exceptUntyped(setOperations, dense, newRight_inner.left);\n const rChild_inner = exceptUntyped(setOperations, dense, newRight_inner.right);\n return combineChildren(lChild_inner, rChild_inner);\n }\n if (left.isExact && right.isExact) {\n const res = exceptExact<Key, Id>(setOperations, left, right);\n if (res !== undefined) { return res; }\n }\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n\n const lChild = exceptUntyped(setOperations, newLeft.left, newRight.left);\n const rChild = exceptUntyped(setOperations, newLeft.right, newRight.right);\n\n return combineChildren(lChild, rChild);\n}\n\nexport function except<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n): BspSet<Key, Id> {\n if (left === empty) { return left; }\n if (right === empty) { return left; }\n if (right === dense) { return empty; }\n if (left === dense) {\n return fromUntyped(\n right.setOperations,\n exceptUntyped<Key, Id>(right.setOperations, left, right.root),\n );\n }\n\n return fromUntyped(\n left.setOperations,\n exceptUntyped<Key, Id>(left.setOperations, left.root, right.root),\n );\n}\n\nconst compareExact = <Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: KeyExact<Key>,\n right: KeyExact<Key>,\n) => setOperations.compare(left.key, right.key);\n\nexport function combineCmp(\n left: -1 | 0 | 1 | undefined,\n right: -1 | 0 | 1 | undefined,\n) {\n if (left === undefined || right === undefined) { return undefined; }\n if (left === 0) { return right; }\n if (right === 0) { return left; }\n return left === right ? left : undefined;\n}\n\nexport function compareUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n left: UntypedBspSet<Key>,\n right: UntypedBspSet<Key>,\n): -1 | 0 | 1 | undefined {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n if (left.isExact && right.isExact) {\n return compareExact(setOperations, left, right);\n }\n\n const newLeft = materialize<Key, Id>(setOperations, left);\n const newRight = materialize<Key, Id>(setOperations, right);\n const lCmp = compareUntyped(setOperations, newLeft.left, newRight.left);\n if (lCmp === undefined) { return undefined; }\n\n const rCmp = compareUntyped(setOperations, newLeft.right, newRight.right);\n\n if (rCmp === undefined) { return undefined; }\n\n return combineCmp(lCmp, rCmp);\n}\n\nexport function compare<Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) {\n if (left === right) { return 0; }\n\n if (left === empty) {\n return -1;\n }\n\n if (right === empty) {\n return 1;\n }\n\n if (left === dense) {\n if (right === dense) {\n return 0;\n }\n\n return 1;\n }\n\n if (right === dense) {\n return -1;\n }\n\n return compareUntyped<Key, Id>(left.setOperations, left.root, right.root);\n}\n\nexport const symmetricDiff = <Key extends Cachable<Key>, Id>(\n left: BspSet<Key, Id>,\n right: BspSet<Key, Id>,\n) => union(except(left, right), except(right, left));\n\nexport const complement = <Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) => except(dense, set);\n\nfunction getNodeCountUntyped<T>(set: UntypedBspSet<T> | undefined): number {\n if (set === undefined || set === empty || set === dense) {\n return 0;\n }\n\n return getNodeCountUntyped(set.left) + getNodeCountUntyped(set.right) + 1;\n}\n\nexport function getNodeCount<Key extends Cachable<Key>, Id>(\n set: BspSet<Key, Id>,\n) {\n if (set === empty || set === dense) { return 0; }\n return getNodeCountUntyped(set.root);\n}\n\nfunction forEachKeyUntyped<Key extends Cachable<Key>, Id>(\n setOperations: SetOperations<Key, Id>,\n set: UntypedBspSet<Key>,\n f: (key: Key) => boolean,\n): boolean {\n function loop(pathKey: Key, set_inner: UntypedBspSet<Key>): boolean {\n if (set_inner === empty) { return true; }\n if (set_inner === dense) { return f(pathKey); }\n if (set_inner.isExact) { return f(set_inner.key); }\n\n const newSet = materialize<Key, Id>(setOperations, set_inner);\n const [[left], [right]] = setOperations.split(pathKey);\n return loop(left, newSet.left) && loop(right, newSet.right);\n }\n\n return loop(setOperations.top, set);\n}\n\nexport function forEachKey<Key extends Cachable<Key>, Id>(\n set: Empty | Sparse<Key, Id>,\n f: (key: Key) => boolean,\n): boolean {\n if (set === empty) { return true; }\n return forEachKeyUntyped(set.setOperations, set.root, f);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"bspSet.js","sourceRoot":"","sources":["../src/bspSet.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,iCAAiC;AAI1B,MAAM,IAAI,GAAG,CAAW,IAAO,EAAE,KAAQ,EAAc,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAAlE,QAAA,IAAI,QAA8D;AAE/E,uEAAuE;AACvE,MAAM,YAAY,GAAyB,gBAAQ,CAAC;AAEpD,IAAY,OAGX;AAHD,WAAY,OAAO;IAClB,uCAAK,CAAA;IACL,uCAAK,CAAA;AACN,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAsBY,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AACtB,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;AAuG5B,MAAM,iBAAiB,GAC7B,CACC,aAA0E,EAC1E,GAAmB,EACnB,WAAmB,EA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C;AAED,SAAS,iBAAiB,CACzB,aAAqC,EACrC,GAAuB,EACvB,CAAwB;IAExB,SAAS,IAAI,CAAC,OAAY,EAAE,SAA6B;QACxD,IAAI,SAAS,KAAK,aAAK,EAAE;YACxB,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,SAAS,KAAK,aAAK,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,SAAgB,UAAU,CACzB,GAA4B,EAC5B,CAAwB;IAExB,IAAI,GAAG,KAAK,aAAK,EAAE;QAClB,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1D,CAAC;AARD,gCAQC","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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAG5E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"handlecache.d.ts","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAG5E;;;;;GAKG;AACH,qBAAa,WAAY,YAAW,eAAe,CAAC,MAAM,CAAC;aAI9B,MAAM,EAAE,iBAAiB;IAHrD,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,KAAK,CAAK;gBAEU,MAAM,EAAE,iBAAiB;IAErD;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;OAOG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM;IAajC,8EAA8E;IACvE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAajD,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,SAAS;IA4BjB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAoB9E"}
|
package/dist/handlecache.js
CHANGED
|
@@ -43,9 +43,7 @@ class HandleCache {
|
|
|
43
43
|
// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer
|
|
44
44
|
// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an
|
|
45
45
|
// ~40% speedup when the position is in the cache (node v12 x64).
|
|
46
|
-
return index < this.handles.length
|
|
47
|
-
? this.handles[index]
|
|
48
|
-
: this.cacheMiss(position);
|
|
46
|
+
return index < this.handles.length ? this.handles[index] : this.cacheMiss(position);
|
|
49
47
|
}
|
|
50
48
|
/** Update the cache when a handle has been allocated for a given position. */
|
|
51
49
|
addHandle(position, handle) {
|
package/dist/handlecache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAsD;AAEtD,+CAAsD;AAEtD,mCAAsC;AAEtC;;;;;GAKG;AACH,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"handlecache.js","sourceRoot":"","sources":["../src/handlecache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAA+B;AAE/B,+DAAsD;AAEtD,+CAAsD;AAEtD,mCAAsC;AAEtC;;;;;GAKG;AACH,MAAa,WAAW;IAIvB,YAA4B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAH7C,YAAO,GAAa,EAAE,CAAC;QACvB,UAAK,GAAG,CAAC,CAAC;IAEsC,CAAC;IAEzD;;;OAGG;IACK,QAAQ,CAAC,QAAgB;QAChC,O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FAA6F;QAC7F,2EAA2E;QAC3E,EAAE;QACF,gFAAgF;QAEhF,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;SAC5B;IACF,CAAC;CAGD;AAnHD,kCAmHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable no-bitwise */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IVectorConsumer } from \"@tiny-calc/nano\";\nimport { Handle, isHandleValid } from \"./handletable\";\nimport { PermutationVector, PermutationSegment } from \"./permutationvector\";\nimport { ensureRange } from \"./range\";\n\n/**\n * Used by PermutationVector to cache position -\\> handle lookups.\n *\n * Perf: Possibly, this should eventually be inlined into PermutationVector itself, but\n * so far there's no measurable perf penalty for being a separate object (node 12 x64)\n */\nexport class HandleCache implements IVectorConsumer<Handle> {\n\tprivate handles: Handle[] = [];\n\tprivate start = 0;\n\n\tconstructor(public readonly vector: PermutationVector) {}\n\n\t/**\n\t * Returns the index of the given position in the 'handles' array as a Uint32.\n\t * (If the position is not in the array, returns an integer greater than 'handles.length').\n\t */\n\tprivate getIndex(position: number) {\n\t\treturn (position - this.start) >>> 0;\n\t}\n\n\t/**\n\t * Returns the handle currently assigned to the given 'position' (if any). Check\n\t * the result with 'isValidHandle(..)' to see if a handle has been allocated for\n\t * the given position.\n\t *\n\t * Throws a 'RangeError' if the provided 'position' is out-of-bounds wrt. the\n\t * PermutationVector's length.\n\t */\n\tpublic getHandle(position: number) {\n\t\tconst index = this.getIndex(position);\n\n\t\t// Perf: To encourage inlining, handling of the 'cacheMiss(..)' case has been extracted\n\t\t// to a separate method.\n\n\t\t// Perf: A cache hit implies that 'position' was in bounds. Therefore, we can defer\n\t\t// checking that 'position' is in bounds until 'cacheMiss(..)'. This yields an\n\t\t// ~40% speedup when the position is in the cache (node v12 x64).\n\n\t\treturn index < this.handles.length ? this.handles[index] : this.cacheMiss(position);\n\t}\n\n\t/** Update the cache when a handle has been allocated for a given position. */\n\tpublic addHandle(position: number, handle: Handle) {\n\t\tassert(isHandleValid(handle), 0x017 /* \"Trying to add invalid handle!\" */);\n\n\t\tconst index = this.getIndex(position);\n\t\tif (index < this.handles.length) {\n\t\t\tassert(\n\t\t\t\t!isHandleValid(this.handles[index]),\n\t\t\t\t0x018 /* \"Trying to insert handle into position with already valid handle!\" */,\n\t\t\t);\n\t\t\tthis.handles[index] = handle;\n\t\t}\n\t}\n\n\t/** Used by 'CacheMiss()' to retrieve handles for a range of positions. */\n\tprivate getHandles(start: number, end: number) {\n\t\t// TODO: This can be accelerated substantially using 'walkSegments()'. The only catch\n\t\t// is that\n\n\t\tconst handles: Handle[] = [];\n\t\tconst { vector } = this;\n\n\t\tfor (let pos = start; pos < end; pos++) {\n\t\t\tconst { segment, offset } = vector.getContainingSegment(pos);\n\t\t\tconst asPerm = segment as PermutationSegment;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\thandles.push(asPerm.start + offset!);\n\t\t}\n\n\t\treturn handles;\n\t}\n\n\tprivate cacheMiss(position: number) {\n\t\t// Coercing 'position' to an Uint32 allows us to handle a negative 'position' value\n\t\t// with the same logic that handles 'position' >= length.\n\t\tconst _position = position >>> 0;\n\n\t\t// TODO: To bound memory usage, there should be a limit on the maximum size of\n\t\t// handle[].\n\n\t\t// TODO: To reduce MergeTree lookups, this code should opportunistically grow\n\t\t// the cache to the next MergeTree segment boundary (within the limits of\n\t\t// the handle cache).\n\n\t\tif (_position < this.start) {\n\t\t\tthis.handles = this.getHandles(_position, this.start).concat(this.handles);\n\t\t\tthis.start = _position;\n\t\t\treturn this.handles[0];\n\t\t} else {\n\t\t\tensureRange(_position, this.vector.getLength());\n\n\t\t\tthis.handles = this.handles.concat(\n\t\t\t\tthis.getHandles(this.start + this.handles.length, _position + 1),\n\t\t\t);\n\t\t\treturn this.handles[this.handles.length - 1];\n\t\t}\n\t}\n\n\t// #region IVectorConsumer\n\n\titemsChanged(start: number, removedCount: number, insertedCount: number): void {\n\t\t// If positions were inserted/removed, our current policy is to trim the array\n\t\t// at the beginning of the invalidate range and lazily repopulate the handles\n\t\t// on demand.\n\t\t//\n\t\t// Some alternatives to consider that preserve the previously cached handles\n\t\t// that are still valid:\n\t\t//\n\t\t// * Eagerly populate the 'handles[]' with the newly insert values (currently guaranteed\n\t\t// to be Handle.unallocated, so we don't even need to look them up.)\n\t\t//\n\t\t// * Use a sentinel value or other mechanism to allow \"holes\" in the cache.\n\n\t\tconst index = this.getIndex(start);\n\t\tif (index < this.handles.length) {\n\t\t\tthis.handles.length = index;\n\t\t}\n\t}\n\n\t// #endregion IVectorConsumer\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;
|
|
1
|
+
{"version":3,"file":"handletable.d.ts","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0BAAkB,MAAM;IACvB,4BAA4B;IAC5B,KAAK,IAAI;IAET,mDAAmD;IACnD,WAAW,cAAc;CACzB;AAED,eAAO,MAAM,aAAa,WAAY,MAAM,YAA2B,CAAC;AAExE;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC;IAIN,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAQ;IAE1D,KAAK;IAOZ;;OAEG;IACI,QAAQ,IAAI,MAAM;IAOzB;;OAEG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM;IAQjC;;OAEG;IACI,IAAI,CAAC,MAAM,EAAE,MAAM;IAK1B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC;IAI7B;;OAEG;IACI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAMnC,OAAO,KAAK,IAAI,GAEf;IACD,OAAO,KAAK,IAAI,QAEf;IAEM,iBAAiB;WAIV,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;CAG1C"}
|
package/dist/handletable.js
CHANGED
|
@@ -29,7 +29,7 @@ class HandleTable {
|
|
|
29
29
|
allocate() {
|
|
30
30
|
var _a;
|
|
31
31
|
const free = this.next;
|
|
32
|
-
this.next = (_a = this.handles[free]) !== null && _a !== void 0 ? _a :
|
|
32
|
+
this.next = (_a = this.handles[free]) !== null && _a !== void 0 ? _a : free + 1;
|
|
33
33
|
this.handles[free] = 0;
|
|
34
34
|
return free;
|
|
35
35
|
}
|
|
@@ -64,8 +64,12 @@ class HandleTable {
|
|
|
64
64
|
}
|
|
65
65
|
// Private helpers to get/set the head of the free list, which is stored in the 0th slot
|
|
66
66
|
// of the handle array.
|
|
67
|
-
get next() {
|
|
68
|
-
|
|
67
|
+
get next() {
|
|
68
|
+
return this.handles[0];
|
|
69
|
+
}
|
|
70
|
+
set next(handle) {
|
|
71
|
+
this.handles[0] = handle;
|
|
72
|
+
}
|
|
69
73
|
getSummaryContent() {
|
|
70
74
|
return this.handles;
|
|
71
75
|
}
|
package/dist/handletable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUI,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,iBAAgB,CAAC;AAA3D,QAAA,aAAa,iBAA8C;AAExE;;GAEG;AACH,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"handletable.js","sourceRoot":"","sources":["../src/handletable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;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AAM,CAAM,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,GAAG,CAAC,MAAc,EAAE,KAAQ;QAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,wFAAwF;IACxF,uBAAuB;IACvB,IAAY,IAAI;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAW,CAAC;IAClC,CAAC;IACD,IAAY,IAAI,CAAC,MAAc;QAC9B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IAC1B,CAAC;IAEM,iBAAiB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,IAAI,CAAI,IAAoB;QACzC,OAAO,IAAI,WAAW,CAAI,IAAI,CAAC,CAAC;IACjC,CAAC;CACD;AAxED,kCAwEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport const enum Handle {\n\t/** Minimum valid handle. */\n\tvalid = 1,\n\n\t/** Sentinel representing an unallocated Handle. */\n\tunallocated = -0x80000000,\n}\n\nexport const isHandleValid = (handle: Handle) => handle >= Handle.valid;\n\n/**\n * A handle table provides a fast mapping from an integer `handle` to a value `T`.\n */\nexport class HandleTable<T> {\n\t// Note: the first slot of the 'handles' array is reserved to store the pointer to the first\n\t// free handle. We initialize this slot with a pointer to slot '1', which will cause\n\t// us to delay allocate the following slot in the array on the first allocation.\n\tpublic constructor(private readonly handles: (Handle | T)[] = [1]) {}\n\n\tpublic clear() {\n\t\t// Restore the HandleTable's initial state by deleting all items in the handles array\n\t\t// and then re-inserting the value '1' in the 0th slot. (See comment at `handles` decl\n\t\t// for explanation.)\n\t\tthis.handles.splice(0, this.handles.length, 1);\n\t}\n\n\t/**\n\t * Allocates and returns the next available handle. Note that freed handles are recycled.\n\t */\n\tpublic allocate(): Handle {\n\t\tconst free = this.next;\n\t\tthis.next = (this.handles[free] as Handle) ?? free + 1;\n\t\tthis.handles[free] = 0;\n\t\treturn free;\n\t}\n\n\t/**\n\t * Allocates and returns the next available `count` handles.\n\t */\n\tpublic allocateMany(count: Handle) {\n\t\tconst handles = new Uint32Array(count);\n\t\tfor (let i = 0; i < count; i++) {\n\t\t\thandles[i] = this.allocate();\n\t\t}\n\t\treturn handles;\n\t}\n\n\t/**\n\t * Returns the given handle to the free list.\n\t */\n\tpublic free(handle: Handle) {\n\t\tthis.handles[handle] = this.next;\n\t\tthis.next = handle;\n\t}\n\n\t/**\n\t * Get the value `T` associated with the given handle, if any.\n\t */\n\tpublic get(handle: Handle): T {\n\t\treturn this.handles[handle] as T;\n\t}\n\n\t/**\n\t * Set the value `T` associated with the given handle.\n\t */\n\tpublic set(handle: Handle, value: T) {\n\t\tthis.handles[handle] = value;\n\t}\n\n\t// Private helpers to get/set the head of the free list, which is stored in the 0th slot\n\t// of the handle array.\n\tprivate get next() {\n\t\treturn this.handles[0] as Handle;\n\t}\n\tprivate set next(handle: Handle) {\n\t\tthis.handles[0] = handle;\n\t}\n\n\tpublic getSummaryContent() {\n\t\treturn this.handles;\n\t}\n\n\tpublic static load<T>(data: (Handle | T)[]) {\n\t\treturn new HandleTable<T>(data);\n\t}\n}\n"]}
|
package/dist/matrix.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export declare class SharedMatrix<T = any> extends SharedObject implements IMatr
|
|
|
54
54
|
getCell(row: number, col: number): MatrixItem<T>;
|
|
55
55
|
get matrixProducer(): IMatrixProducer<MatrixItem<T>>;
|
|
56
56
|
setCell(row: number, col: number, value: MatrixItem<T>): void;
|
|
57
|
-
setCells(rowStart: number, colStart: number, colCount: number, values: readonly
|
|
57
|
+
setCells(rowStart: number, colStart: number, colCount: number, values: readonly MatrixItem<T>[]): void;
|
|
58
58
|
private setCellCore;
|
|
59
59
|
private sendSetCellOp;
|
|
60
60
|
private submitVectorMessage;
|
package/dist/matrix.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,gBAAgB,EAGhB,YAAY,EACZ,iBAAiB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EAIN,QAAQ,EAER,MAAM,4BAA4B,CAAC;AAIpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAwBxC;;;GAGG;AACH,oBAAY,UAAU,CAAC,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,GAAG,CAChC,SAAQ,YACR,YACC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC9B,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAC5B,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAgBrB,EAAE,EAAE,MAAM;IAdlB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;WAEzD,UAAU;IAIxB,OAAO,CAAC,QAA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AEG;IACH,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;CAiD/C"}
|
package/dist/matrix.js
CHANGED
|
@@ -63,7 +63,9 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
63
63
|
this.rows = new permutationvector_1.PermutationVector("rows" /* rows */, this.logger, runtime, this.onRowDelta, this.onRowHandlesRecycled);
|
|
64
64
|
this.cols = new permutationvector_1.PermutationVector("cols" /* cols */, this.logger, runtime, this.onColDelta, this.onColHandlesRecycled);
|
|
65
65
|
}
|
|
66
|
-
static getFactory() {
|
|
66
|
+
static getFactory() {
|
|
67
|
+
return new runtime_1.SharedMatrixFactory();
|
|
68
|
+
}
|
|
67
69
|
/**
|
|
68
70
|
* Subscribes the given IUndoConsumer to the matrix.
|
|
69
71
|
*/
|
|
@@ -72,8 +74,12 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
72
74
|
this.undo = new undoprovider_1.MatrixUndoProvider(consumer, this, this.rows, this.cols);
|
|
73
75
|
}
|
|
74
76
|
// TODO: closeUndo()?
|
|
75
|
-
get rowHandles() {
|
|
76
|
-
|
|
77
|
+
get rowHandles() {
|
|
78
|
+
return this.rows.handleCache;
|
|
79
|
+
}
|
|
80
|
+
get colHandles() {
|
|
81
|
+
return this.cols.handleCache;
|
|
82
|
+
}
|
|
77
83
|
/**
|
|
78
84
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
79
85
|
*/
|
|
@@ -90,8 +96,12 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
90
96
|
}
|
|
91
97
|
// #endregion IMatrixProducer
|
|
92
98
|
// #region IMatrixReader
|
|
93
|
-
get rowCount() {
|
|
94
|
-
|
|
99
|
+
get rowCount() {
|
|
100
|
+
return this.rows.getLength();
|
|
101
|
+
}
|
|
102
|
+
get colCount() {
|
|
103
|
+
return this.cols.getLength();
|
|
104
|
+
}
|
|
95
105
|
getCell(row, col) {
|
|
96
106
|
// Perf: When possible, bounds checking is performed inside the implementation for
|
|
97
107
|
// 'getHandle()' so that it can be elided in the case of a cache hit. This
|
|
@@ -111,11 +121,12 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
111
121
|
}
|
|
112
122
|
return undefined;
|
|
113
123
|
}
|
|
114
|
-
get matrixProducer() {
|
|
124
|
+
get matrixProducer() {
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
115
127
|
// #endregion IMatrixReader
|
|
116
128
|
setCell(row, col, value) {
|
|
117
|
-
(0, common_utils_1.assert)(0 <= row && row < this.rowCount
|
|
118
|
-
&& 0 <= col && col < this.colCount, 0x01a /* "Trying to set out-of-bounds cell!" */);
|
|
129
|
+
(0, common_utils_1.assert)(0 <= row && row < this.rowCount && 0 <= col && col < this.colCount, 0x01a /* "Trying to set out-of-bounds cell!" */);
|
|
119
130
|
this.setCellCore(row, col, value);
|
|
120
131
|
// Avoid reentrancy by raising change notifications after the op is queued.
|
|
121
132
|
for (const consumer of this.consumers.values()) {
|
|
@@ -124,10 +135,13 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
124
135
|
}
|
|
125
136
|
setCells(rowStart, colStart, colCount, values) {
|
|
126
137
|
const rowCount = Math.ceil(values.length / colCount);
|
|
127
|
-
(0, common_utils_1.assert)(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
(0, common_utils_1.assert)(0 <= rowStart &&
|
|
139
|
+
rowStart < this.rowCount &&
|
|
140
|
+
0 <= colStart &&
|
|
141
|
+
colStart < this.colCount &&
|
|
142
|
+
1 <= colCount &&
|
|
143
|
+
colCount <= this.colCount - colStart &&
|
|
144
|
+
rowCount <= this.rowCount - rowStart, 0x01b /* "Trying to set multiple out-of-bounds cells!" */);
|
|
131
145
|
const endCol = colStart + colCount;
|
|
132
146
|
let r = rowStart;
|
|
133
147
|
let c = colStart;
|
|
@@ -189,9 +203,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
189
203
|
if (this.isAttached()) {
|
|
190
204
|
// Record whether this `op` targets rows or cols. (See dispatch in `processCore()`)
|
|
191
205
|
message.target = dimension;
|
|
192
|
-
this.submitLocalMessage(message, currentVector.peekPendingSegmentGroups(message.type === merge_tree_1.MergeTreeDeltaType.GROUP
|
|
193
|
-
? message.ops.length
|
|
194
|
-
: 1));
|
|
206
|
+
this.submitLocalMessage(message, currentVector.peekPendingSegmentGroups(message.type === merge_tree_1.MergeTreeDeltaType.GROUP ? message.ops.length : 1));
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
submitColMessage(message) {
|
|
@@ -278,10 +290,7 @@ class SharedMatrix extends shared_object_base_1.SharedObject {
|
|
|
278
290
|
const builder = new runtime_utils_1.SummaryTreeBuilder();
|
|
279
291
|
builder.addWithStats("rows" /* rows */, this.rows.summarize(this.runtime, this.handle, serializer));
|
|
280
292
|
builder.addWithStats("cols" /* cols */, this.cols.summarize(this.runtime, this.handle, serializer));
|
|
281
|
-
builder.addBlob("cells" /* cells */, serializer.stringify([
|
|
282
|
-
this.cells.snapshot(),
|
|
283
|
-
this.pending.snapshot(),
|
|
284
|
-
], this.handle));
|
|
293
|
+
builder.addBlob("cells" /* cells */, serializer.stringify([this.cells.snapshot(), this.pending.snapshot()], this.handle));
|
|
285
294
|
return builder.getSummaryTree();
|
|
286
295
|
}
|
|
287
296
|
/**
|