public double get ( double index ) { ListIterator < Bucket > b = buckets_ . listIterator ( 0 ) ; ListIterator < Bucket > e = buckets_ . listIterator ( buckets_ . size ( ) ) ; while ( b . nextIndex ( ) < e . previousIndex ( ) ) { final ListIterator < Bucket > mid = buckets_ . listIterator ( b . nextIndex ( ) / 2 + e . nextIndex ( ) / 2 ) ; final Bucket mid_bucket = mid . next ( ) ; mid . previous ( ) ; // Undo position change made by mid.next(). if ( mid_bucket . getRunningEventsCount ( ) == index && mid . nextIndex ( ) >= e . previousIndex ( ) ) { return mid_bucket . getRange ( ) . getCeil ( ) ; } else if ( mid_bucket . getRunningEventsCount ( ) <= index ) { b = mid ; b . next ( ) ; } else if ( mid_bucket . getRunningEventsCount ( ) - mid_bucket . getEvents ( ) > index ) { e = mid ; } else { b = mid ; break ; } } final Bucket bucket = b . next ( ) ; b . previous ( ) ; // Undo position change made by b.next(). final double low = bucket . getRunningEventsCount ( ) - bucket . getEvents ( ) ; final double off = index - low ; final double left_fraction = off / bucket . getEvents ( ) ; final double right_fraction = 1 - left_fraction ; return bucket . getRange ( ) . getCeil ( ) * left_fraction + bucket . getRange ( ) . getFloor ( ) * right_fraction ; }
Get the value at a given position .