Code Duplication    Length = 19-19 lines in 3 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 253-271 (lines=19) @@
250
    /**
251
     *
252
     */
253
    public function lastIndexOf($data) {
254
        if($this->head === null) {
255
            return false;
256
        }
257
        
258
        $current = $this->head;
259
        $i = 0;
260
        $pos = false;
261
        while($i < $this->size) {
262
            if($current->data == $data) {
263
                $pos = $i;
264
            }
265
266
            $current = $current->next;
267
            $i++;
268
        }
269
270
        return $pos;
271
    }
272
273
    /**
274
     * Generator for retrieve all nodes stored.

DataStructures/Lists/DoublyLinkedList.php 1 location

@@ 177-195 (lines=19) @@
174
    /**
175
     *
176
     */
177
    public function lastIndexOf($data) {
178
        if($this->head === null) {
179
            return false;
180
        }
181
        
182
        $current = $this->head;
183
        $i = 0;
184
        $pos = false;
185
        while($i < $this->size) {
186
            if($current->data == $data) {
187
                $pos = $i;
188
            }
189
190
            $current = $current->next;
191
            $i++;
192
        }
193
194
        return $pos;
195
    }
196
    
197
    /**
198
     * Generator for retrieve all nodes stored.

DataStructures/Lists/SimpleLinkedList.php 1 location

@@ 163-181 (lines=19) @@
160
    /**
161
     *
162
     */
163
    public function lastIndexOf($data) {
164
        if($this->head === null) {
165
            return false;
166
        }
167
        
168
        $current = $this->head;
169
        $i = 0;
170
        $pos = false;
171
        while($i < $this->size) {
172
            if($current->data == $data) {
173
                $pos = $i;
174
            }
175
176
            $current = $current->next;
177
            $i++;
178
        }
179
180
        return $pos;
181
    }
182
183
    /**
184
     * Insert a node in the specified list position.