CMapIterator
包 | system.collections |
---|---|
继承 | class CMapIterator |
实现 | Iterator, Traversable |
可用自 | 1.0 |
源码 | framework/collections/CMapIterator.php |
CMapIterator implements an iterator for CMap.
It allows CMap to return a new iterator for traversing the items in the map.
It allows CMap to return a new iterator for traversing the items in the map.
公共方法
方法 | 描述 | 被定义在 |
---|---|---|
__construct() | Constructor. | CMapIterator |
current() | Returns the current array element. | CMapIterator |
key() | Returns the key of the current array element. | CMapIterator |
next() | Moves the internal pointer to the next array element. | CMapIterator |
rewind() | Rewinds internal array pointer. | CMapIterator |
valid() | Returns whether there is an element at current position. | CMapIterator |
方法详情
__construct()
方法
public void __construct(array &$data)
| ||
$data | array | the data to be iterated through |
源码: framework/collections/CMapIterator.php#39 (显示)
public function __construct(&$data)
{
$this->_d=&$data;
$this->_keys=array_keys($data);
$this->_key=reset($this->_keys);
}
Constructor.
current()
方法
public mixed current()
| ||
{return} | mixed | the current array element |
源码: framework/collections/CMapIterator.php#70 (显示)
public function current()
{
return $this->_d[$this->_key];
}
Returns the current array element. This method is required by the interface Iterator.
key()
方法
public mixed key()
| ||
{return} | mixed | the key of the current array element |
Returns the key of the current array element. This method is required by the interface Iterator.
next()
方法
public void next()
|
源码: framework/collections/CMapIterator.php#79 (显示)
public function next()
{
$this->_key=next($this->_keys);
}
Moves the internal pointer to the next array element. This method is required by the interface Iterator.
rewind()
方法
public void rewind()
|
源码: framework/collections/CMapIterator.php#50 (显示)
public function rewind()
{
$this->_key=reset($this->_keys);
}
Rewinds internal array pointer. This method is required by the interface Iterator.
valid()
方法
public boolean valid()
| ||
{return} | boolean |
源码: framework/collections/CMapIterator.php#89 (显示)
public function valid()
{
return $this->_key!==false;
}
Returns whether there is an element at current position. This method is required by the interface Iterator.