@@ 46-60 (lines=15) @@ | ||
43 | * @param integer $index the position. |
|
44 | * @param mixed $data the data to store. |
|
45 | */ |
|
46 | public function insert($index, $data) { |
|
47 | if($index < 0) { |
|
48 | throw new OutOfBoundsException(); |
|
49 | } |
|
50 | ||
51 | if($index === 0) { |
|
52 | $this->insertBeginning($data); |
|
53 | } else if($index >= $this->size) { |
|
54 | $this->insertEnd($data); |
|
55 | } else if($index > 0 && $index < $this->size) { |
|
56 | $this->insertAt($index, $data); |
|
57 | } |
|
58 | ||
59 | $this->size++; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Inserts at the beginning of the list. |
@@ 160-174 (lines=15) @@ | ||
157 | * @param integer $index the position. |
|
158 | * @param mixed $data the data to store. |
|
159 | */ |
|
160 | public function insert($index, $data) { |
|
161 | if($index < 0) { |
|
162 | throw new OutOfBoundsException(); |
|
163 | } |
|
164 | ||
165 | if($index === 0) { |
|
166 | $this->insertBeginning($data); |
|
167 | } else if($index >= $this->size) { |
|
168 | $this->insertEnd($data); |
|
169 | } else if($index > 0 && $index < $this->size) { |
|
170 | $this->insertAt($index, $data); |
|
171 | } |
|
172 | ||
173 | $this->size++; |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Inserts at the beginning of the list. |