[−][src]Struct associative_cache::replacement::RandomReplacement
Choose a random cache entry to replace.
When considering n
items to potentially replace, choose one at random.
Requires the "rand"
feature to be enabled.
Methods
impl<R> RandomReplacement<R>
[src]
pub fn with_rng(rng: R) -> Self
[src]
Construct a RandomReplacement
with the given random number generator.
Example
use associative_cache::*; use rand::{rngs::StdRng, SeedableRng}; let rng = StdRng::seed_from_u64(42); let policy = RandomReplacement::with_rng(rng);
Trait Implementations
impl<V, C, R> Replacement<V, C> for RandomReplacement<R> where
C: Capacity,
R: Rng,
[src]
C: Capacity,
R: Rng,
fn choose_for_replacement<'a>(
&mut self,
candidates: impl Iterator<Item = (usize, &'a V)>
) -> usize where
V: 'a,
[src]
&mut self,
candidates: impl Iterator<Item = (usize, &'a V)>
) -> usize where
V: 'a,
fn on_hit(&self, value: &V)
[src]
fn on_insert(&self, value: &V)
[src]
impl<R: Clone> Clone for RandomReplacement<R>
[src]
fn clone(&self) -> RandomReplacement<R>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for RandomReplacement<StdRng>
[src]
impl<R: PartialOrd> PartialOrd<RandomReplacement<R>> for RandomReplacement<R>
[src]
fn partial_cmp(&self, other: &RandomReplacement<R>) -> Option<Ordering>
[src]
fn lt(&self, other: &RandomReplacement<R>) -> bool
[src]
fn le(&self, other: &RandomReplacement<R>) -> bool
[src]
fn gt(&self, other: &RandomReplacement<R>) -> bool
[src]
fn ge(&self, other: &RandomReplacement<R>) -> bool
[src]
impl<R: Eq> Eq for RandomReplacement<R>
[src]
impl<R: Ord> Ord for RandomReplacement<R>
[src]
fn cmp(&self, other: &RandomReplacement<R>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<R: PartialEq> PartialEq<RandomReplacement<R>> for RandomReplacement<R>
[src]
fn eq(&self, other: &RandomReplacement<R>) -> bool
[src]
fn ne(&self, other: &RandomReplacement<R>) -> bool
[src]
impl<R: Debug> Debug for RandomReplacement<R>
[src]
impl<R: Hash> Hash for RandomReplacement<R>
[src]
Auto Trait Implementations
impl<R> Send for RandomReplacement<R> where
R: Send,
R: Send,
impl<R> Sync for RandomReplacement<R> where
R: Sync,
R: Sync,
impl<R> Unpin for RandomReplacement<R> where
R: Unpin,
R: Unpin,
impl<R> RefUnwindSafe for RandomReplacement<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> UnwindSafe for RandomReplacement<R> where
R: UnwindSafe,
R: UnwindSafe,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,