LruHashSet

Struct LruHashSet 

Source
pub struct LruHashSet<K> { /* private fields */ }
Expand description

A LRU HashSet implementation

Implementations§

Source§

impl<K> LruHashSet<K>
where K: Hash + Eq,

Source

pub fn with_max_entries(max_entries: usize) -> Self

Creates a new LruHashSet with a given number of entries

Source

pub fn get(&mut self, k: &K) -> Option<Rc<K>>

Returns a reference to the value in the set, if any, that is equal to the given value.

Source

pub fn iter(&mut self) -> Iter<'_, K>

Returns an iterator over the values within the set

§Warning

Iterating does not modify the order of the LRU to prevent any unwanted side effects due.

Source

pub fn contains(&mut self, k: &K) -> bool

Returns true if there is an element is in the set

Source

pub fn insert(&mut self, k: K) -> bool

Adds a value to the set.

Returns whether the value was newly inserted. That is:

  • If the set did not previously contain this value, true is returned.
  • If the set already contained this value, false is returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.
Source

pub fn remove(&mut self, k: &K) -> bool

Removes an entry from the LruHashSet and returns true if the entry was removed else false

Source

pub fn len(&self) -> usize

Returns the length of the LruHashSet

Source

pub fn cap(&self) -> usize

Returns the capacity of the LruHashSet

Source

pub fn is_empty(&self) -> bool

Returns true if the LruHashSet is empty

Source

pub fn is_full(&self) -> bool

Returns true if the LruHashSet is full

Auto Trait Implementations§

§

impl<K> Freeze for LruHashSet<K>

§

impl<K> !RefUnwindSafe for LruHashSet<K>

§

impl<K> !Send for LruHashSet<K>

§

impl<K> !Sync for LruHashSet<K>

§

impl<K> Unpin for LruHashSet<K>

§

impl<K> !UnwindSafe for LruHashSet<K>

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.