| @@ 201-212 (lines=12) @@ | ||
| 198 | * |
|
| 199 | * @return multitype | null |
|
| 200 | */ |
|
| 201 | public function pollLast() |
|
| 202 | { |
|
| 203 | if ($this->isEmpty()) |
|
| 204 | { |
|
| 205 | return null; |
|
| 206 | } |
|
| 207 | $index = $this->size() - 1; |
|
| 208 | $element = $this->get($index); |
|
| 209 | $this->removeAt($index); |
|
| 210 | ||
| 211 | return $element; |
|
| 212 | } |
|
| 213 | ||
| 214 | /** |
|
| 215 | * Pops an element from the stack represented by this deque. |
|
| @@ 286-297 (lines=12) @@ | ||
| 283 | * @return multitype $element |
|
| 284 | * @throws NoSuchElementException |
|
| 285 | */ |
|
| 286 | public function removeLast() |
|
| 287 | { |
|
| 288 | if($this->isEmpty()) |
|
| 289 | { |
|
| 290 | throw new NoSuchElementException("List is empty, cannot remove tail element"); |
|
| 291 | } |
|
| 292 | $index = $this->size() - 1; |
|
| 293 | $element = $this->get($index); |
|
| 294 | $this->removeAt($index); |
|
| 295 | ||
| 296 | return $element; |
|
| 297 | } |
|
| 298 | ||
| 299 | /** |
|
| 300 | * Removes the last occurrence of the specified element from this deque. |
|