File tree Expand file tree Collapse file tree 1 file changed +8
-44
lines changed Expand file tree Collapse file tree 1 file changed +8
-44
lines changed Original file line number Diff line number Diff line change 1
- // The implementation doesn't work properly!
2
- // Most of the operations are still buggy, not properly implemented.
3
1
( function ( exports ) {
4
2
'use strict' ;
5
3
176
174
// Adjust the max value
177
175
var p = node . parentNode ;
178
176
if ( p ) {
179
- var maxNode = this . findMax ( p ) ;
180
- if ( maxNode . interval [ 1 ] > p . max ) {
181
- var max = maxNode . interval [ 1 ] ;
182
- while ( maxNode ) {
183
- if ( max > maxNode . max && maxNode . max === node . interval [ 1 ] ) {
184
- maxNode . max = max ;
185
- maxNode = maxNode . parentNode ;
186
- } else {
187
- maxNode = false ;
188
- }
177
+ var maxNode = this . findMax ( p ) ,
178
+ max = maxNode . interval [ 1 ] ;
179
+ while ( maxNode ) {
180
+ if ( maxNode . max === node . interval [ 1 ] ) {
181
+ maxNode . max = max ;
182
+ maxNode = maxNode . parentNode ;
183
+ } else {
184
+ maxNode = false ;
189
185
}
190
186
}
191
187
}
204
200
exports . IntervalTree = IntervalTree ;
205
201
206
202
} ( typeof exports === 'undefined' ? window : exports ) ) ;
207
-
208
- var IntervalTree = exports . IntervalTree ;
209
-
210
- var t = new IntervalTree ( ) ;
211
-
212
- t . add ( [ 1 , 2 ] ) ;
213
- t . add ( [ - 1 , 8 ] ) ;
214
- // t.add([-1, 18]);
215
- // t.add([2, 4]);
216
- // t.add([8, 13]);
217
- // t.add([2, 10]);
218
- // t.add([-2, 10]);
219
- // t.add([-4, 15]);
220
- // t.add([-6, 15]);
221
-
222
- // t.remove([1, 2]);
223
- // t.remove([-1, 8]);
224
- // t.remove([-1, 18]);
225
- // t.remove([2, 4]);
226
- // t.remove([8, 13]);
227
- // t.remove([2, 10]);
228
- // t.remove([-2, 10]);
229
- // t.remove([-4, 15]);
230
- // t.remove([-6, 15]);
231
-
232
- console . log ( t . height ( ) ) ;
233
- console . log ( t . root ) ;
234
-
235
- //console.log(t.intersects([19, 29]));
236
- //console.log(t.contains(16));
237
-
238
- console . log ( 'Height:' , t . height ( ) ) ;
You can’t perform that action at this time.
0 commit comments