Skip to content

Commit 870b4c2

Browse files
author
applewjg
committed
no need to update the iterator in cachemap[key]
1 parent 8b47d16 commit 870b4c2

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

LRUCache.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class LRUCache{
2626
int get(int key){
2727
if (cachemap.find(key) != cachemap.end()) {
2828
cachelist.splice(cachelist.begin(), cachelist, cachemap[key]);
29-
cachemap[key] = cachelist.begin();
3029
return cachemap[key]->value;
3130
}
3231
else {
@@ -37,7 +36,6 @@ class LRUCache{
3736
void set(int key, int value) {
3837
if (cachemap.find(key) != cachemap.end()) {
3938
cachelist.splice(cachelist.begin(), cachelist, cachemap[key]);
40-
cachemap[key] = cachelist.begin();
4139
cachemap[key]->value = value;
4240
}
4341
else {

0 commit comments

Comments
 (0)