pub trait Replacement<V, C: Capacity> {
// Required method
fn choose_for_replacement<'a>(
&mut self,
candidates: impl ExactSizeIterator<Item = (usize, &'a V)>,
) -> usize
where V: 'a;
// Provided methods
fn on_hit(&self, value: &V) { ... }
fn on_insert(&self, value: &V) { ... }
}Expand description
Given that we need to replace a cache entry when inserting a new one, consider
each (index, entry) pair and return the index whose entry should be
replaced.
The given iterator will always be non-empty, and its indices will always be
within the capacity, assuming the Indices that this is paired with is
conformant.
Required Methods§
Sourcefn choose_for_replacement<'a>(
&mut self,
candidates: impl ExactSizeIterator<Item = (usize, &'a V)>,
) -> usizewhere
V: 'a,
fn choose_for_replacement<'a>(
&mut self,
candidates: impl ExactSizeIterator<Item = (usize, &'a V)>,
) -> usizewhere
V: 'a,
Choose which of the given cache entries will be replaced.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<V, C> Replacement<V, C> for LruReplacementwhere
C: Capacity,
V: LruTimestamp,
impl<V, C> Replacement<V, C> for RoundRobinReplacementwhere
C: Capacity,
impl<V, C, R> Replacement<V, C> for RandomReplacement<R>
Available on crate feature
rand only.