summaryrefslogtreecommitdiff
path: root/framework/Collections/TMap.php
diff options
context:
space:
mode:
authorxue <>2006-02-04 04:43:40 +0000
committerxue <>2006-02-04 04:43:40 +0000
commitf97358b8da7a2cbb1bf6438298286f7290616381 (patch)
tree6c30830b0d8df8cc6d7e28d6ab9c7d107d3af0ba /framework/Collections/TMap.php
parente7a6d7d00239b1d320aafeaa2b90308b83103d85 (diff)
Fixed a bug in TList and TMap about the usage of isset.
Diffstat (limited to 'framework/Collections/TMap.php')
-rw-r--r--framework/Collections/TMap.php14
1 files changed, 4 insertions, 10 deletions
diff --git a/framework/Collections/TMap.php b/framework/Collections/TMap.php
index be37a46b..4d810503 100644
--- a/framework/Collections/TMap.php
+++ b/framework/Collections/TMap.php
@@ -97,14 +97,12 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess
/**
* Adds an item into the map.
- * Note, if the specified key already exists, the old value will be removed first.
+ * Note, if the specified key already exists, the old value will be overwritten.
* @param mixed key
* @param mixed value
*/
public function add($key,$value)
{
- if(isset($this->_d[$key]))
- $this->remove($key);
$this->_d[$key]=$value;
}
@@ -116,7 +114,7 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess
*/
public function remove($key)
{
- if(isset($this->_d[$key]))
+ if(isset($this->_d[$key]) || array_key_exists($key,$this->_d))
{
$value=$this->_d[$key];
unset($this->_d[$key]);
@@ -141,7 +139,7 @@ class TMap extends TComponent implements IteratorAggregate,ArrayAccess
*/
public function contains($key)
{
- return isset($this->_d[$key]);
+ return isset($this->_d[$key]) || array_key_exists($key,$this->_d);
}
/**
@@ -305,11 +303,7 @@ class TMapIterator implements Iterator
*/
public function next()
{
- do
- {
- $this->_key=next($this->_keys);
- }
- while(!isset($this->_d[$this->_key]) && $this->_key!==false);
+ $this->_key=next($this->_keys);
}
/**