Redian新闻
>
什么台灯好?能保护眼睛?
avatar
什么台灯好?能保护眼睛?# Parenting - 为人父母
Y*B
1
How to use Double Linked List and Hashmap to implement a LRU cache?
avatar
d*h
2
rt
avatar
s*n
3
1. when you want to get one item, say Ai, check hash if it is in the cache.
a. yes, get the address, and move the node to the last.
b. no, remove the recent one and put it in the cache and address in hash
2. double linked is easy to to remove from middle.
avatar
y*i
4
CO 求推荐

【在 d********h 的大作中提到】
: rt
avatar
Y*B
5
thanks
how to construct the data structure?
avatar
h*t
6
three!
avatar
w*x
7
Use bit map to map key and memory so it can locate the memory in O(1)
Use double linked list to implement a cycle queue (I'd like to choose an
array), if the queue is full, newly queried key will erase the earliest key.
You need to maintain both hash map and cycle queue at the same time as new
query comes.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。