Esempio n. 1
0
 public function insertAll($index, ZendX_Util_Collection_Interface $c)
 {
     if ($index < 0 || $index > $this->size) {
         throw new Zend_Exception('IndexOutOfBounds');
     }
     $a = $c->toArray();
     $numNew = count($a);
     if ($numNew == 0) {
         return false;
     }
     $successor = $index == $this->size ? $this->header : $this->entry($index);
     $predecessor = $successor->previous;
     for ($i = 0; $i < $numNew; $i++) {
         $e = new ZendX_Util_List_Entry($a[$i], $successor, $predecessor);
         $predecessor->next = $e;
         $predecessor = $e;
     }
     $successor->previous = $predecessor;
     $this->size += $numNew;
     return true;
 }
Esempio n. 2
0
 public function insertAll($index, ZendX_Util_Collection_Interface $c)
 {
     if ($index > $this->size || $index < 0) {
         throw new Zend_Exception('IndexOutOfBounds');
     }
     $a = $c->toArray();
     $numNew = count($a);
     if ($numNew > 0) {
         // split the array into upper and lower portions at the point of insertion
         $lower = array_slice($this->elementData, 0, $index);
         $upper = array_slice($this->elementData, $index);
         $this->elementData = array_merge($lower, $a, $upper);
         $this->size += $numNew;
     }
     return $numNew > 0;
 }