fn recalculate(&mut self, insert_point: usize) {
        let index_of_first_bad_state =
            match self.states.binary_search_by_key(&insert_point, |(n, _)| *n) {
                Ok(n) => n + 1,
                Err(n) => n,
            };
        // delete all previous states after least_insert_point, add one so that if something exists
        // exactly at `least_insert_point` it is preserved.
        self.states.truncate(index_of_first_bad_state);
        let (mut applied_ops, mut state) = self.states.pop().unwrap();
        while applied_ops < self.ops.len() {
            if self.states.len() == 0
                || self.states.last().unwrap().0 + self.cache_gap <= applied_ops
            {
                // time to insert a new cache
                self.states.push((applied_ops, state.clone()));
            }
            self.ops[applied_ops].apply(&mut state);
            applied_ops += 1;
        }
        self.states.push((applied_ops, state));
    }
/// Recalculates states after the edit list has been changed. The first `insert_point`
/// ops should be identical to the last time `recalculate` was called.
Recalculates states after the edit list has been changed. The first `insert_point`
ops should be identical to the last time `recalculate` was called.
Recalculates states after the edit list has been changed . The first ` insert_point ` ops should be identical to the last time ` recalculate ` was called .
fn recalculate(&mut self, insert_point: usize) {
        let index_of_first_bad_state =
            match self.states.binary_search_by_key(&insert_point, |(n, _)| *n) {
                Ok(n) => n + 1,
                Err(n) => n,
            };
        // delete all previous states after least_insert_point, add one so that if something exists
        // exactly at `least_insert_point` it is preserved.
        self.states.truncate(index_of_first_bad_state);
        let (mut applied_ops, mut state) = self.states.pop().unwrap();
        while applied_ops < self.ops.len() {
            if self.states.len() == 0
                || self.states.last().unwrap().0 + self.cache_gap <= applied_ops
            {
                // time to insert a new cache
                self.states.push((applied_ops, state.clone()));
            }
            self.ops[applied_ops].apply(&mut state);
            applied_ops += 1;
        }
        self.states.push((applied_ops, state));
    }
fn recalculate ( & mut self , insert_point : usize ) { let index_of_first_bad_state = match self . states . binary_search_by_key ( & insert_point , | ( n , _ ) | * n ) { Ok ( n ) => n + 1 , Err ( n ) => n , } ; // delete all previous states after least_insert_point, add one so that if something exists // exactly at `least_insert_point` it is preserved. self . states . truncate ( index_of_first_bad_state ) ; let ( mut applied_ops , mut state ) = self . states . pop ( ) . unwrap ( ) ; while applied_ops < self . ops . len ( ) { if self . states . len ( ) == 0 || self . states . last ( ) . unwrap ( ) . 0 + self . cache_gap <= applied_ops { // time to insert a new cache self . states . push ( ( applied_ops , state . clone ( ) ) ) ; } self . ops [ applied_ops ] . apply ( & mut state ) ; applied_ops += 1 ; } self . states . push ( ( applied_ops , state ) ) ; }
Recalculates states after the edit list has been changed.
Recalculates states after the edit list has been changed .
&mut self
insert_point
usize