Tracker

Struct Tracker 

Source
pub struct Tracker<K, V: Trackable> { /* private fields */ }
Expand description

Flow tracker for types that have an intrinsic timestamp (via Trackable trait)

Implementations§

Source§

impl<K, V> Tracker<K, V>
where K: Eq + Hash + Clone, V: Trackable,

Source

pub fn new() -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

pub fn get_or_insert_with<F>(&mut self, key: &K, create: F) -> &mut V
where F: FnOnce() -> V,

Source

pub fn process_and_evict<F>(&mut self, process: F) -> usize
where F: FnMut(&K, &V) -> bool,

Evict entries based on a predicate function, in lru order

Source

pub fn front(&self) -> Option<(&K, &V)>

Get the front (oldest) entry without removing it

Source

pub fn back(&self) -> Option<(&K, &V)>

Get the back (newest) entry without removing it

Source

pub fn pop_front(&mut self) -> Option<(K, V)>

Remove and return the front (oldest) entry

Source

pub fn pop_back(&mut self) -> Option<(K, V)>

Remove and return the back (newest) entry

Source

pub fn remove(&mut self, key: &K) -> Option<V>

Remove a specific entry by key

Source

pub fn get_timestamp(&self, key: &K) -> Option<V::Timestamp>

Get the timestamp of an entry

Source

pub fn get(&self, key: &K) -> Option<&V>

Get a reference to the value

Source

pub fn get_mut(&mut self, key: &K) -> Option<&mut V>

Get a mutable reference to the value

Source

pub fn iter(&self) -> impl Iterator<Item = (&K, &V)>

Iterator over entries (from oldest to newest)

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>

Mutable iterator over entries (from oldest to newest)

Source

pub fn keys(&self) -> impl Iterator<Item = &K>

Iterator over keys (from oldest to newest)

Source

pub fn values(&self) -> impl Iterator<Item = &V>

Iterator over values (from oldest to newest)

Source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>

Mutable iterator over values (from oldest to newest)

Source

pub fn len(&self) -> usize

Number of entries

Source

pub fn is_empty(&self) -> bool

Check if empty

Auto Trait Implementations§

§

impl<K, V> Freeze for Tracker<K, V>

§

impl<K, V> RefUnwindSafe for Tracker<K, V>

§

impl<K, V> Send for Tracker<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Tracker<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Tracker<K, V>

§

impl<K, V> UnwindSafe for Tracker<K, V>

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.