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

@@ 233-241 (lines=9) @@
230
    /**
231
     * {@inheritDoc}
232
     */
233
    protected function insertBeginning($data) {
234
        $newNode = new SimpleLinkedListNode($data);
235
        if($this->head === null) {
236
            $this->head = &$newNode;
237
        } else {
238
            $newNode->next = $this->head;
239
            $this->head = &$newNode;
240
        }
241
    }
242
243
    /**
244
     * Delete a node in the given position and returns it back.