| @@ 141-153 (lines=13) @@ | ||
| 138 | * |
|
| 139 | * @return mixed the head of this queue, or null if this queue is empty |
|
| 140 | */ |
|
| 141 | public function poll() |
|
| 142 | { |
|
| 143 | if ($this->count() === 0) { |
|
| 144 | return null; |
|
| 145 | } |
|
| 146 | ||
| 147 | $head = $this[$this->index]; |
|
| 148 | ||
| 149 | unset($this[$this->index]); |
|
| 150 | $this->index++; |
|
| 151 | ||
| 152 | return $head; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Retrieves and removes the head of this queue. This method differs |
|
| @@ 163-174 (lines=12) @@ | ||
| 160 | * @return mixed the head of this queue |
|
| 161 | * @throws NoSuchElementException |
|
| 162 | */ |
|
| 163 | public function remove() |
|
| 164 | { |
|
| 165 | if ($this->count() === 0) { |
|
| 166 | throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); |
|
| 167 | } |
|
| 168 | $head = $this[$this->index]; |
|
| 169 | ||
| 170 | unset($this[$this->index]); |
|
| 171 | $this->index++; |
|
| 172 | ||
| 173 | return $head; |
|
| 174 | } |
|
| 175 | ||
| 176 | /** |
|
| 177 | * Returns the type associated with this collection |
|