Code Duplication    Length = 14-14 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 77-90 (lines=14) @@
74
     * @param integer $index the position.
75
     * @param mixed $data the data to be stored.
76
     */
77
    protected function insertAt($index, $data) {
78
        $newNode = new SimpleLinkedListNode($data);
79
        $current = $this->head;
80
        $prev = null;
81
        $i = 0;
82
        while($i < $index) {
83
            $prev = $current;
84
            $current = $current->next;
85
            $i++;
86
        }
87
        
88
        $prev->next = &$newNode;
89
        $newNode->next = &$current;
90
    }
91
92
    /**
93
     * Returns the last node data with O(1).

DataStructures/Lists/SimpleLinkedList.php 1 location

@@ 201-214 (lines=14) @@
198
     * @param integer $index the position.
199
     * @param mixed $data the data to be stored.
200
     */
201
    protected function insertAt($index, $data) {
202
        $newNode = new SimpleLinkedListNode($data);
203
        $current = $this->head;
204
        $prev = null;
205
        $i = 0;
206
        while($i < $index) {
207
            $prev = $current;
208
            $current = $current->next;
209
            $i++;
210
        }
211
        
212
        $prev->next = &$newNode;
213
        $newNode->next = &$current;
214
    }
215
216
    protected function insertEnd($data) {
217
        $newNode = new SimpleLinkedListNode($data);