@@ 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 | } |
@@ 46-55 (lines=10) @@ | ||
43 | */ |
|
44 | public function push($data) { |
|
45 | $newNode = new SimpleLinkedListNode($data); |
|
46 | if($this->head === null) { |
|
47 | $this->head = &$newNode; |
|
48 | $this->current = &$this->head; |
|
49 | } else { |
|
50 | $current = $this->head; |
|
51 | while($current->next !== null) { |
|
52 | $current = $current->next; |
|
53 | } |
|
54 | $current->next = &$newNode; |
|
55 | } |
|
56 | ||
57 | $this->size++; |
|
58 | } |