Skip to content

Instantly share code, notes, and snippets.

@codinko
Created May 1, 2021 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codinko/09f4052e2178a1dbebbabe4d99a4778b to your computer and use it in GitHub Desktop.
Save codinko/09f4052e2178a1dbebbabe4d99a4778b to your computer and use it in GitHub Desktop.
LRU Cache Java implementation Using Custom created Double linked List and Hashmap - OUTPUT
jdk1.8.0_231
{1=key = 1 | value = mango | leftValue = mango | rightValue = null}
******************************************************
{1=key = 1 | value = mango | leftValue = apple | rightValue = null,
2=key = 2 | value = apple | leftValue = null | rightValue = mango}
******************************************************
{1=key = 1 | value = mango | leftValue = apple | rightValue = null,
2=key = 2 | value = apple | leftValue = orange | rightValue = mango,
3=key = 3 | value = orange | leftValue = null | rightValue = apple}
******************************************************
{1=key = 1 | value = mango | leftValue = apple | rightValue = null,
2=key = 2 | value = apple | leftValue = orange | rightValue = mango,
3=key = 3 | value = orange | leftValue = null | rightValue = apple}
LRU item is key = 1 | value = mango | leftValue = apple | rightValue = null
MRU item is key = 3 | value = orange | leftValue = null | rightValue = apple
******************************************************
{4=key = 4 | value = strawberry | leftValue = kiwi | rightValue = null,
5=key = 5 | value = kiwi | leftValue = blueberry | rightValue = strawberry,
6=key = 6 | value = blueberry | leftValue = null | rightValue = kiwi}
LRU item is key = 4 | value = strawberry | leftValue = kiwi | rightValue = null
MRU item is key = 6 | value = blueberry | leftValue = null | rightValue = kiwi
strawberry
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment