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

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