| @@ 71-79 (lines=9) @@ | ||
| 68 | } |
|
| 69 | ||
| 70 | $newNode = new Node($data); |
|
| 71 | if($this->head === null) { |
|
| 72 | $this->head = &$newNode; |
|
| 73 | $this->tail = &$this->head; |
|
| 74 | $newNode->next = &$this->tail; |
|
| 75 | } else { |
|
| 76 | $this->tail->next = &$newNode; |
|
| 77 | $newNode->next = &$this->head; |
|
| 78 | $this->tail = &$newNode; |
|
| 79 | } |
|
| 80 | $this->size++; |
|
| 81 | } |
|
| 82 | ||
| @@ 88-96 (lines=9) @@ | ||
| 85 | */ |
|
| 86 | private function insertBeginning($data) { |
|
| 87 | $newNode = new Node($data); |
|
| 88 | if($this->head === null) { |
|
| 89 | $newNode->next = &$this->head; |
|
| 90 | $this->head = &$newNode; |
|
| 91 | $this->tail = &$newNode; |
|
| 92 | } else { |
|
| 93 | $this->tail->next = &$newNode; |
|
| 94 | $newNode->next = &$this->head; |
|
| 95 | $this->head = &$newNode; |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|