[][src]Trait fn_memo::unsync::Cache

pub trait Cache {
    type Arg;
    type Output;
    fn new() -> Self;
fn get(&self, arg: &Self::Arg) -> Option<&Self::Output>;
fn cache(&mut self, arg: Self::Arg, result: Self::Output);
fn clear(&mut self); }

The cache for single-thread memoization.

Associated Types

type Arg

type Output

Loading content...

Required methods

fn new() -> Self

Create an empty cache.

fn get(&self, arg: &Self::Arg) -> Option<&Self::Output>

Gets the cached result of arg. If it is not cached, returns None.

fn cache(&mut self, arg: Self::Arg, result: Self::Output)

Caches the arg with result.

fn clear(&mut self)

Clears the cache.

Loading content...

Implementations on Foreign Types

impl<Arg: Clone + Eq + Hash, Output: Clone> Cache for HashMap<Arg, Output>[src]

Use HashMap as Cache.

type Arg = Arg

type Output = Output

impl<Output: Clone> Cache for Vec<Option<Output>>[src]

Use Vec as Cache for sequences.

type Arg = usize

type Output = Output

Loading content...

Implementors

Loading content...