MCPcopy
hub / github.com/wangzheng0822/algo / offer

Method offer

java/06_linkedlist/LRUBasedArray.java:40–54  ·  view source on GitHub ↗

模拟访问某个值 @param object

(T object)

Source from the content-addressed store, hash-verified

38 * @param object
39 */
40 public void offer(T object) {
41 if (object == null) {
42 throw new IllegalArgumentException("该缓存容器不支持null!");
43 }
44 Integer index = holder.get(object);
45 if (index == null) {
46 if (isFull()) {
47 removeAndCache(object);
48 } else {
49 cache(object, count);
50 }
51 } else {
52 update(index);
53 }
54 }
55
56 /**
57 * 若缓存中有指定的值,则更新位置

Callers 3

testWithExceptionMethod · 0.95

Calls 5

isFullMethod · 0.95
removeAndCacheMethod · 0.95
cacheMethod · 0.95
updateMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected