@fluidframework/merge-tree 2.0.0-internal.5.0.0 → 2.0.0-internal.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fluidframework/merge-tree
2
2
 
3
+ ## 2.0.0-internal.5.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - New APIs for interval querying by range ([#15837](https://github.com/microsoft/FluidFramework/issues/15837)) [2a4242e1b5](https://github.com/microsoft/FluidFramework/commits/2a4242e1b5f15442b13ae413124ec76315a4cc52)
8
+
9
+ SharedString now supports querying intervals whose start/end-points fall in a specified range.
10
+
3
11
  ## 2.0.0-internal.5.0.0
4
12
 
5
13
  Dependency updates only.
@@ -390,7 +390,7 @@ class RedBlackTree {
390
390
  return node;
391
391
  }
392
392
  mapRange(action, accum, start, end) {
393
- this.nodeMap(this.root, action, start, end);
393
+ this.nodeMap(this.root, action, accum, start, end);
394
394
  }
395
395
  map(action, accum) {
396
396
  // TODO: optimize to avoid comparisons
@@ -1 +1 @@
1
- {"version":3,"file":"rbTree.js","sourceRoot":"","sources":["../../src/collections/rbTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,4CAA4C;AAE5C;;GAEG;AACU,QAAA,OAAO,GAAG;IACtB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACC,CAAC;AA4GX;;GAEG;AACH,MAAa,YAAY;IAGxB,YACkB,WAA8B,EAC9B,GAAkC;QADlC,gBAAW,GAAX,WAAW,CAAmB;QAC9B,QAAG,GAAH,GAAG,CAA+B;IACjD,CAAC;IAEI,QAAQ,CAAC,GAAS,EAAE,IAAW,EAAE,KAAc,EAAE,IAAY;QACpE,OAA4B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,IAAqC;QAClD,OAAO,CAAC,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AC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC3D;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AA7lBD,oCA6lBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\n\n/* Remove once strictNullCheck is enabled */\n\n/**\n * @internal\n */\nexport const RBColor = {\n\tRED: 0,\n\tBLACK: 1,\n} as const;\n\n/**\n * @internal\n */\nexport type RBColor = typeof RBColor[keyof typeof RBColor];\n\n/**\n * @internal\n */\nexport interface RBNode<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n\tleft: RBNode<TKey, TData> | undefined;\n\tright: RBNode<TKey, TData> | undefined;\n\tcolor: RBColor;\n\tsize: number;\n}\n/**\n * @internal\n */\nexport interface IRBAugmentation<TKey, TData> {\n\tupdate(node: RBNode<TKey, TData>): void;\n}\n/**\n * @internal\n */\nexport interface IRBMatcher<TKey, TData> {\n\tcontinueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n\tmatchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n}\n\n/**\n * @internal\n */\nexport interface RBNodeActions<TKey, TData> {\n\tinfix?(node: RBNode<TKey, TData>): boolean;\n\tpre?(node: RBNode<TKey, TData>): boolean;\n\tpost?(node: RBNode<TKey, TData>): boolean;\n\tshowStructure?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface KeyComparer<TKey> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(a: TKey, b: TKey): number;\n}\n\n/**\n * @internal\n */\nexport interface Property<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n}\n\n/**\n * @internal\n */\nexport interface PropertyAction<TKey, TData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t<TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;\n}\n\n/**\n * @internal\n */\nexport interface QProperty<TKey, TData> {\n\tkey?: TKey;\n\tdata?: TData;\n}\n\n/**\n * @internal\n */\nexport type ConflictAction<TKey, TData> = (\n\tkey: TKey,\n\tcurrentKey: TKey,\n\tdata: TData,\n\tcurrentData: TData,\n) => QProperty<TKey, TData>;\n\n/**\n * @internal\n */\nexport interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {\n\tmax(): Property<TKey, TData> | undefined;\n\tmin(): Property<TKey, TData> | undefined;\n\tmapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface Dictionary<TKey, TData> {\n\tget(key: TKey): Property<TKey, TData> | undefined;\n\tput(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;\n\tremove(key: TKey): void;\n\tmap<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;\n}\n\n/**\n * @internal\n */\nexport class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {\n\tprivate root: RBNode<TKey, TData> | undefined;\n\n\tconstructor(\n\t\tprivate readonly compareKeys: KeyComparer<TKey>,\n\t\tprivate readonly aug?: IRBAugmentation<TKey, TData>,\n\t) {}\n\n\tprivate makeNode(key: TKey, data: TData, color: RBColor, size: number) {\n\t\treturn <RBNode<TKey, TData>>{ key, data, color, size };\n\t}\n\n\tprivate isRed(node: RBNode<TKey, TData> | undefined) {\n\t\treturn !!node && node.color === RBColor.RED;\n\t}\n\n\tprivate nodeSize(node: RBNode<TKey, TData> | undefined) {\n\t\treturn node ? node.size : 0;\n\t}\n\tpublic size() {\n\t\treturn this.nodeSize(this.root);\n\t}\n\tpublic isEmpty() {\n\t\treturn !this.root;\n\t}\n\tpublic get(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\treturn this.nodeGet(this.root, key);\n\t\t}\n\t}\n\tprivate nodeGet(node: RBNode<TKey, TData> | undefined, key: TKey) {\n\t\tlet _node = node;\n\t\twhile (_node) {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node = _node.left;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node = _node.right;\n\t\t\t} else {\n\t\t\t\treturn _node;\n\t\t\t}\n\t\t}\n\t}\n\tprivate contains(key: TKey) {\n\t\treturn this.get(key);\n\t}\n\n\tpublic gather(key: TKey, matcher: IRBMatcher<TKey, TData>) {\n\t\tconst results = [] as RBNode<TKey, TData>[];\n\t\tif (key !== undefined) {\n\t\t\tthis.nodeGather(this.root, results, key, matcher);\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate nodeGather(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tresults: RBNode<TKey, TData>[],\n\t\tkey: TKey,\n\t\tmatcher: IRBMatcher<TKey, TData>,\n\t) {\n\t\tif (node) {\n\t\t\tif (matcher.continueSubtree(node.left, key)) {\n\t\t\t\tthis.nodeGather(node.left, results, key, matcher);\n\t\t\t}\n\t\t\tif (matcher.matchNode(node, key)) {\n\t\t\t\tresults.push(node);\n\t\t\t}\n\t\t\tif (matcher.continueSubtree(node.right, key)) {\n\t\t\t\tthis.nodeGather(node.right, results, key, matcher);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic walkExactMatchesForward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesForward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesForward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic walkExactMatchesBackward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (cmp: number) => boolean,\n\t\tcontinueRightFn: (cmp: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>) {\n\t\tif (key !== undefined) {\n\t\t\tif (data === undefined) {\n\t\t\t\tthis.remove(key);\n\t\t\t} else {\n\t\t\t\tthis.root = this.nodePut(this.root, key, data, conflict);\n\t\t\t\tthis.root.color = RBColor.BLACK;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nodePut(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t\tdata: TData,\n\t\tconflict?: ConflictAction<TKey, TData>,\n\t) {\n\t\tlet _node = node;\n\t\tif (!_node) {\n\t\t\treturn this.makeNode(key, data, RBColor.RED, 1);\n\t\t} else {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node.left = this.nodePut(_node.left, key, data, conflict);\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node.right = this.nodePut(_node.right, key, data, conflict);\n\t\t\t} else {\n\t\t\t\tif (conflict) {\n\t\t\t\t\tconst kd = conflict(key, _node.key, data, _node.data);\n\t\t\t\t\tif (kd.key) {\n\t\t\t\t\t\t_node.key = kd.key;\n\t\t\t\t\t}\n\t\t\t\t\t_node.data = kd.data ? kd.data : data;\n\t\t\t\t} else {\n\t\t\t\t\t_node.data = data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isRed(_node.right) && !this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.right)) {\n\t\t\t\tthis.flipColors(_node);\n\t\t\t}\n\t\t\t_node.size = this.nodeSize(_node.left) + this.nodeSize(_node.right) + 1;\n\t\t\tif (this.aug) {\n\t\t\t\tthis.updateLocal(_node);\n\t\t\t}\n\t\t\treturn _node;\n\t\t}\n\t}\n\n\tprivate updateLocal(node: RBNode<TKey, TData>) {\n\t\tif (this.aug) {\n\t\t\tif (this.isRed(node.left)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.left!);\n\t\t\t}\n\t\t\tif (this.isRed(node.right)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.right!);\n\t\t\t}\n\t\t\tthis.aug.update(node);\n\t\t}\n\t}\n\n\tprivate nodeRemoveMin(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tif (_node.left) {\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemoveMin(_node.left!);\n\t\t\treturn this.balance(_node);\n\t\t}\n\t}\n\n\tpublic remove(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\tif (!this.contains(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.removeExisting(key);\n\t\t}\n\t\t// TODO: error on undefined key\n\t}\n\n\tpublic removeExisting(key: TKey) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (!this.isRed(this.root!.left) && !this.isRed(this.root!.right)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.root!.color = RBColor.RED;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.root = this.nodeRemove(this.root!, key);\n\t}\n\n\tprivate nodeRemove(node: RBNode<TKey, TData>, key: TKey) {\n\t\tlet _node = node;\n\t\tif (this.compareKeys(key, _node.key) < 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemove(_node.left!, key);\n\t\t} else {\n\t\t\tif (this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0 && !_node.right) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.right) && !this.isRed(_node.right!.left)) {\n\t\t\t\t_node = this.moveRedRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst subtreeMin = this.nodeMin(_node.right!);\n\t\t\t\t_node.key = subtreeMin.key;\n\t\t\t\t_node.data = subtreeMin.data;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemoveMin(_node.right!);\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemove(_node.right!, key);\n\t\t\t}\n\t\t}\n\t\treturn this.balance(_node);\n\t}\n\n\t/**\n\t * @returns The largest node in this tree which compares less than or equal to `key`\n\t */\n\tpublic floor(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeFloor(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeFloor(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp < 0) {\n\t\t\t\treturn this.nodeFloor(node.left, key);\n\t\t\t} else {\n\t\t\t\tconst rightFloor = this.nodeFloor(node.right, key);\n\t\t\t\treturn rightFloor ? rightFloor : node;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns The smallest node in this tree which compares greater than or equal to `key`\n\t */\n\tpublic ceil(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeCeil(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeCeil(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\treturn this.nodeCeil(node.right, key);\n\t\t\t} else {\n\t\t\t\tconst leftCeil = this.nodeCeil(node.left, key);\n\t\t\t\treturn leftCeil ? leftCeil : node;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic min() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMin(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.left ? node : this.nodeMin(node.left);\n\t}\n\n\tpublic max() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMax(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.right ? node : this.nodeMax(node.right);\n\t}\n\n\tprivate rotateRight(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst leftChild = node.left!;\n\t\tnode.left = leftChild.right;\n\t\tleftChild.right = node;\n\t\tleftChild.color = leftChild.right.color;\n\t\tleftChild.right.color = RBColor.RED;\n\t\tleftChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(leftChild);\n\t\t}\n\t\treturn leftChild;\n\t}\n\n\tprivate rotateLeft(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst rightChild = node.right!;\n\t\tnode.right = rightChild.left;\n\t\trightChild.left = node;\n\t\trightChild.color = rightChild.left.color;\n\t\trightChild.left.color = RBColor.RED;\n\t\trightChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(rightChild);\n\t\t}\n\t\treturn rightChild;\n\t}\n\n\tprivate oppositeColor(c: RBColor) {\n\t\treturn c === RBColor.BLACK ? RBColor.RED : RBColor.BLACK;\n\t}\n\n\tprivate flipColors(node: RBNode<TKey, TData>) {\n\t\tnode.color = this.oppositeColor(node.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.left!.color = this.oppositeColor(node.left!.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.right!.color = this.oppositeColor(node.right!.color);\n\t}\n\n\tprivate moveRedLeft(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.right!.left)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.right = this.rotateRight(_node.right!);\n\t\t\t_node = this.rotateLeft(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate moveRedRight(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.left!.left)) {\n\t\t\t_node = this.rotateRight(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate balance(input: RBNode<TKey, TData>) {\n\t\tlet node: RBNode<TKey, TData> | undefined = input;\n\t\tif (this.isRed(node.right)) {\n\t\t\tnode = this.rotateLeft(node);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(node.left) && this.isRed(node.left!.left)) {\n\t\t\tnode = this.rotateRight(node);\n\t\t}\n\t\tif (this.isRed(node.left) && this.isRed(node.right)) {\n\t\t\tthis.flipColors(node);\n\t\t}\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.aug.update(node);\n\t\t}\n\t\treturn node;\n\t}\n\n\tpublic mapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t) {\n\t\tthis.nodeMap(this.root, action, start, end);\n\t}\n\n\tpublic map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum) {\n\t\t// TODO: optimize to avoid comparisons\n\t\tthis.nodeMap(this.root, action, accum);\n\t}\n\n\tpublic keys() {\n\t\tconst keyList = <TKey[]>[];\n\t\tconst actions = <RBNodeActions<TKey, TData>>{\n\t\t\tshowStructure: true,\n\t\t\tinfix: (node) => {\n\t\t\t\tkeyList.push(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\tthis.walk(actions);\n\t\treturn keyList;\n\t}\n\n\t/**\n\t * Depth-first traversal with custom action; if action returns\n\t * false, traversal is halted.\n\t * @param action - action to apply to each node\n\t */\n\tpublic walk(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalk(this.root, actions);\n\t}\n\n\tpublic walkBackward(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalkBackward(this.root, actions);\n\t}\n\n\tprivate nodeWalk(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.left) {\n\t\t\t\tgo = this.nodeWalk(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalk(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeWalkBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.right) {\n\t\t\t\tgo = this.nodeWalkBackward(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalkBackward(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeMap<TAccum>(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): boolean {\n\t\tlet _start = start;\n\t\tlet _end = end;\n\t\tif (!node) {\n\t\t\treturn true;\n\t\t}\n\t\tif (_start === undefined) {\n\t\t\t_start = this.nodeMin(node).key;\n\t\t}\n\t\tif (_end === undefined) {\n\t\t\t_end = this.nodeMax(node).key;\n\t\t}\n\t\tconst cmpStart = this.compareKeys(_start, node.key);\n\t\tconst cmpEnd = this.compareKeys(_end, node.key);\n\t\tlet go = true;\n\t\tif (cmpStart < 0) {\n\t\t\tgo = this.nodeMap(node.left, action, accum, _start, _end);\n\t\t}\n\t\tif (go && cmpStart <= 0 && cmpEnd >= 0) {\n\t\t\t// REVIEW: test for black node here\n\t\t\tgo = action(node, accum);\n\t\t}\n\t\tif (go && cmpEnd > 0) {\n\t\t\tgo = this.nodeMap(node.right, action, accum, _start, _end);\n\t\t}\n\t\treturn go;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rbTree.js","sourceRoot":"","sources":["../../src/collections/rbTree.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAkE;AAElE,4CAA4C;AAE5C;;GAEG;AACU,QAAA,OAAO,GAAG;IACtB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACC,CAAC;AA4GX;;GAEG;AACH,MAAa,YAAY;IAGxB,YACkB,WAA8B,EAC9B,GAAkC;QADlC,gBAAW,GAAX,WAAW,CAAmB;QAC9B,QAAG,GAAH,GAAG,CAA+B;IACjD,CAAC;IAEI,QAAQ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AAM,IAAI,CAAC,EAAE;YACvC,mCAAmC;YACnC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACzB;QACD,IAAI,EAAE,IAAI,MAAM,GAAG,CAAC,EAAE;YACrB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC3D;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AA7lBD,oCA6lBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\n\n/* Remove once strictNullCheck is enabled */\n\n/**\n * @internal\n */\nexport const RBColor = {\n\tRED: 0,\n\tBLACK: 1,\n} as const;\n\n/**\n * @internal\n */\nexport type RBColor = typeof RBColor[keyof typeof RBColor];\n\n/**\n * @internal\n */\nexport interface RBNode<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n\tleft: RBNode<TKey, TData> | undefined;\n\tright: RBNode<TKey, TData> | undefined;\n\tcolor: RBColor;\n\tsize: number;\n}\n/**\n * @internal\n */\nexport interface IRBAugmentation<TKey, TData> {\n\tupdate(node: RBNode<TKey, TData>): void;\n}\n/**\n * @internal\n */\nexport interface IRBMatcher<TKey, TData> {\n\tcontinueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n\tmatchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n}\n\n/**\n * @internal\n */\nexport interface RBNodeActions<TKey, TData> {\n\tinfix?(node: RBNode<TKey, TData>): boolean;\n\tpre?(node: RBNode<TKey, TData>): boolean;\n\tpost?(node: RBNode<TKey, TData>): boolean;\n\tshowStructure?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface KeyComparer<TKey> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(a: TKey, b: TKey): number;\n}\n\n/**\n * @internal\n */\nexport interface Property<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n}\n\n/**\n * @internal\n */\nexport interface PropertyAction<TKey, TData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t<TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;\n}\n\n/**\n * @internal\n */\nexport interface QProperty<TKey, TData> {\n\tkey?: TKey;\n\tdata?: TData;\n}\n\n/**\n * @internal\n */\nexport type ConflictAction<TKey, TData> = (\n\tkey: TKey,\n\tcurrentKey: TKey,\n\tdata: TData,\n\tcurrentData: TData,\n) => QProperty<TKey, TData>;\n\n/**\n * @internal\n */\nexport interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {\n\tmax(): Property<TKey, TData> | undefined;\n\tmin(): Property<TKey, TData> | undefined;\n\tmapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface Dictionary<TKey, TData> {\n\tget(key: TKey): Property<TKey, TData> | undefined;\n\tput(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;\n\tremove(key: TKey): void;\n\tmap<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;\n}\n\n/**\n * @internal\n */\nexport class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {\n\tprivate root: RBNode<TKey, TData> | undefined;\n\n\tconstructor(\n\t\tprivate readonly compareKeys: KeyComparer<TKey>,\n\t\tprivate readonly aug?: IRBAugmentation<TKey, TData>,\n\t) {}\n\n\tprivate makeNode(key: TKey, data: TData, color: RBColor, size: number) {\n\t\treturn <RBNode<TKey, TData>>{ key, data, color, size };\n\t}\n\n\tprivate isRed(node: RBNode<TKey, TData> | undefined) {\n\t\treturn !!node && node.color === RBColor.RED;\n\t}\n\n\tprivate nodeSize(node: RBNode<TKey, TData> | undefined) {\n\t\treturn node ? node.size : 0;\n\t}\n\tpublic size() {\n\t\treturn this.nodeSize(this.root);\n\t}\n\tpublic isEmpty() {\n\t\treturn !this.root;\n\t}\n\tpublic get(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\treturn this.nodeGet(this.root, key);\n\t\t}\n\t}\n\tprivate nodeGet(node: RBNode<TKey, TData> | undefined, key: TKey) {\n\t\tlet _node = node;\n\t\twhile (_node) {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node = _node.left;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node = _node.right;\n\t\t\t} else {\n\t\t\t\treturn _node;\n\t\t\t}\n\t\t}\n\t}\n\tprivate contains(key: TKey) {\n\t\treturn this.get(key);\n\t}\n\n\tpublic gather(key: TKey, matcher: IRBMatcher<TKey, TData>) {\n\t\tconst results = [] as RBNode<TKey, TData>[];\n\t\tif (key !== undefined) {\n\t\t\tthis.nodeGather(this.root, results, key, matcher);\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate nodeGather(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tresults: RBNode<TKey, TData>[],\n\t\tkey: TKey,\n\t\tmatcher: IRBMatcher<TKey, TData>,\n\t) {\n\t\tif (node) {\n\t\t\tif (matcher.continueSubtree(node.left, key)) {\n\t\t\t\tthis.nodeGather(node.left, results, key, matcher);\n\t\t\t}\n\t\t\tif (matcher.matchNode(node, key)) {\n\t\t\t\tresults.push(node);\n\t\t\t}\n\t\t\tif (matcher.continueSubtree(node.right, key)) {\n\t\t\t\tthis.nodeGather(node.right, results, key, matcher);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic walkExactMatchesForward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesForward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesForward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic walkExactMatchesBackward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (cmp: number) => boolean,\n\t\tcontinueRightFn: (cmp: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>) {\n\t\tif (key !== undefined) {\n\t\t\tif (data === undefined) {\n\t\t\t\tthis.remove(key);\n\t\t\t} else {\n\t\t\t\tthis.root = this.nodePut(this.root, key, data, conflict);\n\t\t\t\tthis.root.color = RBColor.BLACK;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nodePut(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t\tdata: TData,\n\t\tconflict?: ConflictAction<TKey, TData>,\n\t) {\n\t\tlet _node = node;\n\t\tif (!_node) {\n\t\t\treturn this.makeNode(key, data, RBColor.RED, 1);\n\t\t} else {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node.left = this.nodePut(_node.left, key, data, conflict);\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node.right = this.nodePut(_node.right, key, data, conflict);\n\t\t\t} else {\n\t\t\t\tif (conflict) {\n\t\t\t\t\tconst kd = conflict(key, _node.key, data, _node.data);\n\t\t\t\t\tif (kd.key) {\n\t\t\t\t\t\t_node.key = kd.key;\n\t\t\t\t\t}\n\t\t\t\t\t_node.data = kd.data ? kd.data : data;\n\t\t\t\t} else {\n\t\t\t\t\t_node.data = data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isRed(_node.right) && !this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.right)) {\n\t\t\t\tthis.flipColors(_node);\n\t\t\t}\n\t\t\t_node.size = this.nodeSize(_node.left) + this.nodeSize(_node.right) + 1;\n\t\t\tif (this.aug) {\n\t\t\t\tthis.updateLocal(_node);\n\t\t\t}\n\t\t\treturn _node;\n\t\t}\n\t}\n\n\tprivate updateLocal(node: RBNode<TKey, TData>) {\n\t\tif (this.aug) {\n\t\t\tif (this.isRed(node.left)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.left!);\n\t\t\t}\n\t\t\tif (this.isRed(node.right)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.right!);\n\t\t\t}\n\t\t\tthis.aug.update(node);\n\t\t}\n\t}\n\n\tprivate nodeRemoveMin(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tif (_node.left) {\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemoveMin(_node.left!);\n\t\t\treturn this.balance(_node);\n\t\t}\n\t}\n\n\tpublic remove(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\tif (!this.contains(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.removeExisting(key);\n\t\t}\n\t\t// TODO: error on undefined key\n\t}\n\n\tpublic removeExisting(key: TKey) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (!this.isRed(this.root!.left) && !this.isRed(this.root!.right)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.root!.color = RBColor.RED;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.root = this.nodeRemove(this.root!, key);\n\t}\n\n\tprivate nodeRemove(node: RBNode<TKey, TData>, key: TKey) {\n\t\tlet _node = node;\n\t\tif (this.compareKeys(key, _node.key) < 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemove(_node.left!, key);\n\t\t} else {\n\t\t\tif (this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0 && !_node.right) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.right) && !this.isRed(_node.right!.left)) {\n\t\t\t\t_node = this.moveRedRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst subtreeMin = this.nodeMin(_node.right!);\n\t\t\t\t_node.key = subtreeMin.key;\n\t\t\t\t_node.data = subtreeMin.data;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemoveMin(_node.right!);\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemove(_node.right!, key);\n\t\t\t}\n\t\t}\n\t\treturn this.balance(_node);\n\t}\n\n\t/**\n\t * @returns The largest node in this tree which compares less than or equal to `key`\n\t */\n\tpublic floor(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeFloor(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeFloor(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp < 0) {\n\t\t\t\treturn this.nodeFloor(node.left, key);\n\t\t\t} else {\n\t\t\t\tconst rightFloor = this.nodeFloor(node.right, key);\n\t\t\t\treturn rightFloor ? rightFloor : node;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns The smallest node in this tree which compares greater than or equal to `key`\n\t */\n\tpublic ceil(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeCeil(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeCeil(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\treturn this.nodeCeil(node.right, key);\n\t\t\t} else {\n\t\t\t\tconst leftCeil = this.nodeCeil(node.left, key);\n\t\t\t\treturn leftCeil ? leftCeil : node;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic min() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMin(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.left ? node : this.nodeMin(node.left);\n\t}\n\n\tpublic max() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMax(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.right ? node : this.nodeMax(node.right);\n\t}\n\n\tprivate rotateRight(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst leftChild = node.left!;\n\t\tnode.left = leftChild.right;\n\t\tleftChild.right = node;\n\t\tleftChild.color = leftChild.right.color;\n\t\tleftChild.right.color = RBColor.RED;\n\t\tleftChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(leftChild);\n\t\t}\n\t\treturn leftChild;\n\t}\n\n\tprivate rotateLeft(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst rightChild = node.right!;\n\t\tnode.right = rightChild.left;\n\t\trightChild.left = node;\n\t\trightChild.color = rightChild.left.color;\n\t\trightChild.left.color = RBColor.RED;\n\t\trightChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(rightChild);\n\t\t}\n\t\treturn rightChild;\n\t}\n\n\tprivate oppositeColor(c: RBColor) {\n\t\treturn c === RBColor.BLACK ? RBColor.RED : RBColor.BLACK;\n\t}\n\n\tprivate flipColors(node: RBNode<TKey, TData>) {\n\t\tnode.color = this.oppositeColor(node.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.left!.color = this.oppositeColor(node.left!.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.right!.color = this.oppositeColor(node.right!.color);\n\t}\n\n\tprivate moveRedLeft(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.right!.left)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.right = this.rotateRight(_node.right!);\n\t\t\t_node = this.rotateLeft(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate moveRedRight(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.left!.left)) {\n\t\t\t_node = this.rotateRight(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate balance(input: RBNode<TKey, TData>) {\n\t\tlet node: RBNode<TKey, TData> | undefined = input;\n\t\tif (this.isRed(node.right)) {\n\t\t\tnode = this.rotateLeft(node);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(node.left) && this.isRed(node.left!.left)) {\n\t\t\tnode = this.rotateRight(node);\n\t\t}\n\t\tif (this.isRed(node.left) && this.isRed(node.right)) {\n\t\t\tthis.flipColors(node);\n\t\t}\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.aug.update(node);\n\t\t}\n\t\treturn node;\n\t}\n\n\tpublic mapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t) {\n\t\tthis.nodeMap(this.root, action, accum, start, end);\n\t}\n\n\tpublic map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum) {\n\t\t// TODO: optimize to avoid comparisons\n\t\tthis.nodeMap(this.root, action, accum);\n\t}\n\n\tpublic keys() {\n\t\tconst keyList = <TKey[]>[];\n\t\tconst actions = <RBNodeActions<TKey, TData>>{\n\t\t\tshowStructure: true,\n\t\t\tinfix: (node) => {\n\t\t\t\tkeyList.push(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\tthis.walk(actions);\n\t\treturn keyList;\n\t}\n\n\t/**\n\t * Depth-first traversal with custom action; if action returns\n\t * false, traversal is halted.\n\t * @param action - action to apply to each node\n\t */\n\tpublic walk(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalk(this.root, actions);\n\t}\n\n\tpublic walkBackward(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalkBackward(this.root, actions);\n\t}\n\n\tprivate nodeWalk(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.left) {\n\t\t\t\tgo = this.nodeWalk(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalk(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeWalkBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.right) {\n\t\t\t\tgo = this.nodeWalkBackward(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalkBackward(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeMap<TAccum>(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): boolean {\n\t\tlet _start = start;\n\t\tlet _end = end;\n\t\tif (!node) {\n\t\t\treturn true;\n\t\t}\n\t\tif (_start === undefined) {\n\t\t\t_start = this.nodeMin(node).key;\n\t\t}\n\t\tif (_end === undefined) {\n\t\t\t_end = this.nodeMax(node).key;\n\t\t}\n\t\tconst cmpStart = this.compareKeys(_start, node.key);\n\t\tconst cmpEnd = this.compareKeys(_end, node.key);\n\t\tlet go = true;\n\t\tif (cmpStart < 0) {\n\t\t\tgo = this.nodeMap(node.left, action, accum, _start, _end);\n\t\t}\n\t\tif (go && cmpStart <= 0 && cmpEnd >= 0) {\n\t\t\t// REVIEW: test for black node here\n\t\t\tgo = action(node, accum);\n\t\t}\n\t\tif (go && cmpEnd > 0) {\n\t\t\tgo = this.nodeMap(node.right, action, accum, _start, _end);\n\t\t}\n\t\treturn go;\n\t}\n}\n"]}
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.34.9"
9
+ }
10
+ ]
11
+ }
@@ -387,7 +387,7 @@ export class RedBlackTree {
387
387
  return node;
388
388
  }
