@@ -20,9 +20,18 @@ class MKAverage {
20
20
if ( this . queue . length === this . m ) {
21
21
const willBeDelete : number = this . queue [ 0 ] ;
22
22
this . queue . shift ( ) ;
23
-
23
+ console . log ( "deleteElement" , willBeDelete ) ;
24
24
this . total -= willBeDelete ;
25
25
this . tree . remove ( willBeDelete ) ;
26
+ const root = this . tree . getRoot ( ) ;
27
+ if ( ! root ) throw Error ( "null root" ) ;
28
+ {
29
+ const temp : [ number , number ] [ ] = [ ] ;
30
+ for ( const node of InOrderIterator ( root ) ) {
31
+ temp . push ( [ node . value , node . count ] ) ;
32
+ }
33
+ console . log ( JSON . stringify ( temp ) ) ;
34
+ }
26
35
}
27
36
28
37
this . queue . push ( num ) ;
@@ -31,6 +40,7 @@ class MKAverage {
31
40
this . total += num ;
32
41
this . count ++ ;
33
42
// debugger;
43
+ console . log ( "addElement" , num ) ;
34
44
const root = this . tree . getRoot ( ) ;
35
45
if ( ! root ) throw Error ( "null root" ) ;
36
46
{
@@ -48,14 +58,14 @@ class MKAverage {
48
58
let ret = this . total ;
49
59
const root = this . tree . getRoot ( ) ;
50
60
if ( ! root ) throw Error ( "null root" ) ;
61
+ console . log ( "calculateMKAverage" ) ;
51
62
{
52
63
const temp : [ number , number ] [ ] = [ ] ;
53
64
for ( const node of InOrderIterator ( root ) ) {
54
65
temp . push ( [ node . value , node . count ] ) ;
55
66
}
56
67
console . log ( JSON . stringify ( temp ) ) ;
57
68
}
58
-
59
69
60
70
// console.log(root)
61
71
let k = this . k ;
0 commit comments