pub struct LimitedCache<K: Clone + Hash + Eq, V> {
    map: HashMap<K, V>,
    oldest: VecDeque<K>,
}
Expand description

A HashMap-alike, which never gets larger than a specified capacity, and evicts the oldest insertion to maintain this.

The requested capacity may be rounded up by the underlying collections. This implementation uses all the allocated storage.

This is inefficient: it stores keys twice.

Fields§

§map: HashMap<K, V>§oldest: VecDeque<K>

Implementations§

Create a new LimitedCache with the given rough capacity.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The Resulting [TupleList], of an [Prepend::prepend()] call, including the prepended entry.
Prepend a value to this tuple, returning a new tuple with prepended value.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.