389
389
  mapRange(action, accum, start, end) {
390
- this.nodeMap(this.root, action, start, end);
390
+ this.nodeMap(this.root, action, accum, start, end);
391
391
  }
392
392
  map(action, accum) {
393
393
  // TODO: optimize to avoid comparisons
@@ -1 +1 @@
1
- {"version":3,"file":"rbTree.js","sourceRoot":"","sources":["../../src/collections/rbTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kEAAkE;AAElE,4CAA4C;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACC,CAAC;AA4GX;;GAEG;AACH,MAAM,OAAO,YAAY;IAGxB,YACkB,WAA8B,EAC9B,GAAkC;QADlC,gBAAW,GAAX,WAAW,CAAmB;QAC9B,QAAG,GAAH,GAAG,CAA+B;IACjD,CAAC;IAEI,QAAQ,CAAC,GAAS,EAAE,IAAW,EAAE,KAAc,EAAE,IAAY;QACpE,OAA4B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,IAAqC;QAClD,OAAO,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC;IAC7C,CAAC;IAEO,QAAQ,CAAC,IAAqC;QACrD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACM,IAAI;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IACM,OAAO;QACb,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACM,GAAG,CAAC,GAAS;QACnB,IAAI,GAAG,KAAK,SAAS,EAAE;YACtB,OAAO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,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;SAChC;QACD,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;SAC9B;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,EAAE,GAAG,IAAI,CAAC;QACd,IAAI,QAAQ,GAAG,CAAC,EAAE;YACjB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC1D;QACD,IAAI,EAAE,IAAI,QAAQ,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;YACvC,mCAAmC;YACnC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACzB;QACD,IAAI,EAAE,IAAI,MAAM,GAAG,CAAC,EAAE;YACrB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC3D;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\n\n/* Remove once strictNullCheck is enabled */\n\n/**\n * @internal\n */\nexport const RBColor = {\n\tRED: 0,\n\tBLACK: 1,\n} as const;\n\n/**\n * @internal\n */\nexport type RBColor = typeof RBColor[keyof typeof RBColor];\n\n/**\n * @internal\n */\nexport interface RBNode<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n\tleft: RBNode<TKey, TData> | undefined;\n\tright: RBNode<TKey, TData> | undefined;\n\tcolor: RBColor;\n\tsize: number;\n}\n/**\n * @internal\n */\nexport interface IRBAugmentation<TKey, TData> {\n\tupdate(node: RBNode<TKey, TData>): void;\n}\n/**\n * @internal\n */\nexport interface IRBMatcher<TKey, TData> {\n\tcontinueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n\tmatchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n}\n\n/**\n * @internal\n */\nexport interface RBNodeActions<TKey, TData> {\n\tinfix?(node: RBNode<TKey, TData>): boolean;\n\tpre?(node: RBNode<TKey, TData>): boolean;\n\tpost?(node: RBNode<TKey, TData>): boolean;\n\tshowStructure?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface KeyComparer<TKey> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(a: TKey, b: TKey): number;\n}\n\n/**\n * @internal\n */\nexport interface Property<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n}\n\n/**\n * @internal\n */\nexport interface PropertyAction<TKey, TData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t<TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;\n}\n\n/**\n * @internal\n */\nexport interface QProperty<TKey, TData> {\n\tkey?: TKey;\n\tdata?: TData;\n}\n\n/**\n * @internal\n */\nexport type ConflictAction<TKey, TData> = (\n\tkey: TKey,\n\tcurrentKey: TKey,\n\tdata: TData,\n\tcurrentData: TData,\n) => QProperty<TKey, TData>;\n\n/**\n * @internal\n */\nexport interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {\n\tmax(): Property<TKey, TData> | undefined;\n\tmin(): Property<TKey, TData> | undefined;\n\tmapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface Dictionary<TKey, TData> {\n\tget(key: TKey): Property<TKey, TData> | undefined;\n\tput(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;\n\tremove(key: TKey): void;\n\tmap<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;\n}\n\n/**\n * @internal\n */\nexport class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {\n\tprivate root: RBNode<TKey, TData> | undefined;\n\n\tconstructor(\n\t\tprivate readonly compareKeys: KeyComparer<TKey>,\n\t\tprivate readonly aug?: IRBAugmentation<TKey, TData>,\n\t) {}\n\n\tprivate makeNode(key: TKey, data: TData, color: RBColor, size: number) {\n\t\treturn <RBNode<TKey, TData>>{ key, data, color, size };\n\t}\n\n\tprivate isRed(node: RBNode<TKey, TData> | undefined) {\n\t\treturn !!node && node.color === RBColor.RED;\n\t}\n\n\tprivate nodeSize(node: RBNode<TKey, TData> | undefined) {\n\t\treturn node ? node.size : 0;\n\t}\n\tpublic size() {\n\t\treturn this.nodeSize(this.root);\n\t}\n\tpublic isEmpty() {\n\t\treturn !this.root;\n\t}\n\tpublic get(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\treturn this.nodeGet(this.root, key);\n\t\t}\n\t}\n\tprivate nodeGet(node: RBNode<TKey, TData> | undefined, key: TKey) {\n\t\tlet _node = node;\n\t\twhile (_node) {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node = _node.left;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node = _node.right;\n\t\t\t} else {\n\t\t\t\treturn _node;\n\t\t\t}\n\t\t}\n\t}\n\tprivate contains(key: TKey) {\n\t\treturn this.get(key);\n\t}\n\n\tpublic gather(key: TKey, matcher: IRBMatcher<TKey, TData>) {\n\t\tconst results = [] as RBNode<TKey, TData>[];\n\t\tif (key !== undefined) {\n\t\t\tthis.nodeGather(this.root, results, key, matcher);\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate nodeGather(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tresults: RBNode<TKey, TData>[],\n\t\tkey: TKey,\n\t\tmatcher: IRBMatcher<TKey, TData>,\n\t) {\n\t\tif (node) {\n\t\t\tif (matcher.continueSubtree(node.left, key)) {\n\t\t\t\tthis.nodeGather(node.left, results, key, matcher);\n\t\t\t}\n\t\t\tif (matcher.matchNode(node, key)) {\n\t\t\t\tresults.push(node);\n\t\t\t}\n\t\t\tif (matcher.continueSubtree(node.right, key)) {\n\t\t\t\tthis.nodeGather(node.right, results, key, matcher);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic walkExactMatchesForward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesForward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesForward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic walkExactMatchesBackward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (cmp: number) => boolean,\n\t\tcontinueRightFn: (cmp: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>) {\n\t\tif (key !== undefined) {\n\t\t\tif (data === undefined) {\n\t\t\t\tthis.remove(key);\n\t\t\t} else {\n\t\t\t\tthis.root = this.nodePut(this.root, key, data, conflict);\n\t\t\t\tthis.root.color = RBColor.BLACK;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nodePut(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t\tdata: TData,\n\t\tconflict?: ConflictAction<TKey, TData>,\n\t) {\n\t\tlet _node = node;\n\t\tif (!_node) {\n\t\t\treturn this.makeNode(key, data, RBColor.RED, 1);\n\t\t} else {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node.left = this.nodePut(_node.left, key, data, conflict);\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node.right = this.nodePut(_node.right, key, data, conflict);\n\t\t\t} else {\n\t\t\t\tif (conflict) {\n\t\t\t\t\tconst kd = conflict(key, _node.key, data, _node.data);\n\t\t\t\t\tif (kd.key) {\n\t\t\t\t\t\t_node.key = kd.key;\n\t\t\t\t\t}\n\t\t\t\t\t_node.data = kd.data ? kd.data : data;\n\t\t\t\t} else {\n\t\t\t\t\t_node.data = data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isRed(_node.right) && !this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.right)) {\n\t\t\t\tthis.flipColors(_node);\n\t\t\t}\n\t\t\t_node.size = this.nodeSize(_node.left) + this.nodeSize(_node.right) + 1;\n\t\t\tif (this.aug) {\n\t\t\t\tthis.updateLocal(_node);\n\t\t\t}\n\t\t\treturn _node;\n\t\t}\n\t}\n\n\tprivate updateLocal(node: RBNode<TKey, TData>) {\n\t\tif (this.aug) {\n\t\t\tif (this.isRed(node.left)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.left!);\n\t\t\t}\n\t\t\tif (this.isRed(node.right)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.right!);\n\t\t\t}\n\t\t\tthis.aug.update(node);\n\t\t}\n\t}\n\n\tprivate nodeRemoveMin(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tif (_node.left) {\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemoveMin(_node.left!);\n\t\t\treturn this.balance(_node);\n\t\t}\n\t}\n\n\tpublic remove(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\tif (!this.contains(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.removeExisting(key);\n\t\t}\n\t\t// TODO: error on undefined key\n\t}\n\n\tpublic removeExisting(key: TKey) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (!this.isRed(this.root!.left) && !this.isRed(this.root!.right)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.root!.color = RBColor.RED;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.root = this.nodeRemove(this.root!, key);\n\t}\n\n\tprivate nodeRemove(node: RBNode<TKey, TData>, key: TKey) {\n\t\tlet _node = node;\n\t\tif (this.compareKeys(key, _node.key) < 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemove(_node.left!, key);\n\t\t} else {\n\t\t\tif (this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0 && !_node.right) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.right) && !this.isRed(_node.right!.left)) {\n\t\t\t\t_node = this.moveRedRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst subtreeMin = this.nodeMin(_node.right!);\n\t\t\t\t_node.key = subtreeMin.key;\n\t\t\t\t_node.data = subtreeMin.data;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemoveMin(_node.right!);\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemove(_node.right!, key);\n\t\t\t}\n\t\t}\n\t\treturn this.balance(_node);\n\t}\n\n\t/**\n\t * @returns The largest node in this tree which compares less than or equal to `key`\n\t */\n\tpublic floor(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeFloor(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeFloor(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp < 0) {\n\t\t\t\treturn this.nodeFloor(node.left, key);\n\t\t\t} else {\n\t\t\t\tconst rightFloor = this.nodeFloor(node.right, key);\n\t\t\t\treturn rightFloor ? rightFloor : node;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns The smallest node in this tree which compares greater than or equal to `key`\n\t */\n\tpublic ceil(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeCeil(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeCeil(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\treturn this.nodeCeil(node.right, key);\n\t\t\t} else {\n\t\t\t\tconst leftCeil = this.nodeCeil(node.left, key);\n\t\t\t\treturn leftCeil ? leftCeil : node;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic min() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMin(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.left ? node : this.nodeMin(node.left);\n\t}\n\n\tpublic max() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMax(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.right ? node : this.nodeMax(node.right);\n\t}\n\n\tprivate rotateRight(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst leftChild = node.left!;\n\t\tnode.left = leftChild.right;\n\t\tleftChild.right = node;\n\t\tleftChild.color = leftChild.right.color;\n\t\tleftChild.right.color = RBColor.RED;\n\t\tleftChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(leftChild);\n\t\t}\n\t\treturn leftChild;\n\t}\n\n\tprivate rotateLeft(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst rightChild = node.right!;\n\t\tnode.right = rightChild.left;\n\t\trightChild.left = node;\n\t\trightChild.color = rightChild.left.color;\n\t\trightChild.left.color = RBColor.RED;\n\t\trightChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(rightChild);\n\t\t}\n\t\treturn rightChild;\n\t}\n\n\tprivate oppositeColor(c: RBColor) {\n\t\treturn c === RBColor.BLACK ? RBColor.RED : RBColor.BLACK;\n\t}\n\n\tprivate flipColors(node: RBNode<TKey, TData>) {\n\t\tnode.color = this.oppositeColor(node.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.left!.color = this.oppositeColor(node.left!.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.right!.color = this.oppositeColor(node.right!.color);\n\t}\n\n\tprivate moveRedLeft(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.right!.left)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.right = this.rotateRight(_node.right!);\n\t\t\t_node = this.rotateLeft(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate moveRedRight(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.left!.left)) {\n\t\t\t_node = this.rotateRight(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate balance(input: RBNode<TKey, TData>) {\n\t\tlet node: RBNode<TKey, TData> | undefined = input;\n\t\tif (this.isRed(node.right)) {\n\t\t\tnode = this.rotateLeft(node);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(node.left) && this.isRed(node.left!.left)) {\n\t\t\tnode = this.rotateRight(node);\n\t\t}\n\t\tif (this.isRed(node.left) && this.isRed(node.right)) {\n\t\t\tthis.flipColors(node);\n\t\t}\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.aug.update(node);\n\t\t}\n\t\treturn node;\n\t}\n\n\tpublic mapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t) {\n\t\tthis.nodeMap(this.root, action, start, end);\n\t}\n\n\tpublic map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum) {\n\t\t// TODO: optimize to avoid comparisons\n\t\tthis.nodeMap(this.root, action, accum);\n\t}\n\n\tpublic keys() {\n\t\tconst keyList = <TKey[]>[];\n\t\tconst actions = <RBNodeActions<TKey, TData>>{\n\t\t\tshowStructure: true,\n\t\t\tinfix: (node) => {\n\t\t\t\tkeyList.push(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\tthis.walk(actions);\n\t\treturn keyList;\n\t}\n\n\t/**\n\t * Depth-first traversal with custom action; if action returns\n\t * false, traversal is halted.\n\t * @param action - action to apply to each node\n\t */\n\tpublic walk(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalk(this.root, actions);\n\t}\n\n\tpublic walkBackward(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalkBackward(this.root, actions);\n\t}\n\n\tprivate nodeWalk(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.left) {\n\t\t\t\tgo = this.nodeWalk(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalk(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeWalkBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.right) {\n\t\t\t\tgo = this.nodeWalkBackward(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalkBackward(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeMap<TAccum>(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): boolean {\n\t\tlet _start = start;\n\t\tlet _end = end;\n\t\tif (!node) {\n\t\t\treturn true;\n\t\t}\n\t\tif (_start === undefined) {\n\t\t\t_start = this.nodeMin(node).key;\n\t\t}\n\t\tif (_end === undefined) {\n\t\t\t_end = this.nodeMax(node).key;\n\t\t}\n\t\tconst cmpStart = this.compareKeys(_start, node.key);\n\t\tconst cmpEnd = this.compareKeys(_end, node.key);\n\t\tlet go = true;\n\t\tif (cmpStart < 0) {\n\t\t\tgo = this.nodeMap(node.left, action, accum, _start, _end);\n\t\t}\n\t\tif (go && cmpStart <= 0 && cmpEnd >= 0) {\n\t\t\t// REVIEW: test for black node here\n\t\t\tgo = action(node, accum);\n\t\t}\n\t\tif (go && cmpEnd > 0) {\n\t\t\tgo = this.nodeMap(node.right, action, accum, _start, _end);\n\t\t}\n\t\treturn go;\n\t}\n}\n"]}
1
+ {"version":3,"file":"rbTree.js","sourceRoot":"","sources":["../../src/collections/rbTree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kEAAkE;AAElE,4CAA4C;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;CACC,CAAC;AA4GX;;GAEG;AACH,MAAM,OAAO,YAAY;IAGxB,YACkB,WAA8B,EAC9B,GAAkC;QADlC,gBAAW,GAAX,WAAW,CAAmB;QAC9B,QAAG,GAAH,GAAG,CAA+B;IACjD,CAAC;IAEI,QAAQ,CAAC,GAAS,EAAE,IAAW,EAAE,KAAc,EAAE,IAAY;QACpE,OAA4B,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxD,CAAC;IAEO,KAAK,CAAC,IAAqC;QAClD,OAAO,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC;IAC7C,CAAC;IAEO,QAAQ,CAAC,IAAqC;QACrD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACM,IAAI;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,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AAY,EACZ,GAAU;QAEV,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,EAAE;YACV,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,MAAM,KAAK,SAAS,EAAE;YACzB,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;SAChC;QACD,IAAI,IAAI,KAAK,SAAS,EAAE;YACvB,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;SAC9B;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,EAAE,GAAG,IAAI,CAAC;QACd,IAAI,QAAQ,GAAG,CAAC,EAAE;YACjB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC1D;QACD,IAAI,EAAE,IAAI,QAAQ,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE;YACvC,mCAAmC;YACnC,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACzB;QACD,IAAI,EAAE,IAAI,MAAM,GAAG,CAAC,EAAE;YACrB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC3D;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\n\n/* Remove once strictNullCheck is enabled */\n\n/**\n * @internal\n */\nexport const RBColor = {\n\tRED: 0,\n\tBLACK: 1,\n} as const;\n\n/**\n * @internal\n */\nexport type RBColor = typeof RBColor[keyof typeof RBColor];\n\n/**\n * @internal\n */\nexport interface RBNode<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n\tleft: RBNode<TKey, TData> | undefined;\n\tright: RBNode<TKey, TData> | undefined;\n\tcolor: RBColor;\n\tsize: number;\n}\n/**\n * @internal\n */\nexport interface IRBAugmentation<TKey, TData> {\n\tupdate(node: RBNode<TKey, TData>): void;\n}\n/**\n * @internal\n */\nexport interface IRBMatcher<TKey, TData> {\n\tcontinueSubtree(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n\tmatchNode(node: RBNode<TKey, TData> | undefined, key: TKey): boolean;\n}\n\n/**\n * @internal\n */\nexport interface RBNodeActions<TKey, TData> {\n\tinfix?(node: RBNode<TKey, TData>): boolean;\n\tpre?(node: RBNode<TKey, TData>): boolean;\n\tpost?(node: RBNode<TKey, TData>): boolean;\n\tshowStructure?: boolean;\n}\n\n/**\n * @internal\n */\nexport interface KeyComparer<TKey> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t(a: TKey, b: TKey): number;\n}\n\n/**\n * @internal\n */\nexport interface Property<TKey, TData> {\n\tkey: TKey;\n\tdata: TData;\n}\n\n/**\n * @internal\n */\nexport interface PropertyAction<TKey, TData> {\n\t// eslint-disable-next-line @typescript-eslint/prefer-function-type\n\t<TAccum>(p: Property<TKey, TData>, accum?: TAccum): boolean;\n}\n\n/**\n * @internal\n */\nexport interface QProperty<TKey, TData> {\n\tkey?: TKey;\n\tdata?: TData;\n}\n\n/**\n * @internal\n */\nexport type ConflictAction<TKey, TData> = (\n\tkey: TKey,\n\tcurrentKey: TKey,\n\tdata: TData,\n\tcurrentData: TData,\n) => QProperty<TKey, TData>;\n\n/**\n * @internal\n */\nexport interface SortedDictionary<TKey, TData> extends Dictionary<TKey, TData> {\n\tmax(): Property<TKey, TData> | undefined;\n\tmin(): Property<TKey, TData> | undefined;\n\tmapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): void;\n}\n\n/**\n * @internal\n */\nexport interface Dictionary<TKey, TData> {\n\tget(key: TKey): Property<TKey, TData> | undefined;\n\tput(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>): void;\n\tremove(key: TKey): void;\n\tmap<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum): void;\n}\n\n/**\n * @internal\n */\nexport class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData> {\n\tprivate root: RBNode<TKey, TData> | undefined;\n\n\tconstructor(\n\t\tprivate readonly compareKeys: KeyComparer<TKey>,\n\t\tprivate readonly aug?: IRBAugmentation<TKey, TData>,\n\t) {}\n\n\tprivate makeNode(key: TKey, data: TData, color: RBColor, size: number) {\n\t\treturn <RBNode<TKey, TData>>{ key, data, color, size };\n\t}\n\n\tprivate isRed(node: RBNode<TKey, TData> | undefined) {\n\t\treturn !!node && node.color === RBColor.RED;\n\t}\n\n\tprivate nodeSize(node: RBNode<TKey, TData> | undefined) {\n\t\treturn node ? node.size : 0;\n\t}\n\tpublic size() {\n\t\treturn this.nodeSize(this.root);\n\t}\n\tpublic isEmpty() {\n\t\treturn !this.root;\n\t}\n\tpublic get(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\treturn this.nodeGet(this.root, key);\n\t\t}\n\t}\n\tprivate nodeGet(node: RBNode<TKey, TData> | undefined, key: TKey) {\n\t\tlet _node = node;\n\t\twhile (_node) {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node = _node.left;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node = _node.right;\n\t\t\t} else {\n\t\t\t\treturn _node;\n\t\t\t}\n\t\t}\n\t}\n\tprivate contains(key: TKey) {\n\t\treturn this.get(key);\n\t}\n\n\tpublic gather(key: TKey, matcher: IRBMatcher<TKey, TData>) {\n\t\tconst results = [] as RBNode<TKey, TData>[];\n\t\tif (key !== undefined) {\n\t\t\tthis.nodeGather(this.root, results, key, matcher);\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate nodeGather(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tresults: RBNode<TKey, TData>[],\n\t\tkey: TKey,\n\t\tmatcher: IRBMatcher<TKey, TData>,\n\t) {\n\t\tif (node) {\n\t\t\tif (matcher.continueSubtree(node.left, key)) {\n\t\t\t\tthis.nodeGather(node.left, results, key, matcher);\n\t\t\t}\n\t\t\tif (matcher.matchNode(node, key)) {\n\t\t\t\tresults.push(node);\n\t\t\t}\n\t\t\tif (matcher.continueSubtree(node.right, key)) {\n\t\t\t\tthis.nodeGather(node.right, results, key, matcher);\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic walkExactMatchesForward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesForward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesForward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesForward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic walkExactMatchesBackward(\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (number: number) => boolean,\n\t\tcontinueRightFn: (number: number) => boolean,\n\t) {\n\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\tthis.root,\n\t\t\tcompareFn,\n\t\t\tactionFn,\n\t\t\tcontinueLeftFn,\n\t\t\tcontinueRightFn,\n\t\t);\n\t}\n\n\tprivate nodeWalkExactMatchesBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tcompareFn: (node: RBNode<TKey, TData>) => number,\n\t\tactionFn: (node: RBNode<TKey, TData>) => void,\n\t\tcontinueLeftFn: (cmp: number) => boolean,\n\t\tcontinueRightFn: (cmp: number) => boolean,\n\t) {\n\t\tif (!node) {\n\t\t\treturn;\n\t\t}\n\t\tconst result: number = compareFn(node);\n\t\tif (continueRightFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.right,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t\tif (result === 0) {\n\t\t\tactionFn(node);\n\t\t}\n\t\tif (continueLeftFn(result)) {\n\t\t\tthis.nodeWalkExactMatchesBackward(\n\t\t\t\tnode.left,\n\t\t\t\tcompareFn,\n\t\t\t\tactionFn,\n\t\t\t\tcontinueLeftFn,\n\t\t\t\tcontinueRightFn,\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic put(key: TKey, data: TData, conflict?: ConflictAction<TKey, TData>) {\n\t\tif (key !== undefined) {\n\t\t\tif (data === undefined) {\n\t\t\t\tthis.remove(key);\n\t\t\t} else {\n\t\t\t\tthis.root = this.nodePut(this.root, key, data, conflict);\n\t\t\t\tthis.root.color = RBColor.BLACK;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nodePut(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t\tdata: TData,\n\t\tconflict?: ConflictAction<TKey, TData>,\n\t) {\n\t\tlet _node = node;\n\t\tif (!_node) {\n\t\t\treturn this.makeNode(key, data, RBColor.RED, 1);\n\t\t} else {\n\t\t\tconst cmp = this.compareKeys(key, _node.key);\n\t\t\tif (cmp < 0) {\n\t\t\t\t_node.left = this.nodePut(_node.left, key, data, conflict);\n\t\t\t} else if (cmp > 0) {\n\t\t\t\t_node.right = this.nodePut(_node.right, key, data, conflict);\n\t\t\t} else {\n\t\t\t\tif (conflict) {\n\t\t\t\t\tconst kd = conflict(key, _node.key, data, _node.data);\n\t\t\t\t\tif (kd.key) {\n\t\t\t\t\t\t_node.key = kd.key;\n\t\t\t\t\t}\n\t\t\t\t\t_node.data = kd.data ? kd.data : data;\n\t\t\t\t} else {\n\t\t\t\t\t_node.data = data;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isRed(_node.right) && !this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.isRed(_node.left) && this.isRed(_node.right)) {\n\t\t\t\tthis.flipColors(_node);\n\t\t\t}\n\t\t\t_node.size = this.nodeSize(_node.left) + this.nodeSize(_node.right) + 1;\n\t\t\tif (this.aug) {\n\t\t\t\tthis.updateLocal(_node);\n\t\t\t}\n\t\t\treturn _node;\n\t\t}\n\t}\n\n\tprivate updateLocal(node: RBNode<TKey, TData>) {\n\t\tif (this.aug) {\n\t\t\tif (this.isRed(node.left)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.left!);\n\t\t\t}\n\t\t\tif (this.isRed(node.right)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tthis.aug.update(node.right!);\n\t\t\t}\n\t\t\tthis.aug.update(node);\n\t\t}\n\t}\n\n\tprivate nodeRemoveMin(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tif (_node.left) {\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemoveMin(_node.left!);\n\t\t\treturn this.balance(_node);\n\t\t}\n\t}\n\n\tpublic remove(key: TKey) {\n\t\tif (key !== undefined) {\n\t\t\tif (!this.contains(key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.removeExisting(key);\n\t\t}\n\t\t// TODO: error on undefined key\n\t}\n\n\tpublic removeExisting(key: TKey) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (!this.isRed(this.root!.left) && !this.isRed(this.root!.right)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tthis.root!.color = RBColor.RED;\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tthis.root = this.nodeRemove(this.root!, key);\n\t}\n\n\tprivate nodeRemove(node: RBNode<TKey, TData>, key: TKey) {\n\t\tlet _node = node;\n\t\tif (this.compareKeys(key, _node.key) < 0) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.left) && !this.isRed(_node.left!.left)) {\n\t\t\t\t_node = this.moveRedLeft(_node);\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.left = this.nodeRemove(_node.left!, key);\n\t\t} else {\n\t\t\tif (this.isRed(_node.left)) {\n\t\t\t\t_node = this.rotateRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0 && !_node.right) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (!this.isRed(_node.right) && !this.isRed(_node.right!.left)) {\n\t\t\t\t_node = this.moveRedRight(_node);\n\t\t\t}\n\t\t\tif (this.compareKeys(key, _node.key) === 0) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst subtreeMin = this.nodeMin(_node.right!);\n\t\t\t\t_node.key = subtreeMin.key;\n\t\t\t\t_node.data = subtreeMin.data;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemoveMin(_node.right!);\n\t\t\t} else {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t_node.right = this.nodeRemove(_node.right!, key);\n\t\t\t}\n\t\t}\n\t\treturn this.balance(_node);\n\t}\n\n\t/**\n\t * @returns The largest node in this tree which compares less than or equal to `key`\n\t */\n\tpublic floor(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeFloor(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeFloor(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp < 0) {\n\t\t\t\treturn this.nodeFloor(node.left, key);\n\t\t\t} else {\n\t\t\t\tconst rightFloor = this.nodeFloor(node.right, key);\n\t\t\t\treturn rightFloor ? rightFloor : node;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @returns The smallest node in this tree which compares greater than or equal to `key`\n\t */\n\tpublic ceil(key: TKey) {\n\t\tif (!this.isEmpty()) {\n\t\t\treturn this.nodeCeil(this.root, key);\n\t\t}\n\t}\n\n\tprivate nodeCeil(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tkey: TKey,\n\t): RBNode<TKey, TData> | undefined {\n\t\tif (node) {\n\t\t\tconst cmp = this.compareKeys(key, node.key);\n\t\t\tif (cmp === 0) {\n\t\t\t\treturn node;\n\t\t\t} else if (cmp > 0) {\n\t\t\t\treturn this.nodeCeil(node.right, key);\n\t\t\t} else {\n\t\t\t\tconst leftCeil = this.nodeCeil(node.left, key);\n\t\t\t\treturn leftCeil ? leftCeil : node;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic min() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMin(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMin(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.left ? node : this.nodeMin(node.left);\n\t}\n\n\tpublic max() {\n\t\tif (this.root) {\n\t\t\treturn this.nodeMax(this.root);\n\t\t}\n\t}\n\n\tprivate nodeMax(node: RBNode<TKey, TData>): RBNode<TKey, TData> {\n\t\treturn !node.right ? node : this.nodeMax(node.right);\n\t}\n\n\tprivate rotateRight(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst leftChild = node.left!;\n\t\tnode.left = leftChild.right;\n\t\tleftChild.right = node;\n\t\tleftChild.color = leftChild.right.color;\n\t\tleftChild.right.color = RBColor.RED;\n\t\tleftChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(leftChild);\n\t\t}\n\t\treturn leftChild;\n\t}\n\n\tprivate rotateLeft(node: RBNode<TKey, TData>) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst rightChild = node.right!;\n\t\tnode.right = rightChild.left;\n\t\trightChild.left = node;\n\t\trightChild.color = rightChild.left.color;\n\t\trightChild.left.color = RBColor.RED;\n\t\trightChild.size = node.size;\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.updateLocal(node);\n\t\t\tthis.updateLocal(rightChild);\n\t\t}\n\t\treturn rightChild;\n\t}\n\n\tprivate oppositeColor(c: RBColor) {\n\t\treturn c === RBColor.BLACK ? RBColor.RED : RBColor.BLACK;\n\t}\n\n\tprivate flipColors(node: RBNode<TKey, TData>) {\n\t\tnode.color = this.oppositeColor(node.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.left!.color = this.oppositeColor(node.left!.color);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tnode.right!.color = this.oppositeColor(node.right!.color);\n\t}\n\n\tprivate moveRedLeft(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.right!.left)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t_node.right = this.rotateRight(_node.right!);\n\t\t\t_node = this.rotateLeft(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate moveRedRight(node: RBNode<TKey, TData>) {\n\t\tlet _node = node;\n\t\tthis.flipColors(_node);\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(_node.left!.left)) {\n\t\t\t_node = this.rotateRight(_node);\n\t\t\tthis.flipColors(_node);\n\t\t}\n\t\treturn _node;\n\t}\n\n\tprivate balance(input: RBNode<TKey, TData>) {\n\t\tlet node: RBNode<TKey, TData> | undefined = input;\n\t\tif (this.isRed(node.right)) {\n\t\t\tnode = this.rotateLeft(node);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tif (this.isRed(node.left) && this.isRed(node.left!.left)) {\n\t\t\tnode = this.rotateRight(node);\n\t\t}\n\t\tif (this.isRed(node.left) && this.isRed(node.right)) {\n\t\t\tthis.flipColors(node);\n\t\t}\n\t\tnode.size = this.nodeSize(node.left) + this.nodeSize(node.right) + 1;\n\t\tif (this.aug) {\n\t\t\tthis.aug.update(node);\n\t\t}\n\t\treturn node;\n\t}\n\n\tpublic mapRange<TAccum>(\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t) {\n\t\tthis.nodeMap(this.root, action, accum, start, end);\n\t}\n\n\tpublic map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum) {\n\t\t// TODO: optimize to avoid comparisons\n\t\tthis.nodeMap(this.root, action, accum);\n\t}\n\n\tpublic keys() {\n\t\tconst keyList = <TKey[]>[];\n\t\tconst actions = <RBNodeActions<TKey, TData>>{\n\t\t\tshowStructure: true,\n\t\t\tinfix: (node) => {\n\t\t\t\tkeyList.push(node.key);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\t\tthis.walk(actions);\n\t\treturn keyList;\n\t}\n\n\t/**\n\t * Depth-first traversal with custom action; if action returns\n\t * false, traversal is halted.\n\t * @param action - action to apply to each node\n\t */\n\tpublic walk(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalk(this.root, actions);\n\t}\n\n\tpublic walkBackward(actions: RBNodeActions<TKey, TData>) {\n\t\tthis.nodeWalkBackward(this.root, actions);\n\t}\n\n\tprivate nodeWalk(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.left) {\n\t\t\t\tgo = this.nodeWalk(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalk(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeWalkBackward(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\tactions: RBNodeActions<TKey, TData>,\n\t): boolean {\n\t\tlet go = true;\n\t\tif (node) {\n\t\t\tif (actions.pre) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.pre(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (node.right) {\n\t\t\t\tgo = this.nodeWalkBackward(node.right, actions);\n\t\t\t}\n\t\t\tif (go && actions.infix) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.infix(node);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (go) {\n\t\t\t\tgo = this.nodeWalkBackward(node.left, actions);\n\t\t\t}\n\t\t\tif (go && actions.post) {\n\t\t\t\tif (actions.showStructure || node.color === RBColor.BLACK) {\n\t\t\t\t\tgo = actions.post(node);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn go;\n\t}\n\n\tprivate nodeMap<TAccum>(\n\t\tnode: RBNode<TKey, TData> | undefined,\n\t\taction: PropertyAction<TKey, TData>,\n\t\taccum?: TAccum,\n\t\tstart?: TKey,\n\t\tend?: TKey,\n\t): boolean {\n\t\tlet _start = start;\n\t\tlet _end = end;\n\t\tif (!node) {\n\t\t\treturn true;\n\t\t}\n\t\tif (_start === undefined) {\n\t\t\t_start = this.nodeMin(node).key;\n\t\t}\n\t\tif (_end === undefined) {\n\t\t\t_end = this.nodeMax(node).key;\n\t\t}\n\t\tconst cmpStart = this.compareKeys(_start, node.key);\n\t\tconst cmpEnd = this.compareKeys(_end, node.key);\n\t\tlet go = true;\n\t\tif (cmpStart < 0) {\n\t\t\tgo = this.nodeMap(node.left, action, accum, _start, _end);\n\t\t}\n\t\tif (go && cmpStart <= 0 && cmpEnd >= 0) {\n\t\t\t// REVIEW: test for black node here\n\t\t\tgo = action(node, accum);\n\t\t}\n\t\tif (go && cmpEnd > 0) {\n\t\t\tgo = this.nodeMap(node.right, action, accum, _start, _end);\n\t\t}\n\t\treturn go;\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/merge-tree",
3
- "version": "2.0.0-internal.5.0.0",
3
+ "version": "2.0.0-internal.5.1.0",
4
4
  "description": "Merge tree",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,27 +37,27 @@
37
37
  "dependencies": {
38
38
  "@fluidframework/common-definitions": "^0.20.1",
39
39
  "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/container-definitions": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
41
- "@fluidframework/container-utils": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
42
- "@fluidframework/core-interfaces": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
43
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
40
+ "@fluidframework/container-definitions": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
41
+ "@fluidframework/container-utils": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
42
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
43
+ "@fluidframework/datastore-definitions": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
44
44
  "@fluidframework/protocol-definitions": "^1.1.0",
45
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
46
- "@fluidframework/runtime-utils": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
47
- "@fluidframework/shared-object-base": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
48
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0"
45
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
46
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
47
+ "@fluidframework/shared-object-base": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
48
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
52
- "@fluid-internal/test-pairwise-generator": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
51
+ "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
52
+ "@fluid-internal/test-pairwise-generator": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
53
53
  "@fluid-tools/benchmark": "^0.47.0",
54
- "@fluid-tools/build-cli": "^0.17.0",
55
- "@fluidframework/build-common": "^1.1.0",
56
- "@fluidframework/build-tools": "^0.17.0",
54
+ "@fluid-tools/build-cli": "^0.19.0",
55
+ "@fluidframework/build-common": "^1.2.0",
56
+ "@fluidframework/build-tools": "^0.19.0",
57
57
  "@fluidframework/eslint-config-fluid": "^2.0.0",
58
- "@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.0.0-internal.4.1.0",
59
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
60
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.5.0.0 <2.0.0-internal.5.1.0",
58
+ "@fluidframework/merge-tree-previous": "npm:@fluidframework/merge-tree@2.0.0-internal.5.0.0",
59
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
60
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.5.1.0 <2.0.0-internal.5.2.0",
61
61
  "@microsoft/api-extractor": "^7.34.4",
62
62
  "@types/diff": "^3.5.1",
63
63
  "@types/mocha": "^9.1.1",
@@ -78,20 +78,14 @@
78
78
  "typescript": "~4.5.5"
79
79
  },
80
80
  "typeValidation": {
81
- "broken": {
82
- "InterfaceDeclaration_MergeTreeRevertibleDriver": {
83
- "backCompat": false
84
- }
85
- }
81
+ "broken": {}
86
82
  },
87
83
  "scripts": {
88
- "build": "concurrently npm:build:compile npm:lint && npm run build:docs",
89
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
90
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
84
+ "build": "fluid-build . --task build",
85
+ "build:commonjs": "fluid-build . --task commonjs",
86
+ "build:compile": "fluid-build . --task compile",
91
87
  "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
92
88
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
93
- "build:full": "npm run build",
94
- "build:full:compile": "npm run build:compile",
95
89
  "build:test": "tsc --project ./src/test/tsconfig.json",
96
90
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
97
91
  "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
@@ -600,7 +600,7 @@ export class RedBlackTree<TKey, TData> implements SortedDictionary<TKey, TData>
600
600
  start?: TKey,
601
601
  end?: TKey,
602
602
  ) {
603
- this.nodeMap(this.root, action, start, end);
603
+ this.nodeMap(this.root, action, accum, start, end);
604
604
  }
605
605
 
606
606
  public map<TAccum>(action: PropertyAction<TKey, TData>, accum?: TAccum) {