Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Created March 21, 2022 03:41
Show Gist options
  • Select an option

  • Save jayhuang75/43a0cef82e553c55e71dde19a64baa78 to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/43a0cef82e553c55e71dde19a64baa78 to your computer and use it in GitHub Desktop.
lfu_other
// current cache length
pub fn len(&self) -> usize {
self.by_key.len()
}
// check if current cache is empty
pub fn is_empty(&self) -> bool {
self.by_key.is_empty()
}
// current cache capacity
pub fn capacity(&self) -> usize {
self.capacity
}
// clean up the cache
pub fn clear(&mut self) {
self.by_key.clear();
self.freq_node.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment