avatar
w*o
1
今天的电面挂了,有道题真不知道怎么回答
If you need to design some cache. Usually you implement it with hashtable.
But what if you have some item which was not used for long time, you want
to delete it from cache when you add more items. What data structure will
you use ? In other words, if you want to delete those items not used often
but keep
those accessed often. What's the best data structure to do it ?
avatar
m*n
2
是不是只有写着multi touch 的才是触摸屏?
一般的写着FHD QHD的都是非触摸的?
avatar
e*l
3
Linked List吧,把每次访问的元素都移到头部,可以加上Hashtable来快速查找
avatar
f*o
4
没写touch就没有

【在 m********n 的大作中提到】
: 是不是只有写着multi touch 的才是触摸屏?
: 一般的写着FHD QHD的都是非触摸的?

avatar
n*w
5
DLL + Hashtable
多次看到帖子说是业界标准。

often

【在 w***o 的大作中提到】
: 今天的电面挂了,有道题真不知道怎么回答
: If you need to design some cache. Usually you implement it with hashtable.
: But what if you have some item which was not used for long time, you want
: to delete it from cache when you add more items. What data structure will
: you use ? In other words, if you want to delete those items not used often
: but keep
: those accessed often. What's the best data structure to do it ?

avatar
d*t
6
what's DLL?

【在 n*******w 的大作中提到】
: DLL + Hashtable
: 多次看到帖子说是业界标准。
:
: often

avatar
A*u
7
呵呵 double linked list?

【在 d********t 的大作中提到】
: what's DLL?
avatar
w*o
8
DLL是double ended 还是doubly linked list ?
avatar
w*x
9
consistent hashing, just use a sorted linked list
avatar
r*4
10
Why ddl?
avatar
c*p
12
链表实现LRU。
如果你看过SimpleScalar里面的相关代码,
这个问题就很好回答。。。

often

【在 w***o 的大作中提到】
: 今天的电面挂了,有道题真不知道怎么回答
: If you need to design some cache. Usually you implement it with hashtable.
: But what if you have some item which was not used for long time, you want
: to delete it from cache when you add more items. What data structure will
: you use ? In other words, if you want to delete those items not used often
: but keep
: those accessed often. What's the best data structure to do it ?

avatar
r*4
13
Got it. Thanks.
Played with java a little bit.
========================================
import java.util.LinkedHashMap;
import java.util.Map;
public class cache{
//Implement Cache using DS
public static void main(String[] args) {
mycache testCache = new mycache();
testCache.put(1, "a");
testCache.put(3, "c");
testCache.put(2, "b");
System.out.println(testCache);
testCache.put(4, "d");
System.out.println(testCache);
testCache.put(5, "e");
System.out.println(testCache);
}
}
class mycache extends LinkedHashMap{
private static final int MAX_ENTRIES = 3;
protected boolean removeEldestEntry(Map.Entry eldest) {//It is called
whenever LinkedHashMap.put() is called.
System.out.print("Removed From Cache: ");
System.out.println(eldest);
return size() > MAX_ENTRIES;
}


}
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。