ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
PHPExcel_HashTable Class Reference
+ Collaboration diagram for PHPExcel_HashTable:

Public Member Functions

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

Data Fields

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

Detailed Description

Definition at line 36 of file HashTable.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_HashTable::__construct (   $pSource = null)

Create a new PHPExcel_HashTable.

Parameters
PHPExcel_IComparable[]$pSourceOptional source array to create HashTable from
Exceptions
PHPExcel_Exception

Definition at line 58 of file HashTable.php.

59 {
60 if ($pSource !== NULL) {
61 // Create HashTable
62 $this->addFromSource($pSource);
63 }
64 }
addFromSource($pSource=null)
Add HashTable items from source.
Definition: HashTable.php:72

References addFromSource().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

PHPExcel_HashTable::__clone ( )

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

Definition at line 194 of file HashTable.php.

194 {
195 $vars = get_object_vars($this);
196 foreach ($vars as $key => $value) {
197 if (is_object($value)) {
198 $this->$key = clone $value;
199 }
200 }
201 }
$key
Definition: croninfo.php:18

References $key.

◆ add()

PHPExcel_HashTable::add ( PHPExcel_IComparable  $pSource = null)

Add HashTable item.

Parameters
PHPExcel_IComparable$pSourceItem to add
Exceptions
PHPExcel_Exception

Definition at line 91 of file HashTable.php.

91 {
92 $hash = $pSource->getHashCode();
93 if (!isset($this->_items[$hash])) {
94 $this->_items[$hash] = $pSource;
95 $this->_keyMap[count($this->_items) - 1] = $hash;
96 }
97 }
getHashCode()
Get hash code.

References count().

Referenced by addFromSource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addFromSource()

PHPExcel_HashTable::addFromSource (   $pSource = null)

Add HashTable items from source.

Parameters
PHPExcel_IComparable[]$pSourceSource array to create HashTable from
Exceptions
PHPExcel_Exception

Definition at line 72 of file HashTable.php.

72 {
73 // Check if an array was passed
74 if ($pSource == null) {
75 return;
76 } else if (!is_array($pSource)) {
77 throw new PHPExcel_Exception('Invalid array parameter passed.');
78 }
79
80 foreach ($pSource as $item) {
81 $this->add($item);
82 }
83 }
add(PHPExcel_IComparable $pSource=null)
Add HashTable item.
Definition: HashTable.php:91

References add().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

PHPExcel_HashTable::clear ( )

Clear HashTable.

Definition at line 128 of file HashTable.php.

128 {
129 $this->_items = array();
130 $this->_keyMap = array();
131 }

◆ count()

PHPExcel_HashTable::count ( )

Count.

Returns
int

Definition at line 138 of file HashTable.php.

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

References count().

Referenced by add(), count(), and remove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getByHashCode()

PHPExcel_HashTable::getByHashCode (   $pHashCode = '')

Get by hashcode.

Parameters
string$pHashCode
Returns
PHPExcel_IComparable

Definition at line 174 of file HashTable.php.

174 {
175 if (isset($this->_items[$pHashCode])) {
176 return $this->_items[$pHashCode];
177 }
178
179 return null;
180 }

Referenced by getByIndex().

+ Here is the caller graph for this function:

◆ getByIndex()

PHPExcel_HashTable::getByIndex (   $pIndex = 0)

Get by index.

Parameters
int$pIndex
Returns
PHPExcel_IComparable

Definition at line 159 of file HashTable.php.

159 {
160 if (isset($this->_keyMap[$pIndex])) {
161 return $this->getByHashCode( $this->_keyMap[$pIndex] );
162 }
163
164 return null;
165 }
getByHashCode($pHashCode='')
Get by hashcode.
Definition: HashTable.php:174

References getByHashCode().

+ Here is the call graph for this function:

◆ getIndexForHashCode()

PHPExcel_HashTable::getIndexForHashCode (   $pHashCode = '')

Get index for hash code.

Parameters
string$pHashCode
Returns
int Index

Definition at line 148 of file HashTable.php.

148 {
149 return array_search($pHashCode, $this->_keyMap);
150 }

◆ remove()

PHPExcel_HashTable::remove ( PHPExcel_IComparable  $pSource = null)

Remove HashTable item.

Parameters
PHPExcel_IComparable$pSourceItem to remove
Exceptions
PHPExcel_Exception

Definition at line 105 of file HashTable.php.

105 {
106 $hash = $pSource->getHashCode();
107 if (isset($this->_items[$hash])) {
108 unset($this->_items[$hash]);
109
110 $deleteKey = -1;
111 foreach ($this->_keyMap as $key => $value) {
112 if ($deleteKey >= 0) {
113 $this->_keyMap[$key - 1] = $value;
114 }
115
116 if ($value == $hash) {
117 $deleteKey = $key;
118 }
119 }
120 unset($this->_keyMap[count($this->_keyMap) - 1]);
121 }
122 }

References $key, count(), and PHPExcel_IComparable\getHashCode().

+ Here is the call graph for this function:

◆ toArray()

PHPExcel_HashTable::toArray ( )

HashTable to array.

Returns
PHPExcel_IComparable[]

Definition at line 187 of file HashTable.php.

187 {
188 return $this->_items;
189 }

References $_items.

Field Documentation

◆ $_items

PHPExcel_HashTable::$_items = array()

Definition at line 43 of file HashTable.php.

Referenced by toArray().

◆ $_keyMap

PHPExcel_HashTable::$_keyMap = array()

Definition at line 50 of file HashTable.php.


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