Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Last active March 21, 2022 04:32
Show Gist options
  • Select an option

  • Save jayhuang75/6538e7941dc61a7e50545203928e80a2 to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/6538e7941dc61a7e50545203928e80a2 to your computer and use it in GitHub Desktop.
lfu_used
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