/** * Add HashTable item * * @param PHPExcel_IComparable $pSource Item to add * @throws Exception */ public function add(PHPExcel_IComparable $pSource = null) { $hashCode = $pSource->getHashCode(); 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()); } }
/** * Add HashTable item * * @param PHPExcel_IComparable $pSource Item to add * @throws Exception */ public function add(PHPExcel_IComparable $pSource = null) { // Determine hashcode $hashCode = null; $hashIndex = $pSource->getHashIndex(); if (is_null($hashIndex)) { $hashCode = $pSource->getHashCode(); } else { if (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()); } }