Last active
March 21, 2022 04:32
-
-
Save jayhuang75/6538e7941dc61a7e50545203928e80a2 to your computer and use it in GitHub Desktop.
lfu_used
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
| let mut tu = TinyUrl::new(); | |
| let url = "http://hotmail.com"; | |
| let key = tu.set(url); | |
| let url_2 = "http://google.com"; | |
| let t key_2 = tu.set(url); | |
| let url_3 = "http://linkedin.com"; | |
| let key_3 = tu.set(url); | |
| type MyCache<'a> = LFUCache<'a, &'a str, 2>; | |
| let mut my_cache = MyCache::default(); | |
| my_cache.set(&key, url); | |
| my_cache.set(&key_2, url_2); | |
| my_cache.set(&key_3, url_3); | |
| my_cache.get(&key_2).unwrap(); | |
| my_cache.get(&key_2).unwrap(); | |
| my_cache.get(&key_2).unwrap(); | |
| println!("orignal url : {:?}", my_cache); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment