Esempio n. 1
0
 /**
  * Add HashTable item
  *
  * @param \PhpOffice\PhpPresentation\ComparableInterface $pSource Item to add
  */
 public function add(ComparableInterface $pSource)
 {
     // Determine hashcode
     $hashIndex = $pSource->getHashIndex();
     if (is_null($hashIndex)) {
         $hashCode = $pSource->getHashCode();
     } elseif (isset($this->keyMap[$hashIndex])) {
         $hashCode = $this->keyMap[$hashIndex];
     } else {
         $hashCode = $pSource->getHashCode();
     }
     // Add value
     if (!isset($this->items[$hashCode])) {
         $this->items[$hashCode] = $pSource;
         $index = count($this->items) - 1;
         $this->keyMap[$index] = $hashCode;
         $pSource->setHashIndex($index);
     } else {
         $pSource->setHashIndex($this->items[$hashCode]->getHashIndex());
     }
 }