ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_HashTable Class Reference
+ Collaboration diagram for PHPExcel_HashTable:

Public Member Functions

 __construct ($pSource=null)
 Create a new PHPExcel_HashTable.
 addFromSource ($pSource=null)
 Add HashTable items from source.
 add (PHPExcel_IComparable $pSource=null)
 Add HashTable item.
 remove (PHPExcel_IComparable $pSource=null)
 Remove HashTable item.
 clear ()
 Clear HashTable.
 count ()
 Count.
 getIndexForHashCode ($pHashCode= '')
 Get index for hash code.
 getByIndex ($pIndex=0)
 Get by index.
 getByHashCode ($pHashCode= '')
 Get by hashcode.
 toArray ()
 HashTable to array.
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy.

Data Fields

 $_items = array()
 $_keyMap = array()

Detailed Description

Definition at line 48 of file HashTable.php.

Constructor & Destructor Documentation

PHPExcel_HashTable::__construct (   $pSource = null)

Create a new PHPExcel_HashTable.

Parameters
PHPExcel_IComparable[]$pSource Optional source array to create HashTable from
Exceptions
Exception

Definition at line 70 of file HashTable.php.

References addFromSource().

{
if (!is_null($pSource)) {
// Create HashTable
$this->addFromSource($pSource);
}
}

+ Here is the call graph for this function:

Member Function Documentation

PHPExcel_HashTable::__clone ( )

Implement PHP __clone to create a deep clone, not just a shallow copy.

Definition at line 220 of file HashTable.php.

References $key.

{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
$this->$key = clone $value;
}
}
}
PHPExcel_HashTable::add ( PHPExcel_IComparable  $pSource = null)

Add HashTable item.

Parameters
PHPExcel_IComparable$pSourceItem to add
Exceptions
Exception

Definition at line 103 of file HashTable.php.

References count().

Referenced by addFromSource().

{
// 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() );
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_HashTable::addFromSource (   $pSource = null)

Add HashTable items from source.

Parameters
PHPExcel_IComparable[]$pSource Source array to create HashTable from
Exceptions
Exception

Definition at line 84 of file HashTable.php.

References add().

Referenced by __construct().

{
// Check if an array was passed
if ($pSource == null) {
return;
} else if (!is_array($pSource)) {
throw new Exception('Invalid array parameter passed.');
}
foreach ($pSource as $item) {
$this->add($item);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_HashTable::clear ( )

Clear HashTable.

Definition at line 154 of file HashTable.php.

{
$this->_items = array();
$this->_keyMap = array();
}
PHPExcel_HashTable::count ( )

Count.

Returns
int

Definition at line 164 of file HashTable.php.

Referenced by add(), and remove().

{
return count($this->_items);
}

+ Here is the caller graph for this function:

PHPExcel_HashTable::getByHashCode (   $pHashCode = '')

Get by hashcode.

Parameters
string$pHashCode
Returns
PHPExcel_IComparable

Definition at line 200 of file HashTable.php.

Referenced by getByIndex().

{
if (isset($this->_items[$pHashCode])) {
return $this->_items[$pHashCode];
}
return null;
}

+ Here is the caller graph for this function:

PHPExcel_HashTable::getByIndex (   $pIndex = 0)

Get by index.

Parameters
int$pIndex
Returns
PHPExcel_IComparable

Definition at line 185 of file HashTable.php.

References getByHashCode().

{
if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] );
}
return null;
}

+ Here is the call graph for this function:

PHPExcel_HashTable::getIndexForHashCode (   $pHashCode = '')

Get index for hash code.

Parameters
string$pHashCode
Returns
int Index

Definition at line 174 of file HashTable.php.

{
return array_search($pHashCode, $this->_keyMap);
}
PHPExcel_HashTable::remove ( PHPExcel_IComparable  $pSource = null)

Remove HashTable item.

Parameters
PHPExcel_IComparable$pSourceItem to remove
Exceptions
Exception

Definition at line 132 of file HashTable.php.

References $key, and count().

{
if (isset($this->_items[ $pSource->getHashCode() ])) {
unset($this->_items[ $pSource->getHashCode() ]);
$deleteKey = -1;
foreach ($this->_keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->_keyMap[$key - 1] = $value;
}
if ($value == $pSource->getHashCode()) {
$deleteKey = $key;
}
}
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
}
}

+ Here is the call graph for this function:

PHPExcel_HashTable::toArray ( )

HashTable to array.

Returns
PHPExcel_IComparable[]

Definition at line 213 of file HashTable.php.

References $_items.

{
return $this->_items;
}

Field Documentation

PHPExcel_HashTable::$_items = array()

Definition at line 55 of file HashTable.php.

Referenced by toArray().

PHPExcel_HashTable::$_keyMap = array()

Definition at line 62 of file HashTable.php.


The documentation for this class was generated from the following file: