Struct Cache

Source
pub struct Cache<T> {
    pub points1: FnvHashMap<usize, Option<T>>,
    pub points2: FnvHashMap<usize, Option<[T; 2]>>,
    pub points3: FnvHashMap<usize, Option<[T; 3]>>,
    pub points4: FnvHashMap<usize, Option<[T; 4]>>,
}
Expand description

Used to store temporary values of shared functions to speed up computation. By default, all function outputs that are referenced more than once are cached. To signal that some function output should be cached, None is stored in a hash map. When performing the first computation of that output, Some(value) is stored in the cache.

Fields§

§points1: FnvHashMap<usize, Option<T>>

Stores temporary values of scalars.

§points2: FnvHashMap<usize, Option<[T; 2]>>

Stores temporary values of 2D vectors.

§points3: FnvHashMap<usize, Option<[T; 3]>>

Stores temporary values of 3D vectors.

§points4: FnvHashMap<usize, Option<[T; 4]>>

Stores temporary values of 4D vectors.

Implementations§

Source§

impl<T> Cache<T>

Source

pub fn new(doc: &Reactor<T>) -> Cache<T>
where T: Copy,

Creates a new cache for a document.

Analyzes the graph to find function outputs that are referenced more than once.

If new data and functions are added after the cache is created, then these will not be automatically cached, but the behavior should be the same.

Source

pub fn clear(&mut self)

Reset cache such that new temporary values can be calculated.

Auto Trait Implementations§

§

impl<T> Freeze for Cache<T>

§

impl<T> RefUnwindSafe for Cache<T>
where T: RefUnwindSafe,

§

impl<T> Send for Cache<T>
where T: Send,

§

impl<T> Sync for Cache<T>
where T: Sync,

§

impl<T> Unpin for Cache<T>
where T: Unpin,

§

impl<T> UnwindSafe for Cache<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.