ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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[]$pSource Optional source array to create HashTable from
Exceptions
PHPExcel_Exception

Definition at line 58 of file HashTable.php.

References addFromSource().

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
+ 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  }

◆ 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.

References count().

Referenced by addFromSource().

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.
+ 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[]$pSource Source array to create HashTable from
Exceptions
PHPExcel_Exception

Definition at line 72 of file HashTable.php.

References add().

Referenced by __construct().

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
+ 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.

References array.

128  {
129  $this->_items = array();
130  $this->_keyMap = array();
131  }
Create styles array
The data for the language used.

◆ count()

PHPExcel_HashTable::count ( )

Count.

Returns
int

Definition at line 138 of file HashTable.php.

Referenced by add(), and remove().

138  {
139  return count($this->_items);
140  }
+ 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.

Referenced by getByIndex().

174  {
175  if (isset($this->_items[$pHashCode])) {
176  return $this->_items[$pHashCode];
177  }
178 
179  return null;
180  }
+ 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.

References getByHashCode().

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
+ 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.

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

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  }
getHashCode()
Get hash code.
+ 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.

References $_items.

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

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: