PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

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
Extended by TList implements IteratorAggregate, ArrayAccess, Countable

Direct known subclasses

TAuthorizationRuleCollection, TCacheDependencyList, TMetaTagCollection, TPagedList, TPriorityList, TRepeaterItemCollection, TWizardStepCollection, TXmlElementList, TCallChain, TControlCollection, TDataGridColumnCollection, TDataGridItemCollection, TDataListItemCollection, THotSpotCollection, THttpCookieCollection, TListItemCollection

Indirect known subclasses

TAccordionViewCollection, TActiveListItemCollection, TEmptyControlCollection, TSqlMapPagedList, TTableCellCollection, TTableRowCollection, TTabViewCollection, TViewCollection
Package: System\Collections
Copyright: 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
Methods summary
public
# __construct( array|Iterator $data = null, boolean $readOnly = false )

Constructor. Initializes the list with an array or an iterable object.

Constructor. Initializes the list with an array or an iterable object.

Parameters

$data
array|Iterator
the initial data. Default is null, meaning no initialization.
$readOnly
boolean
whether the list is read-only

Throws

TInvalidDataTypeException
If data is not null and neither an array nor an iterator.

Overrides

TComponent::__construct()
public boolean
# getReadOnly( )

Returns

boolean
whether this list is read-only or not. Defaults to false.
protected
# setReadOnly( boolean $value )

Parameters

$value
boolean
whether this list is read-only or not
public Iterator
# getIterator( )

Returns an iterator for traversing the items in the list. This method is required by the interface IteratorAggregate.

Returns an iterator for traversing the items in the list. This method is required by the interface IteratorAggregate.

Returns

Iterator
an iterator for traversing the items in the list.

Implementation of

IteratorAggregate::getIterator()
public integer
# count( )

Returns the number of items in the list. This method is required by Countable interface.

Returns the number of items in the list. This method is required by Countable interface.

Returns

integer
number of items in the list.

Implementation of

Countable::count()
public integer
# getCount( )

Returns

integer
the number of items in the list
public mixed
# itemAt( integer $index )

Returns the item at the specified offset. This method is exactly the same as TList::offsetGet().

Returns the item at the specified offset. This method is exactly the same as TList::offsetGet().

Parameters

$index
integer
the index of the item

Returns

mixed
the item at the index

Throws

TInvalidDataValueException
if the index is out of the range
public integer
# add( mixed $item )

Appends an item at the end of the list.

Appends an item at the end of the list.

Parameters

$item
mixed
new item

Returns

integer
the zero-based index at which the item is added

Throws

TInvalidOperationException
if the list is read-only
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.

Inserts an item at the specified position. Original item at the position and the next items will be moved one step towards the end.

Parameters

$index
integer
the specified position.
$item
mixed
new item

Throws

TInvalidDataValueException
If the index specified exceeds the bound
TInvalidOperationException
if the list is read-only
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.

Removes an item from the list. The list will first search for the item. The first item found will be removed from the list.

Parameters

$item
mixed
the item to be removed.

Returns

integer
the index at which the item is being removed

Throws

TInvalidDataValueException
If the item does not exist
TInvalidOperationException
if the list is read-only
public mixed
# removeAt( integer $index )

Removes an item at the specified position.

Removes an item at the specified position.

Parameters

$index
integer
the index of the item to be removed.

Returns

mixed
the removed item.

Throws

TInvalidDataValueException
If the index specified exceeds the bound
TInvalidOperationException
if the list is read-only
public
# clear( )

Removes all items in the list.

Removes all items in the list.

Throws

TInvalidOperationException
if the list is read-only
public boolean
# contains( mixed $item )

Parameters

$item
mixed
the item

Returns

boolean
whether the list contains the item
public integer
# indexOf( mixed $item )

Parameters

$item
mixed
the item

Returns

integer
the index of the item in the list (0 based), -1 if not found.
public integer
# insertBefore( mixed $baseitem, mixed $item )

Finds the base item. If found, the item is inserted before it.

Finds the base item. If found, the item is inserted before it.

Parameters

$baseitem
mixed
the base item which will be pushed back by the second parameter
$item
mixed
the item

Returns

integer
the index where the item is inserted

Throws

TInvalidDataValueException
if the base item is not within this list
TInvalidOperationException
if the list is read-only

Since

3.2a
public integer
# insertAfter( mixed $baseitem, mixed $item )

Finds the base item. If found, the item is inserted after it.

Finds the base item. If found, the item is inserted after it.

Parameters

$baseitem
mixed
the base item which comes before the second parameter when added to the list
$item
mixed
the item

Returns

integer
the index where the item is inserted

Throws

TInvalidDataValueException
if the base item is not within this list
TInvalidOperationException
if the list is read-only

Since

3.2a
public array
# toArray( )

Returns

array
the list of items in array
public
# copyFrom( mixed $data )

Copies iterable data into the list. Note, existing data in the list will be cleared first.

Copies iterable data into the list. Note, existing data in the list will be cleared first.

Parameters

$data
mixed
the data to be copied from, must be an array or object implementing Traversable

Throws

TInvalidDataTypeException
If data is neither an array nor a Traversable.
public
# mergeWith( mixed $data )

Merges iterable data into the map. New data will be appended to the end of the existing data.

Merges iterable data into the map. New data will be appended to the end of the existing data.

Parameters

$data
mixed
the data to be merged with, must be an array or object implementing Traversable

Throws

TInvalidDataTypeException
If data is neither an array nor an iterator.
public boolean
# offsetExists( integer $offset )

Returns whether there is an item at the specified offset. This method is required by the interface ArrayAccess.

Returns whether there is an item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to check on

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed
# offsetGet( integer $offset )

Returns the item at the specified offset. This method is required by the interface ArrayAccess.

Returns the item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to retrieve item.

Returns

mixed
the item at the offset

Throws

TInvalidDataValueException
if the offset is invalid

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( integer $offset, mixed $item )

Sets the item at the specified offset. This method is required by the interface ArrayAccess.

Sets the item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to set item
$item
mixed
the item value

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( integer $offset )

Unsets the item at the specified offset. This method is required by the interface ArrayAccess.

Unsets the item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to unset item

Implementation of

ArrayAccess::offsetUnset()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO