Skip to main content

ApplyCache

Trait ApplyCache 

Source
pub trait ApplyCache<M: Manager, O: Copy>: DropWith<M::Edge> {
    // Required methods
    fn get_extended<const E: usize, const N: usize>(
        &self,
        manager: &M,
        operator: O,
        operands: (&[Borrowed<'_, M::Edge>], &[u32]),
    ) -> Option<([M::Edge; E], [u32; N])>;
    fn add_extended(
        &self,
        manager: &M,
        operator: O,
        operands: (&[Borrowed<'_, M::Edge>], &[u32]),
        values: (&[Borrowed<'_, M::Edge>], &[u32]),
    );
    fn clear(&self, manager: &M);

    // Provided methods
    fn get(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
    ) -> Option<M::Edge> { ... }
    fn add(
        &self,
        manager: &M,
        operator: O,
        operands: &[Borrowed<'_, M::Edge>],
        value: Borrowed<'_, M::Edge>,
    ) { ... }
}
Expand description

Cache for the result of apply operations

This trait provides methods to add computation results to the apply cache and to query the cache for these results. Just as every cache, the implementation may decide to evict results from the cache.

Required Methods§

Source

fn get_extended<const E: usize, const N: usize>( &self, manager: &M, operator: O, operands: (&[Borrowed<'_, M::Edge>], &[u32]), ) -> Option<([M::Edge; E], [u32; N])>

Get the result for the key consisting of operand and operator, if cached

This is the extended version of Self::get(), allowing for numeric operands and multiple, possibly numeric values. The constants E and N indicate the number of expected edge values and numeric values, respectively.

Source

fn add_extended( &self, manager: &M, operator: O, operands: (&[Borrowed<'_, M::Edge>], &[u32]), values: (&[Borrowed<'_, M::Edge>], &[u32]), )

Add the result of operation to this cache

An implementation is free to not cache any result. (This is why we use Borrowed<M::Edge>, which in this case elides a few clone and drop operations.) If the cache already contains the key consisting of operator and operands, there is no need to update its value. (Again, an implementation could elide clone and drop operations.)

Source

fn clear(&self, manager: &M)

Remove all entries from the cache

Provided Methods§

Source

fn get( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], ) -> Option<M::Edge>

Shorthand for Self::get_extended() without numeric operands and just a single edge value

Source

fn add( &self, manager: &M, operator: O, operands: &[Borrowed<'_, M::Edge>], value: Borrowed<'_, M::Edge>, )

Shorthand for Self::add_extended() without numeric operands and just a single edge value

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§