VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Class: Collection

Source Location: /classes.inc.php

Class Overview

Object
   |
   --Collection

A class for storing and managing a list of objects. This class acts as a wrapper over a PHP array.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: Object

Object::__construct()
Constructs an object and initializes its data before the object is first used.
Object::className()
Returns a string indicating the type of the object instance (as opposed to the type of the variable passed as an argument).
Object::classNameIs()
Determines whether an object is of a specific type.
Object::classParent()
Returns the type of the immediate ancestor of a class.
Object::inheritsFrom()
Determines the relationship of two object types.
Object::methodExists()
Check if a method exists declared on this object instance.
Object::readProperty()
Reads a property from the streams
Object::__get()
To virtualize properties
Object::__set()
To virtualize properties

Class Details

[line 654]
A class for storing and managing a list of objects. This class acts as a wrapper over a PHP array.

Collection, which stores an array of items, is often used to maintain lists of objects. Collection introduces properties and methods to:

Add or delete the objects in the list.

Rearrange the objects in the list.

Locate and access objects in the list.

Sort the objects in the list.




Tags:



[ Top ]


Class Variables

$items =

[line 657]



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 659]

Collection __construct( )



Overrides Object::__construct() (Constructs an object and initializes its data before the object is first used.)

[ Top ]

method add [line 680]

integer add( mixed $item)

Inserts a new item at the end of the list.

Call Add to insert a new object at the end of the array. Add returns the index of the new item, where the first item in the list has an index of 0.

Note: Add always inserts the Item at the end of the array, even if the internal position pointer of the array is at another position




Tags:

return:  Number of items in the collection
see:  Collection::delete()


Parameters:

mixed   $item   Object to add to the list

[ Top ]

method clear [line 700]

void clear( )

Deletes all items from the list

Call Clear to empty the array and set the Count to 0. Clear also frees the memory used to store the Items.




Tags:



[ Top ]

method count [line 799]

integer count( )

Indicates the number of entries in the list that are in use

Call Count to determine the number of entries in the Items array.




Tags:



[ Top ]

method delete [line 719]

void delete( integer $index)

Removes the item at the position given by the Index parameter.

Call Delete to remove the item at a specific position from the list. The index is zero-based, so the first item has an Index value of 0, the second item has an Index value of 1, and so on. Calling Delete moves up all items in the array that follow the deleted item, and reduces the Count.

If the item is not in the list, an ECollectionError exception is raised.




Tags:



Parameters:

integer   $index   Index of the item to delete

[ Top ]

method indexof [line 744]

integer indexof( object $item)

Returns the index of the first entry in the Items array with a specified value.

Call IndexOf to get the index for an item in the array. Specify the item as the Item parameter.

The first item in the array has index 0, the second item has index 1, and so on. If an item is not in the list, IndexOf returns -1. If an item appears more than once in the array, IndexOf returns the index of the first appearance.




Tags:

return:  Index of the item or -1 if not found


Parameters:

object   $item   Item to find

[ Top ]

method last [line 814]

object last( )

Returns the last element from the collection.

Call this method to get the last item added to the list, if the list is empty, this method returns null




Tags:



[ Top ]

method remove [line 776]

integer remove( object $item)

Deletes the first reference to the Item parameter from the Items array.

Call Remove to remove a specific item from the array when its index is unknown. The value returned is the index of the item in the array before it was removed. After an item is removed, all the items that follow it are moved up in index position and the Count is reduced by one.

If the array contains more than one copy of the pointer, only the first copy is deleted.




Tags:

return:  Index of the item removed or -1 if it's not found
see:  Collection::delete()


Parameters:

object   $item   Item to delete from the list

[ Top ]


Documentation generated on Sat, 13 Jun 2009 10:50:59 -0700 by phpDocumentor 1.4.1