pub struct BudgetLru<K: Ord + Copy, V> {
map: BTreeMap<K, Slot<V>>,
order: BTreeMap<u64, K>,
clock: u64,
total: usize,
limits: Limits,
}Expand description
量の上限つきの、使った時が古い順に捨てる表。
Fields§
§map: BTreeMap<K, Slot<V>>§order: BTreeMap<u64, K>使った時 → 鍵。最初の物がいちばん古い。
clock: u64§total: usize§limits: LimitsImplementations§
Source§impl<K: Ord + Copy, V> BudgetLru<K, V>
impl<K: Ord + Copy, V> BudgetLru<K, V>
pub const fn new(limits: Limits) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
今入っている項目の量の合計(見積もり)。
pub fn limits(&self) -> Limits
fn next_clock(&mut self) -> u64
fn remove_slot(&mut self, key: &K) -> Option<Slot<V>>
Sourcefn evict_oldest(&mut self) -> Option<usize>
fn evict_oldest(&mut self) -> Option<usize>
いちばん古い項目を捨てる。捨てた量を返す。
Sourcepub fn insert(
&mut self,
key: K,
value: V,
bytes: usize,
group: u8,
) -> InsertOutcome
pub fn insert( &mut self, key: K, value: V, bytes: usize, group: u8, ) -> InsertOutcome
入れる。同じ鍵があれば置き換える。全体の量・項目の数の上限に収まるまで古い順に捨ててから入れる。
Auto Trait Implementations§
impl<K, V> Freeze for BudgetLru<K, V>
impl<K, V> RefUnwindSafe for BudgetLru<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for BudgetLru<K, V>
impl<K, V> Sync for BudgetLru<K, V>
impl<K, V> Unpin for BudgetLru<K, V>
impl<K, V> UnsafeUnpin for BudgetLru<K, V>
impl<K, V> UnwindSafe for BudgetLru<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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