Example #1
0
 /**
  * @param mixed $offset
  * @param mixed $value
  */
 public function offsetSet($offset, $value)
 {
     if (!is_object($value)) {
         parent::offsetSet($offset, $value);
         return;
     }
     $hashCode = $value->hashCode();
     if (is_null($offset)) {
         $this->index[$hashCode] = count($this->data);
         $this->indexSplHash[spl_object_hash($value)] = $hashCode;
         $this->data[] = $value;
     } else {
         if (isset($this->data[$offset])) {
             unset($this->indexSplHash[spl_object_hash($this->data[$offset])]);
             unset($this->index[$this->data[$offset]->hashCode()]);
         }
         $this->index[$hashCode] = $offset;
         $this->indexSplHash[spl_object_hash($value)] = $hashCode;
         $this->data[$offset] = $value;
     }
 }