Created
March 21, 2022 03:41
-
-
Save jayhuang75/43a0cef82e553c55e71dde19a64baa78 to your computer and use it in GitHub Desktop.
lfu_other
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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