Code Duplication    Length = 6-9 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

@@ 64-69 (lines=6) @@
61
     * @param integer $index the position.
62
     * @param mixed $data the data to be stored.
63
     */
64
    protected function insertEnd($data) {
65
        $newNode = new SimpleLinkedListNode($data);
66
        $this->tail->next = &$newNode;
67
        $newNode->next = &$this->head;
68
        $this->tail = &$newNode;
69
    }
70
71
    /**
72
     * Add a new node in the specified index.

DataStructures/Lists/SimpleLinkedList.php 1 location

@@ 227-235 (lines=9) @@
224
        }
225
    }
226
227
    protected function insertBeginning($data) {
228
        $newNode = new SimpleLinkedListNode($data);
229
        if($this->head === null) {
230
            $this->head = &$newNode;
231
        } else {
232
            $newNode->next = $this->head;
233
            $this->head = &$newNode;
234
        }
235
    }
236
237
    /**
238
     * Delete a node in the given position and returns it back.