Class TMap
TMap class
TMap implements a collection that takes key-value pairs.
You can access, add or remove an item with a key by using TMap::itemAt()
,
TMap::add()
, and TMap::remove()
. To get the number of the items in the map, use
TMap::getCount()
. TMap can also be used like a regular array as follows,
$map[$key]=$value; // add a key-value pair unset($map[$key]); // remove the value with the specified key if(isset($map[$key])) // if the map contains the key foreach($map as $key=>$value) // traverse the items in the map $n=count($map); // returns the number of items in the map
- TComponent
-
TMap implements IteratorAggregate, ArrayAccess, Countable
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Collections/TMap.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
array
|
|
public
mixed
|
#
itemAt( mixed $key )
Returns the item with the specified key. This method is exactly the same as
|
public
|
#
add( mixed $key, mixed $value )
Adds an item into the map. Note, if the specified key already exists, the old value will be overwritten. |
public
mixed
|
|
public
|
|
public
boolean
|
|
public
array
|
|
public
|
#
copyFrom( mixed $data )
Copies iterable data into the map. Note, existing data in the map will be cleared first. |
public
|
#
mergeWith( mixed $data )
Merges iterable data into the map. Existing data in the map will be kept and overwritten if the keys are the same. |
public
boolean
|
#
offsetExists( mixed $offset )
Returns whether there is an element at the specified offset. This method is required by the interface ArrayAccess. |
public
mixed
|
#
offsetGet( integer $offset )
Returns the element at the specified offset. This method is required by the interface ArrayAccess. |
public
|
#
offsetSet( integer $offset, mixed $item )
Sets the element at the specified offset. This method is required by the interface ArrayAccess. |
public
|
#
offsetUnset( mixed $offset )
Unsets the element at the specified offset. This method is required by the interface ArrayAccess. |
GLOBAL_RAISE_EVENT_LISTENER
|