Class TList
TList class
TList implements an integer-indexed collection class.
You can access, append, insert, remove an item by using TList::itemAt()
,
TList::add()
, TList::insertAt()
, TList::remove()
, and TList::removeAt()
. To get the
number of the items in the list, use TList::getCount()
. TList can also be used
like a regular array as follows,
$list[]=$item; // append at the end $list[$index]=$item; // $index must be between 0 and $list->Count unset($list[$index]); // remove the item at $index if(isset($list[$index])) // if the list has an item at $index foreach($list as $index=>$item) // traverse each item in the list $n=count($list); // returns the number of items in the list
To extend TList by doing additional operations with each addition or removal
operation, override TList::insertAt()
, and TList::removeAt()
.
- TComponent
-
TList implements IteratorAggregate, ArrayAccess, Countable
Direct known subclasses
TAuthorizationRuleCollection, TCacheDependencyList, TMetaTagCollection, TPagedList, TPriorityList, TRepeaterItemCollection, TWizardStepCollection, TXmlElementList, TCallChain, TControlCollection, TDataGridColumnCollection, TDataGridItemCollection, TDataListItemCollection, THotSpotCollection, THttpCookieCollection, TListItemCollectionIndirect known subclasses
TAccordionViewCollection, TActiveListItemCollection, TEmptyControlCollection, TSqlMapPagedList, TTableCellCollection, TTableRowCollection, TTabViewCollection, TViewCollectionCopyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Collections/TList.php
public
|
#
__construct( array|Iterator $data = null, boolean $readOnly = false )
Constructor. Initializes the list with an array or an iterable object. |
public
boolean
|
|
protected
|
|
public
Iterator
|
#
getIterator( )
Returns an iterator for traversing the items in the list. This method is required by the interface IteratorAggregate. |
public
integer
|
|
public
integer
|
|
public
mixed
|
#
itemAt( integer $index )
Returns the item at the specified offset. This method is exactly the same as
|
public
integer
|
|
public
|
#
insertAt( integer $index, mixed $item )
Inserts an item at the specified position. Original item at the position and the next items will be moved one step towards the end. |
public
integer
|
#
remove( mixed $item )
Removes an item from the list. The list will first search for the item. The first item found will be removed from the list. |
public
mixed
|
|
public
|
|
public
boolean
|
|
public
integer
|
|
public
integer
|
#
insertBefore( mixed $baseitem, mixed $item )
Finds the base item. If found, the item is inserted before it. |
public
integer
|
#
insertAfter( mixed $baseitem, mixed $item )
Finds the base item. If found, the item is inserted after it. |
public
array
|
|
public
|
#
copyFrom( mixed $data )
Copies iterable data into the list. Note, existing data in the list will be cleared first. |
public
|
#
mergeWith( mixed $data )
Merges iterable data into the map. New data will be appended to the end of the existing data. |
public
boolean
|
#
offsetExists( integer $offset )
Returns whether there is an item at the specified offset. This method is required by the interface ArrayAccess. |
public
mixed
|
#
offsetGet( integer $offset )
Returns the item at the specified offset. This method is required by the interface ArrayAccess. |
public
|
#
offsetSet( integer $offset, mixed $item )
Sets the item at the specified offset. This method is required by the interface ArrayAccess. |
public
|
#
offsetUnset( integer $offset )
Unsets the item at the specified offset. This method is required by the interface ArrayAccess. |
GLOBAL_RAISE_EVENT_LISTENER
|