fn generate(&self, iteration: u64) -> Vec<A> {
        {
            let cache = self.iteration_cache.borrow_mut();
            if let Some(val) = cache.get(iteration as usize) {
                log::debug!("found {}", iteration);
                return val.clone();
            }
        } // end borrow of the cache
        {
            log::debug!("generating {}", iteration);
            let curr = match iteration {
                0 => self.system.initial(), // terminating case
                _ => {
                    let last = self.generate(iteration - 1);
                    self.system.generate_next_iteration(&last)
                }
            };
            let mut cache = self.iteration_cache.borrow_mut();
            cache.push(curr);
        } // end borrow of the cache
          // Now that we have cached, try again (which should use the cache)
        self.generate(iteration)
    }
/// Reimplement to to use caching. Currently using recursion.
Reimplement to to use caching. Currently using recursion.
Reimplement to to use caching . Currently using recursion .
fn generate(&self, iteration: u64) -> Vec<A> {
        {
            let cache = self.iteration_cache.borrow_mut();
            if let Some(val) = cache.get(iteration as usize) {
                log::debug!("found {}", iteration);
                return val.clone();
            }
        } // end borrow of the cache
        {
            log::debug!("generating {}", iteration);
            let curr = match iteration {
                0 => self.system.initial(), // terminating case
                _ => {
                    let last = self.generate(iteration - 1);
                    self.system.generate_next_iteration(&last)
                }
            };
            let mut cache = self.iteration_cache.borrow_mut();
            cache.push(curr);
        } // end borrow of the cache
          // Now that we have cached, try again (which should use the cache)
        self.generate(iteration)
    }
fn generate ( & self , iteration : u64 ) -> Vec < A > { { let cache = self . iteration_cache . borrow_mut ( ) ; if let Some ( val ) = cache . get ( iteration as usize ) { log :: debug ! ( " " iteration ) ; return val . clone ( ) ; } } // end borrow of the cache { log :: debug ! ( " " iteration ) ; let curr = match iteration { 0 => self . system . initial ( ) , // terminating case _ => { let last = self . generate ( iteration - 1 ) ; self . system . generate_next_iteration ( & last ) } } ; let mut cache = self . iteration_cache . borrow_mut ( ) ; cache . push ( curr ) ; } // end borrow of the cache // Now that we have cached, try again (which should use the cache) self . generate ( iteration ) }
Reimplement to to use caching.
Reimplement to to use caching .
&self
iteration
u64