(key: K, value: V, touch: Touch = Touch.None)
| 60 | } |
| 61 | |
| 62 | public set(key: K, value: V, touch: Touch = Touch.None): void { |
| 63 | let item = this._map.get(key); |
| 64 | if (item) { |
| 65 | item.value = value; |
| 66 | if (touch !== Touch.None) { |
| 67 | this.touch(item, touch); |
| 68 | } |
| 69 | } else { |
| 70 | item = { key, value, next: undefined, previous: undefined }; |
| 71 | switch(touch) { |
| 72 | case Touch.None: |
| 73 | this.addItemLast(item); |
| 74 | break; |
| 75 | case Touch.First: |
| 76 | this.addItemFirst(item); |
| 77 | break; |
| 78 | case Touch.Last: |
| 79 | this.addItemLast(item); |
| 80 | break; |
| 81 | default: |
| 82 | this.addItemLast(item); |
| 83 | break; |
| 84 | } |
| 85 | this._map.set(key, item); |
| 86 | this._size++; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | public delete(key: K): boolean { |
| 91 | const item = this._map.get(key); |
no test coverage detected