()
| 49 | } |
| 50 | |
| 51 | getCache() { |
| 52 | const result: T[] = []; |
| 53 | let index = this.head; |
| 54 | for (let i = 0; i < this.size; i++) { |
| 55 | result.push(this.buffer[index]); |
| 56 | index = (index + 1) % this.capacity; |
| 57 | } |
| 58 | const wasDeleted = this.deleted; |
| 59 | |
| 60 | this.head = 0; |
| 61 | this.tail = 0; |
| 62 | this.size = 0; |
| 63 | this.deleted = false; |
| 64 | |
| 65 | return { |
| 66 | items: result, |
| 67 | wasDeleted |
| 68 | }; |
| 69 | } |
| 70 | |
| 71 | clear(){ |
| 72 | this.buffer = new Array(this.capacity); |