CTypedList
| 包 | system.collections |
|---|---|
| 继承 | class CTypedList » CList » CComponent |
| 实现 | Countable, ArrayAccess, Traversable, IteratorAggregate |
| 源自 | 1.0 |
| 版本 | $Id: CTypedList.php 3001 2011-02-24 16:42:44Z alexander.makarow $ |
| 源码 | framework/collections/CTypedList.php |
公共属性
| 属性 | 类型 | 描述 | 定义在 |
|---|---|---|---|
| count | integer | 返回列表的项目数。 | CList |
| iterator | Iterator | 返回遍历这个项目列表的迭代器。 | CList |
| readOnly | boolean | 返回值说明这个列表是否为只读。默认为false。 | CList |
公共方法
方法详细
__construct()
方法
|
public void __construct(string $type)
| ||
| $type | string | 类的类型 |
源码: framework/collections/CTypedList.php#30 (显示)
public function __construct($type)
{
$this->_type=$type;
}
构造方法
insertAt()
方法
|
public void insertAt(integer $index, mixed $item)
| ||
| $index | integer | 指定位置。 |
| $item | mixed | 新的项目 |
源码: framework/collections/CTypedList.php#44 (显示)
public function insertAt($index,$item)
{
if($item instanceof $this->_type)
parent::insertAt($index,$item);
else
throw new CException(Yii::t('yii','CTypedList<{type}> can only hold objects of {type} class.',
array('{type}'=>$this->_type)));
}
将项目插入到指定位置。 这个方法重写了父类方法, 实现了检查要插入的项目是否为某个类型。