(key int)
| 44 | } |
| 45 | |
| 46 | func (this *LRUCache) Get(key int) int { |
| 47 | n, ok := this.cacheMap[key] |
| 48 | if !ok { |
| 49 | return -1 |
| 50 | } |
| 51 | this.delete(n) |
| 52 | this.pushAfter(this.head, n) |
| 53 | return n.value |
| 54 | } |
| 55 | |
| 56 | func (this *LRUCache) Put(key int, value int) { |
| 57 | n, ok := this.cacheMap[key] |