@@ 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 | $this->current = &$this->head; |
|
59 | $this->size++; |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Inserts at the beginning of the list. |
@@ 262-276 (lines=15) @@ | ||
259 | * @param integer $index the position. |
|
260 | * @param mixed $data the data to store. |
|
261 | */ |
|
262 | public function insert($index, $data) { |
|
263 | if($index < 0) { |
|
264 | throw new OutOfBoundsException(); |
|
265 | } |
|
266 | ||
267 | if($index === 0) { |
|
268 | $this->insertBeginning($data); |
|
269 | } else if($index >= $this->size) { |
|
270 | $this->insertEnd($data); |
|
271 | } else if($index > 0 && $index < $this->size) { |
|
272 | $this->insertAt($index, $data); |
|
273 | } |
|
274 | ||
275 | $this->size++; |
|
276 | } |
|
277 | ||
278 | /** |
|
279 | * Inserts at the beginning of the list. |