@@ -3,12 +3,11 @@ import { Direction } from "https://deno.land/std@0.173.0/collections/binary_sear
3
3
import { RedBlackNode } from "https://deno.land/std@0.173.0/collections/red_black_node.ts" ;
4
4
import RedBlackTreeExtended from "../dinner-plate-stacks/RedBlackTree.ts" ;
5
5
6
-
7
6
export class MultiRedBlackTree < T > extends RedBlackTreeExtended < T > {
8
7
hash : ( v : T ) => any ;
9
8
constructor (
10
9
compare : ( a : T , b : T ) => number = ascend ,
11
- hash : ( v : T ) => any = ( v ) => v
10
+ hash : ( v : T ) => any = ( v ) => v ,
12
11
) {
13
12
super ( compare ) ;
14
13
this . hash = hash ;
@@ -68,17 +67,18 @@ export class MultiRedBlackTree<T> extends RedBlackTreeExtended<T> {
68
67
insertGetNode ( value : T ) : RedBlackNode < T > | null {
69
68
let node = this . insertNode (
70
69
RedBlackNode ,
71
- value
70
+ value ,
72
71
) as RedBlackNode < T > | null ;
73
72
if ( node ) this . setCount ( value , 1 ) ;
74
73
75
74
if ( node ) {
76
75
while ( node . parent ?. red ) {
77
76
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" ;
82
82
const uncle : RedBlackNode < T > | null =
83
83
parent . parent ! [ uncleDirection ] ?? null ;
84
84
0 commit comments