PHP 클래스 Prado\Collections\TMap

TMap implements a collection that takes key-value pairs. You can access, add or remove an item with a key by using {@link itemAt}, {@link add}, and {@link remove}. To get the number of the items in the map, use {@link 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
부터: 3.0
저자: Qiang Xue ([email protected])
상속: extends Prado\TComponent, implements IteratorAggregate, implements ArrayAccess, implements Countable
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( $data = null, $readOnly = false ) Constructor.
add ( $key, $value ) Adds an item into the map.
clear ( ) Removes all items in the map.
contains ( $key ) : boolean
copyFrom ( $data ) Copies iterable data into the map.
count ( ) : integer Returns the number of items in the map.
getCount ( ) : integer
getIterator ( ) : Iterator Returns an iterator for traversing the items in the list.
getKeys ( ) : array
getReadOnly ( ) : boolean
itemAt ( $key ) : mixed Returns the item with the specified key.
mergeWith ( $data ) Merges iterable data into the map.
offsetExists ( $offset ) : boolean Returns whether there is an element at the specified offset.
offsetGet ( $offset ) : mixed Returns the element at the specified offset.
offsetSet ( $offset, $item ) Sets the element at the specified offset.
offsetUnset ( $offset ) Unsets the element at the specified offset.
remove ( $key ) : mixed Removes an item from the map by its key.
toArray ( ) : array

보호된 메소드들

메소드 설명
_getZappableSleepProps ( &$exprops ) Returns an array with the names of all variables of this object that should NOT be serialized because their value is the default one or useless to be cached for the next page loads.
setReadOnly ( $value )

메소드 상세

__construct() 공개 메소드

Initializes the list with an array or an iterable object.
public __construct ( $data = null, $readOnly = false )

_getZappableSleepProps() 보호된 메소드

Reimplement in derived classes to add new variables, but remember to also to call the parent implementation first.
protected _getZappableSleepProps ( &$exprops )

add() 공개 메소드

Note, if the specified key already exists, the old value will be overwritten.
public add ( $key, $value )

clear() 공개 메소드

Removes all items in the map.
public clear ( )

contains() 공개 메소드

public contains ( $key ) : boolean
리턴 boolean whether the map contains an item with the specified key

copyFrom() 공개 메소드

Note, existing data in the map will be cleared first.
public copyFrom ( $data )

count() 공개 메소드

This method is required by \Countable interface.
public count ( ) : integer
리턴 integer number of items in the map.

getCount() 공개 메소드

public getCount ( ) : integer
리턴 integer the number of items in the map

getIterator() 공개 메소드

This method is required by the interface \IteratorAggregate.
public getIterator ( ) : Iterator
리턴 Iterator an iterator for traversing the items in the list.

getKeys() 공개 메소드

public getKeys ( ) : array
리턴 array the key list

getReadOnly() 공개 메소드

public getReadOnly ( ) : boolean
리턴 boolean whether this map is read-only or not. Defaults to false.

itemAt() 공개 메소드

This method is exactly the same as {@link offsetGet}.
public itemAt ( $key ) : mixed
리턴 mixed the element at the offset, null if no element is found at the offset

mergeWith() 공개 메소드

Existing data in the map will be kept and overwritten if the keys are the same.
public mergeWith ( $data )

offsetExists() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetExists ( $offset ) : boolean
리턴 boolean

offsetGet() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetGet ( $offset ) : mixed
리턴 mixed the element at the offset, null if no element is found at the offset

offsetSet() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetSet ( $offset, $item )

offsetUnset() 공개 메소드

This method is required by the interface \ArrayAccess.
public offsetUnset ( $offset )

remove() 공개 메소드

Removes an item from the map by its key.
public remove ( $key ) : mixed
리턴 mixed the removed value, null if no such key exists.

setReadOnly() 보호된 메소드

protected setReadOnly ( $value )

toArray() 공개 메소드

public toArray ( ) : array
리턴 array the list of items in array