intervalTree.ts ×9

Frontier kind: Code frontier

unlabeled · c_5afd903bf210

34 tests · 5345 LOC · 21 files · introduces 0 tests · 38 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges38 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
566 ranges5345 lines · 21 files · Browse complete extent
All tests (intent)
34 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 38 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/intervalTree.ts 38 introduced LOC · 9 ranges

Open complete file

80
81 export function getNodeColor(node: IntervalNode): NodeColor {
82 > return ((node.metadata & Constants.ColorMask) >>> Constants.ColorOffset); intervalTree.ts
83 > }
84 function setNodeColor(node: IntervalNode, color: NodeColor): void {
85 node.metadata = (
878 return T.root;
879 }
881 > treeInsert(T, newNode);
882 >
883 > recomputeMaxEndWalkToRoot(newNode.parent);
884 >
885 > // repair tree
886 > let x = newNode;
887 while (x !== T.root && getNodeColor(x.parent) === NodeColor.Red) {
888 if (x.parent === x.parent.parent.left) {
922 }
923 }
925 > setNodeColor(T.root, NodeColor.Black);
926 >
927 > return newNode;
928 > }
929
930 > function treeInsert(T: IntervalTree, z: IntervalNode): void { intervalTree.ts
931 > let delta: number = 0;
932 > let x = T.root;
933 > const zAbsoluteStart = z.start;
934 > const zAbsoluteEnd = z.end;
935 > while (true) {
936 > const cmp = intervalCompare(zAbsoluteStart, zAbsoluteEnd, x.start + delta, x.end + delta);
937 > if (cmp < 0) {
938 // this node should be inserted to the left
939 // => it is not affected by the node's delta
947 x = x.left;
948 }
949 > } else { intervalTree.ts
950 // this node should be inserted to the right
951 // => it is not affected by the node's delta
961 }
962 }
963 > } intervalTree.ts
964 >
965 > z.parent = x;
966 > z.left = SENTINEL;
967 > z.right = SENTINEL;
968 > setNodeColor(z, NodeColor.Red);
969 > }
970 //#endregion
971
1255 }
1256
1257 > function recomputeMaxEndWalkToRoot(node: IntervalNode): void { intervalTree.ts
1258 > while (node !== SENTINEL) {
1259 >
1260 > const maxEnd = computeMaxEnd(node);
1261 >
1262 > if (node.maxEnd === maxEnd) {
1263 // no need to go further
1264 return;
1268 node = node.parent;
1269 }
1270 > } intervalTree.ts
1271
1272 //#endregion
1274 //#region utils
1275 export function intervalCompare(aStart: number, aEnd: number, bStart: number, bEnd: number): number {
1276 > if (aStart === bStart) { intervalTree.ts
1277 return aEnd - bEnd;
1278 }