Esempio n. 1
0
 public function insertAll($index, ZendX_Util_Collection_Interface $c)
 {
     try {
         $modified = false;
         $e1 = $this->listIterator($index);
         $e2 = $c->iterator();
         while ($e2->hasNext()) {
             $e1->add($e2->next());
             $modified = true;
         }
         return $modified;
         // TODO: implement custom exceptions when I can be bothered
     } catch (Zend_Exception $ex) {
         if ($e->getMessage() == 'NoSuchElement') {
             throw new Zend_Exception('IndexOutOfBounds');
         } else {
             throw $ex;
         }
     }
 }
Esempio n. 2
0
 public function retainAll(ZendX_Util_Collection_Interface $collection)
 {
     $newStore = array();
     $iterator = $collection->iterator();
     while ($iterator->hasNext()) {
         $item = $iterator->next();
         if ($this->contains($item)) {
             $newStore[] = $item;
         }
     }
     $this->store = $newStore;
 }
Esempio n. 3
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. 4
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;
 }
Esempio n. 5
0
 public function retainAll(ZendX_Util_Collection_Interface $c)
 {
     $modified = false;
     $e = $this->iterator();
     while ($e->hasNext()) {
         if (!$c->contains($e->next())) {
             $e->remove();
             $modified = true;
         }
     }
     return $modified;
 }
Esempio n. 6
0
 public function insertAll($index, ZendX_Util_Collection_Interface $c)
 {
     $this->rangeCheck($index);
     $cSize = $c->size();
     if ($cSize == 0) {
         return false;
     }
     $result = $this->list->insertAll($index + $this->offset, $c);
     $this->size += $cSize;
     return $result;
 }