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 with O(1).

DataStructures/Lists/SimpleLinkedList.php 1 location

@@ 193-206 (lines=14) @@
190
     * @param integer $index the position.
191
     * @param mixed $data the data to be stored.
192
     */
193
    protected function insertAt($index, $data) {
194
        $newNode = new SimpleLinkedListNode($data);
195
        $current = $this->head;
196
        $prev = null;
197
        $i = 0;
198
        while($i < $index) {
199
            $prev = $current;
200
            $current = $current->next;
201
            $i++;
202
        }
203
        
204
        $prev->next = &$newNode;
205
        $newNode->next = &$current;
206
    }
207
208
    protected function insertEnd($data) {
209
        $newNode = new SimpleLinkedListNode($data);