Skip to content

Commit 4bdee45

Browse files
committed
Update MultiRedBlackTree.ts
1 parent bde18ef commit 4bdee45

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

finding-mk-average/MultiRedBlackTree.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import { Direction } from "https://deno.land/std@0.173.0/collections/binary_sear
33
import { RedBlackNode } from "https://deno.land/std@0.173.0/collections/red_black_node.ts";
44
import RedBlackTreeExtended from "../dinner-plate-stacks/RedBlackTree.ts";
55

6-
76
export class MultiRedBlackTree<T> extends RedBlackTreeExtended<T> {
87
hash: (v: T) => any;
98
constructor(
109
compare: (a: T, b: T) => number = ascend,
11-
hash: (v: T) => any = (v) => v
10+
hash: (v: T) => any = (v) => v,
1211
) {
1312
super(compare);
1413
this.hash = hash;
@@ -68,17 +67,18 @@ export class MultiRedBlackTree<T> extends RedBlackTreeExtended<T> {
6867
insertGetNode(value: T): RedBlackNode<T> | null {
6968
let node = this.insertNode(
7069
RedBlackNode,
71-
value
70+
value,
7271
) as RedBlackNode<T> | null;
7372
if (node) this.setCount(value, 1);
7473

7574
if (node) {
7675
while (node.parent?.red) {
7776
let parent: RedBlackNode<T> = node.parent!;
78-
const parentDirection: Direction =
79-
parent.directionFromParent()!;
80-
const uncleDirection: Direction =
81-
parentDirection === "right" ? "left" : "right";
77+
const parentDirection: Direction = parent
78+
.directionFromParent()!;
79+
const uncleDirection: Direction = parentDirection === "right"
80+
? "left"
81+
: "right";
8282
const uncle: RedBlackNode<T> | null =
8383
parent.parent![uncleDirection] ?? null;
8484

0 commit comments

Comments
 (0)