CTypedList
包 | system.collections |
---|---|
继承 | class CTypedList » CList » CComponent |
实现 | Countable, ArrayAccess, Traversable, IteratorAggregate |
可用自 | 1.0 |
源码 | framework/collections/CTypedList.php |
CTypedList represents a list whose items are of the certain type.
CTypedList extends CList by making sure that the elements to be added to the list is of certain class type.
CTypedList extends CList by making sure that the elements to be added to the list is of certain class type.
公共属性
属性 | 类型 | 描述 | 被定义在 |
---|---|---|---|
count | integer | Returns the number of items in the list. | CList |
iterator | Iterator | Returns an iterator for traversing the items in the list. | CList |
readOnly | boolean | whether this list is read-only or not. | CList |
公共方法
方法 | 描述 | 被定义在 |
---|---|---|
__call() | Calls the named method which is not a class method. | CComponent |
__construct() | Constructor. | CTypedList |
__get() | Returns a property value, an event handler list or a behavior based on its name. | CComponent |
__isset() | Checks if a property value is null. | CComponent |
__set() | Sets value of a component property. | CComponent |
__unset() | Sets a component property to be null. | CComponent |
add() | Appends an item at the end of the list. | CList |
asa() | Returns the named behavior object. | CComponent |
attachBehavior() | Attaches a behavior to this component. | CComponent |
attachBehaviors() | Attaches a list of behaviors to the component. | CComponent |
attachEventHandler() | Attaches an event handler to an event. | CComponent |
canGetProperty() | Determines whether a property can be read. | CComponent |
canSetProperty() | Determines whether a property can be set. | CComponent |
clear() | Removes all items in the list. | CList |
contains() | CList | |
copyFrom() | Copies iterable data into the list. | CList |
count() | Returns the number of items in the list. | CList |
detachBehavior() | Detaches a behavior from the component. | CComponent |
detachBehaviors() | Detaches all behaviors from the component. | CComponent |
detachEventHandler() | Detaches an existing event handler. | CComponent |
disableBehavior() | Disables an attached behavior. | CComponent |
disableBehaviors() | Disables all behaviors attached to this component. | CComponent |
enableBehavior() | Enables an attached behavior. | CComponent |
enableBehaviors() | Enables all behaviors attached to this component. | CComponent |
evaluateExpression() | Evaluates a PHP expression or callback under the context of this component. | CComponent |
getCount() | Returns the number of items in the list. | CList |
getEventHandlers() | Returns the list of attached event handlers for an event. | CComponent |
getIterator() | Returns an iterator for traversing the items in the list. | CList |
getReadOnly() | Returns whether this list is read-only or not. Defaults to false. | CList |
hasEvent() | Determines whether an event is defined. | CComponent |
hasEventHandler() | Checks whether the named event has attached handlers. | CComponent |
hasProperty() | Determines whether a property is defined. | CComponent |
indexOf() | CList | |
insertAt() | Inserts an item at the specified position. | CTypedList |
itemAt() | Returns the item at the specified offset. | CList |
mergeWith() | Merges iterable data into the map. | CList |
offsetExists() | Returns whether there is an item at the specified offset. | CList |
offsetGet() | Returns the item at the specified offset. | CList |
offsetSet() | Sets the item at the specified offset. | CList |
offsetUnset() | Unsets the item at the specified offset. | CList |
raiseEvent() | Raises an event. | CComponent |
remove() | Removes an item from the list. | CList |
removeAt() | Removes an item at the specified position. | CList |
toArray() | CList |
方法详情
__construct()
方法
public void __construct(string $type)
| ||
$type | string | class type |
源码: framework/collections/CTypedList.php#29 (显示)
public function __construct($type)
{
$this->_type=$type;
}
Constructor.
insertAt()
方法
public void insertAt(integer $index, mixed $item)
| ||
$index | integer | the specified position. |
$item | mixed | new item |
源码: framework/collections/CTypedList.php#43 (显示)
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)));
}
Inserts an item at the specified position. This method overrides the parent implementation by checking the item to be inserted is of certain type.