-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompression.diff
More file actions
95 lines (90 loc) · 2.89 KB
/
Copy pathcompression.diff
File metadata and controls
95 lines (90 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- input/input.java
+++ output/output.java
@@ -75,15 +75,7 @@
* @return the evicted entry
*/
private Entry<K, V> evict() {
- if (head == null) {
- throw new RuntimeException("cache cannot be empty!");
- }
- Entry<K, V> evicted = head;
- head = evicted.getNextEntry();
- head.setPreEntry(null);
- evicted.setNextEntry(null);
- return evicted;
- }
+ { … 9 line(s) … ⟦tj:c8f9fade2969101a0a47b5b305e9f88f⟧ }
/**
* Checks if the capacity is valid.
@@ -121,23 +113,8 @@
private void moveNodeToLast(Entry<K, V> entry) {
if (tail == entry) {
return;
- }
- final Entry<K, V> preEntry = entry.getPreEntry();
- final Entry<K, V> nextEntry = entry.getNextEntry();
- if (preEntry != null) {
- preEntry.setNextEntry(nextEntry);
- }
- if (nextEntry != null) {
- nextEntry.setPreEntry(preEntry);
- }
- if (head == entry) {
- head = nextEntry;
- }
- tail.setNextEntry(entry);
- entry.setPreEntry(tail);
- entry.setNextEntry(null);
+ { … 15 line(s) … ⟦tj:8d43701643bc3e2c6ec908d60c5c222e⟧ }
tail = entry;
- }
/**
* Associates the specified value with the specified key in this cache.
@@ -148,23 +125,8 @@
public void put(K key, V value) {
if (data.containsKey(key)) {
final Entry<K, V> existingEntry = data.get(key);
- existingEntry.setValue(value);
- moveNodeToLast(existingEntry);
- return;
- }
- Entry<K, V> newEntry;
- if (data.size() == cap) {
- newEntry = evict();
- data.remove(newEntry.getKey());
- } else {
- newEntry = new Entry<>();
- }
-
- newEntry.setKey(key);
- newEntry.setValue(value);
- addNewEntry(newEntry);
+ { … 15 line(s) … ⟦tj:932f4c2f5fc1a0ef48989acea81a7eb5⟧ }
data.put(key, newEntry);
- }
/**
* Adds a new entry to the end of the list.
@@ -172,16 +134,7 @@
* @param newEntry the entry to add
*/
private void addNewEntry(Entry<K, V> newEntry) {
- if (data.isEmpty()) {
- head = newEntry;
- tail = newEntry;
- return;
- }
- tail.setNextEntry(newEntry);
- newEntry.setPreEntry(tail);
- newEntry.setNextEntry(null);
- tail = newEntry;
- }
+ { … 10 line(s) … ⟦tj:74bcf07953d9727d114bf0f47f4644cf⟧ }
static final class Entry<I, J> {
@@ -233,3 +186,6 @@
}
}
}
+[omitted blocks are individually retrievable: call tinyjuice_retrieve with the token inside an omission marker to expand just that block]
+
+[PARTIAL view — full original (6665 bytes): call tinyjuice_retrieve with token "297a09e22043249ecebe054941693b12"]
\ No newline at end of file