mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +08:00
@@ -15,19 +15,19 @@ class LFUCacheTest {
|
||||
lfuCache.put(4, 40);
|
||||
lfuCache.put(5, 50);
|
||||
|
||||
//get method call will increase frequency of key 1 by 1
|
||||
// get method call will increase frequency of key 1 by 1
|
||||
assertEquals(10, lfuCache.get(1));
|
||||
|
||||
//this operation will remove value with key as 2
|
||||
// this operation will remove value with key as 2
|
||||
lfuCache.put(6, 60);
|
||||
|
||||
//will return null as value with key 2 is now evicted
|
||||
// will return null as value with key 2 is now evicted
|
||||
assertEquals(null, lfuCache.get(2));
|
||||
|
||||
//should return 60
|
||||
// should return 60
|
||||
assertEquals(60, lfuCache.get(6));
|
||||
|
||||
//this operation will remove value with key as 3
|
||||
// this operation will remove value with key as 3
|
||||
lfuCache.put(7, 70);
|
||||
|
||||
assertEquals(null, lfuCache.get(2));
|
||||
@@ -43,19 +43,19 @@ class LFUCacheTest {
|
||||
lfuCache.put(4, "Delta");
|
||||
lfuCache.put(5, "Eplison");
|
||||
|
||||
//get method call will increase frequency of key 1 by 1
|
||||
// get method call will increase frequency of key 1 by 1
|
||||
assertEquals("Alpha", lfuCache.get(1));
|
||||
|
||||
//this operation will remove value with key as 2
|
||||
// this operation will remove value with key as 2
|
||||
lfuCache.put(6, "Digamma");
|
||||
|
||||
//will return null as value with key 2 is now evicted
|
||||
// will return null as value with key 2 is now evicted
|
||||
assertEquals(null, lfuCache.get(2));
|
||||
|
||||
//should return string Digamma
|
||||
// should return string Digamma
|
||||
assertEquals("Digamma", lfuCache.get(6));
|
||||
|
||||
//this operation will remove value with key as 3
|
||||
// this operation will remove value with key as 3
|
||||
lfuCache.put(7, "Zeta");
|
||||
|
||||
assertEquals(null, lfuCache.get(2));
|
||||
|
||||
Reference in New Issue
Block a user