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

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