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