()
| 142 | } |
| 143 | |
| 144 | public poll(): T | null { |
| 145 | if (this._size === 0) { |
| 146 | return null; |
| 147 | } |
| 148 | const s = --this._size; |
| 149 | const result = <T>this._queue[0]; |
| 150 | const x = <T>this._queue[s]; |
| 151 | this._queue.slice(s, 1); |
| 152 | if (s !== 0) { |
| 153 | this.sink(0, x); |
| 154 | } |
| 155 | return result; |
| 156 | } |
| 157 | |
| 158 | public peek(): T | null { |
| 159 | return this._size === 0 ? null : <T>this._queue[0]; |