pub struct LruHashSet<K> { /* private fields */ }Expand description
A LRU HashSet implementation
Implementations§
Source§impl<K> LruHashSet<K>
impl<K> LruHashSet<K>
Sourcepub fn with_max_entries(max_entries: usize) -> Self
pub fn with_max_entries(max_entries: usize) -> Self
Creates a new LruHashSet with a given number of entries
Sourcepub fn get(&mut self, k: &K) -> Option<Rc<K>>
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.
Sourcepub fn iter(&mut self) -> Iter<'_, K> ⓘ
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.
Sourcepub fn insert(&mut self, k: K) -> bool
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,
trueis returned. - If the set already contained this value,
falseis returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more