[][src]Struct hashlink::lru_cache::LruCache

pub struct LruCache<K, V, S = DefaultHashBuilder> { /* fields omitted */ }

Implementations

impl<K: Eq + Hash, V> LruCache<K, V>[src]

pub fn new(capacity: usize) -> Self[src]

pub fn new_unbounded() -> Self[src]

Create a new unbounded LruCache that does not automatically evict entries.

A simple convenience method that is equivalent to LruCache::new(usize::MAX)

impl<K: Eq + Hash, V, S> LruCache<K, V, S> where
    S: BuildHasher
[src]

pub fn with_hasher(capacity: usize, hash_builder: S) -> Self[src]

pub fn contains_key<Q: ?Sized>(&mut self, key: &Q) -> bool where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

pub fn insert(&mut self, k: K, v: V) -> Option<V>[src]

Insert a new value into the LruCache.

If necessary, will remove the value at the front of the LRU list to make room.

pub fn peek<Q: ?Sized>(&self, k: &Q) -> Option<&V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Get the value for the given key, without marking the value as recently used and moving it to the back of the LRU list.

pub fn peek_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Get the value for the given key mutably, without marking the value as recently used and moving it to the back of the LRU list.

pub fn get<Q: ?Sized>(&mut self, k: &Q) -> Option<&V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Retrieve the given key, marking it as recently used and moving it to the back of the LRU list.

pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

Retrieve the given key, marking it as recently used and moving it to the back of the LRU list.

pub fn entry(&mut self, key: K) -> Entry<K, V, S>[src]

If the returned entry is vacant, it will always have room to insert a single value. By using the entry API, you can exceed the configured capacity by 1.

The returned entry is not automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

pub fn raw_entry(&self) -> RawEntryBuilder<K, V, S>[src]

The constructed raw entry is never automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

pub fn raw_entry_mut(&mut self) -> RawEntryBuilderMut<K, V, S>[src]

If the constructed raw entry is vacant, it will always have room to insert a single value. By using the raw entry API, you can exceed the configured capacity by 1.

The constructed raw entry is never automatically moved to the back of the LRU list. By calling Entry::to_back / Entry::to_front you can manually control the position of this entry in the LRU list.

pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)> where
    K: Borrow<Q>,
    Q: Hash + Eq
[src]

pub fn capacity(&self) -> usize[src]

pub fn set_capacity(&mut self, capacity: usize)[src]

Set the new cache capacity for the LruCache.

If there are more entries in the LruCache than the new capacity will allow, they are removed.

pub fn remove_lru(&mut self) -> Option<(K, V)>[src]

Remove the least recently used entry and return it.

If the LruCache is empty this will return None.

pub fn len(&self) -> usize[src]

pub fn is_empty(&self) -> bool[src]

pub fn clear(&mut self)[src]

pub fn iter(&self) -> Iter<K, V>[src]

pub fn iter_mut(&mut self) -> IterMut<K, V>[src]

pub fn drain(&mut self) -> Drain<K, V>[src]

Trait Implementations

impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher + Clone> Clone for LruCache<K, V, S>[src]

impl<K: Eq + Hash, V, S: BuildHasher> Extend<(K, V)> for LruCache<K, V, S>[src]

impl<K: Eq + Hash, V, S: BuildHasher> IntoIterator for LruCache<K, V, S>[src]

type Item = (K, V)

The type of the elements being iterated over.

type IntoIter = IntoIter<K, V>

Which kind of iterator are we turning this into?

impl<'a, K: Eq + Hash, V, S: BuildHasher> IntoIterator for &'a LruCache<K, V, S>[src]

type Item = (&'a K, &'a V)

The type of the elements being iterated over.

type IntoIter = Iter<'a, K, V>

Which kind of iterator are we turning this into?

impl<'a, K: Eq + Hash, V, S: BuildHasher> IntoIterator for &'a mut LruCache<K, V, S>[src]

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.

type IntoIter = IterMut<'a, K, V>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<K, V, S> RefUnwindSafe for LruCache<K, V, S> where
    K: RefUnwindSafe,
    S: RefUnwindSafe,
    V: RefUnwindSafe

impl<K, V, S> Send for LruCache<K, V, S> where
    K: Send,
    S: Send,
    V: Send

impl<K, V, S> Sync for LruCache<K, V, S> where
    K: Sync,
    S: Sync,
    V: Sync

impl<K, V, S> Unpin for LruCache<K, V, S> where
    S: Unpin

impl<K, V, S> UnwindSafe for LruCache<K, V, S> where
    K: RefUnwindSafe,
    S: UnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.