| @@ 209-225 (lines=17) @@ | ||
| 206 | /** |
|
| 207 | * |
|
| 208 | */ |
|
| 209 | public function contains($data) : bool { |
|
| 210 | if($this->empty()) { |
|
| 211 | return false; |
|
| 212 | } |
|
| 213 | ||
| 214 | $current = $this->head->next; |
|
| 215 | $prev = $this->head; |
|
| 216 | while($current !== $this->head) { |
|
| 217 | if($prev->data === $data) { |
|
| 218 | return true; |
|
| 219 | } |
|
| 220 | $prev = $current; |
|
| 221 | $current = $current->next; |
|
| 222 | } |
|
| 223 | ||
| 224 | return false; |
|
| 225 | } |
|
| 226 | ||
| 227 | /** |
|
| 228 | * Generator for retrieve all nodes stored. |
|
| @@ 134-150 (lines=17) @@ | ||
| 131 | /** |
|
| 132 | * |
|
| 133 | */ |
|
| 134 | public function contains($data) : bool { |
|
| 135 | if($this->empty()) { |
|
| 136 | return false; |
|
| 137 | } |
|
| 138 | ||
| 139 | $current = $this->head->next; |
|
| 140 | $prev = $this->head; |
|
| 141 | while($current !== $this->head) { |
|
| 142 | if($prev->data === $data) { |
|
| 143 | return true; |
|
| 144 | } |
|
| 145 | $prev = $current; |
|
| 146 | $current = $current->next; |
|
| 147 | } |
|
| 148 | ||
| 149 | return false; |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * Generator for retrieve all nodes stored. |
|