DataStructures/Lists/Stack.php 1 location
|
@@ 87-94 (lines=8) @@
|
84 |
|
} |
85 |
|
|
86 |
|
$newNode = new Node($data); |
87 |
|
if($this->head === null) { |
88 |
|
$this->head = &$newNode; |
89 |
|
$newNode->next = null; |
90 |
|
} else { |
91 |
|
$temp = $this->head; |
92 |
|
$this->head = &$newNode; |
93 |
|
$newNode->next = &$temp; |
94 |
|
} |
95 |
|
|
96 |
|
$this->size++; |
97 |
|
} |
DataStructures/Lists/SimpleLinkedList.php 1 location
|
@@ 215-224 (lines=10) @@
|
212 |
|
|
213 |
|
protected function insertEnd($data) { |
214 |
|
$newNode = new SimpleLinkedListNode($data); |
215 |
|
if($this->head === null) { |
216 |
|
$this->head = &$newNode; |
217 |
|
$this->current = &$this->head; |
218 |
|
} else { |
219 |
|
$current = $this->head; |
220 |
|
while($current->next !== null) { |
221 |
|
$current = $current->next; |
222 |
|
} |
223 |
|
$current->next = &$newNode; |
224 |
|
} |
225 |
|
} |
226 |
|
|
227 |
|
protected function insertBeginning($data) { |