[−][src]Struct red_memo::Memoizer
Memoization cache for a recursive user function
Methods
impl<'a, K: 'a + Clone + Debug, V: 'a + Clone + Debug> Memoizer<'a, K, V>
[src]
pub fn new_hash<F>(user: F) -> Self where
K: Hash + Eq,
F: 'a + Fn(&mut Memoizer<K, V>, &K) -> V,
[src]
K: Hash + Eq,
F: 'a + Fn(&mut Memoizer<K, V>, &K) -> V,
Creates a Memoizer based on HashMap.
pub fn new_ord<F>(user: F) -> Self where
K: Ord,
F: 'a + Fn(&mut Memoizer<K, V>, &K) -> V,
[src]
K: Ord,
F: 'a + Fn(&mut Memoizer<K, V>, &K) -> V,
Creates a Memoizer based on a BTreeMap.
pub fn lookup(&mut self, k: &K) -> V
[src]
Looks up a key in the cache, calculating a value if necessary.
Panics
This method will panic if a circular dependency is detected.
Before the Memoizer starts calculating a value for a particular key, it places an
"in-progress" marker in the cache for that key. After that key's value is caculated, the
"in-progress" marker is replaced with the finished value. If an in-progress key is passed
to lookup()
, this indicates a circular dependency.
pub fn lookup_immut(&self, k: &K) -> Option<V>
[src]
Look up a key in the cache, but do not calculate it if it is not present.
Trait Implementations
Auto Trait Implementations
impl<'a, K, V> !Send for Memoizer<'a, K, V>
impl<'a, K, V> Unpin for Memoizer<'a, K, V>
impl<'a, K, V> !Sync for Memoizer<'a, K, V>
impl<'a, K, V> !UnwindSafe for Memoizer<'a, K, V>
impl<'a, K, V> !RefUnwindSafe for Memoizer<'a, K, V>
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,