CListIterator

优质
小牛编辑
126浏览
2023-12-01
所有包 | 方法
system.collections
继承class CListIterator
实现Iterator, Traversable
源自1.0
版本$Id: CListIterator.php 2799 2011-01-01 19:31:13Z qiang.xue $
源码framework/collections/CListIterator.php
CListIterator为CList实现的一个迭代器。

它允许CList返回一个新的迭代器用来遍历列表中所有子项。

公共方法

隐藏继承方法

方法描述定义在
__construct()构造方法。CListIterator
current()返回保存数据的数组中的当前项目。CListIterator
key()返回保存数据的数组中的当前键名。CListIterator
next()移动当前索引到下一位置。CListIterator
rewind()重置当前数组索引位置。CListIterator
valid()返回值说明当前位置是否存在一个项目。CListIterator

方法详细

__construct() 方法
public void __construct(array &$data)
$dataarray要迭代的数据
源码: framework/collections/CListIterator.php#40 (显示) publicfunction__construct(&$data)
{
$this->_d=&$data;
$this->_i=0;
$this->_c=count($this->_d);
}

构造方法。

current() 方法
public mixed current()
{return}mixed返回当前数组项目
源码: framework/collections/CListIterator.php#71 (显示) publicfunctioncurrent()
{
return$this->_d[$this->_i];
}

返回保存数据的数组中的当前项目。 此方法为接口Iterator强制要求实现。

key() 方法
public integer key()
{return}integer当前数组项目的键名。
源码: framework/collections/CListIterator.php#61 (显示) publicfunctionkey()
{
return$this->_i;
}

返回保存数据的数组中的当前键名。 此方法为接口Iterator强制要求实现。

next() 方法
public void next()
源码: framework/collections/CListIterator.php#80 (显示) publicfunctionnext()
{
$this->_i++;
}

移动当前索引到下一位置。 此方法为接口Iterator强制要求实现。

rewind() 方法
public void rewind()
源码: framework/collections/CListIterator.php#51 (显示) publicfunctionrewind()
{
$this->_i=0;
}

重置当前数组索引位置。 此方法为接口Iterator强制要求实现。

valid() 方法
public boolean valid()
{return}boolean
源码: framework/collections/CListIterator.php#90 (显示) publicfunctionvalid()
{
return$this->_i<$this->_c;
}

返回值说明当前位置是否存在一个项目。 此方法为接口Iterator强制要求实现。