. Map.entry eldest) < /code> точно так же, как он есть.
Код: Выделить всё
LRUMap map = new LRUMap(3); //capacity 3
map.put("a", "a");
map.put("b", "b");
map.put("c", "c");
map.put("d", "d");
Код: Выделить всё
[header] -> ["a"] -> ["b"] -> ["c"] -> ["d"] -> [header]
< /code>
Объект записи заголовка - это как начало, так и конец двойного связанного списка с момента header.before = header.fter = heder, когда он изначально конструирует. Entry eldest = header.after;
if (removeEldestEntry(eldest)) {
removeEntryForKey(eldest.key);
}
.....
And when we call get(Object key) does it rearrange the list order where it puts that key (lets say "b") before the header node, so it becomes
[header] -> ["c"] -> ["d"] -> ["b"] -> [header]
< /code>
Просто хочу уточнить это. < /p>
Подробнее здесь: https://stackoverflow.com/questions/120 ... -lru-cache