Code Duplication    Length = 6-9 lines in 2 locations

DataStructures/Lists/CircularLinkedList.php 1 location

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

DataStructures/Lists/SinglyLinkedList.php 1 location

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