Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CAttributeCollection
  • CConfiguration
  • CList
  • CListIterator
  • CMap
  • CMapIterator
  • CQueue
  • CQueueIterator
  • CStack
  • CStackIterator
  • CTypedList
  • CTypedMap
  • Overview
  • Package
  • Class
  • Tree

Class CList

CList implements an integer-indexed collection class.

You can access, append, insert, remove an item by using CList::itemAt(), CList::add(), CList::insertAt(), CList::remove(), and CList::removeAt(). To get the number of the items in the list, use CList::getCount(). CList 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 CList by doing additional operations with each addition or removal operation (e.g. performing type check), override CList::insertAt(), and CList::removeAt().

CComponent
Extended by CList implements IteratorAggregate, ArrayAccess, Countable

Direct known subclasses

CFilterChain, CTypedList
Package: system\collections
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/collections/CList.php
Methods summary
public
# __construct( array $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
$data the initial data. Default is null, meaning no initialization.
$readOnly
boolean
$readOnly whether the list is read-only

Throws

CException
If data is not null and neither an array nor an iterator.
public boolean
# getReadOnly( )

Returns

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

Parameters

$value
boolean
$value 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 the number of items in the list.

Returns the number of items in the list.

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 CList::offsetGet().

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

Parameters

$index
integer
$index the index of the item

Returns

mixed
the item at the index

Throws

CException
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
$item new item

Returns

integer
the zero-based index at which the item is added
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
$index the specified position.
$item
mixed
$item new item

Throws

CException
If the index specified exceeds the bound or 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
$item the item to be removed.

Returns

integer
the index at which the item is being removed

Throws

CException
If the item does not exist
public mixed
# removeAt( integer $index )

Removes an item at the specified position.

Removes an item at the specified position.

Parameters

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

Returns

mixed
the removed item.

Throws

CException
If the index specified exceeds the bound or the list is read-only
public
# clear( )

Removes all items in the list.

Removes all items in the list.

public boolean
# contains( mixed $item )

Parameters

$item
mixed
$item the item

Returns

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

Parameters

$item
mixed
$item the item

Returns

integer
the index of the item in the list (0 based), -1 if not found.
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
$data the data to be copied from, must be an array or object implementing Traversable

Throws

CException
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
$data the data to be merged with, must be an array or object implementing Traversable

Throws

CException
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
$offset 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
$offset the offset to retrieve item.

Returns

mixed
the item at the offset

Throws

CException
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
$offset the offset to set item
$item
mixed
$item 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
$offset the offset to unset item

Implementation of

ArrayAccess::offsetUnset()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Magic properties summary
public boolean $readOnly
#

Whether this list is read-only or not. Defaults to false.

Whether this list is read-only or not. Defaults to false.

public Iterator $iterator
#

An iterator for traversing the items in the list.

An iterator for traversing the items in the list.

public integer $count
#

The number of items in the list.

The number of items in the list.

API documentation generated by ApiGen 2.8.0