* @param {number} capacity
(capacity)
| 8 | * @param {number} capacity |
| 9 | */ |
| 10 | constructor(capacity) { |
| 11 | /** @private @const {number} */ |
| 12 | this.capacity_ = capacity; |
| 13 | |
| 14 | /** @private {number} */ |
| 15 | this.size_ = 0; |
| 16 | |
| 17 | /** |
| 18 | * An incrementing counter to define the last access. |
| 19 | * @private {number} |
| 20 | */ |
| 21 | this.access_ = 0; |
| 22 | |
| 23 | /** @private {{[key: (number|string)]: {payload: T, access: number}}} */ |
| 24 | this.cache_ = map(); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Returns whether key is cached. |