CStack
鍖 | system.collections |
---|---|
缁ф壙 | class CStack » CComponent |
瀹炵幇 | IteratorAggregate, Traversable, Countable |
婧愯嚜 | 1.0 |
鐗堟湰 | $Id: CStack.php 3427 2011-10-25 00:03:52Z alexander.makarow $ |
婧愮爜 | framework/collections/CStack.php |
CStack瀹炵幇涓涓爤銆
杩欎釜绫诲凡缁忓疄鐜颁簡涓浜涘吀鍨嬬殑鏍堢殑鎿嶄綔锛屽寘鎷 push()锛pop()鍜peek()銆傚彟澶栵紝 contains()鍙互鐢ㄦ潵妫鏌ラ」鐩槸鍚﹀瓨鍦 浜庢爤涓傞氳繃Count灞炴э紝鍙互鍙栧緱 鍒楄〃涓殑椤圭洰鏁般
鏍堜腑鐨勯」鐩彲浠ュ儚涓嬮潰閭f牱浣跨敤foreach閬嶅巻锛
杩欎釜绫诲凡缁忓疄鐜颁簡涓浜涘吀鍨嬬殑鏍堢殑鎿嶄綔锛屽寘鎷 push()锛pop()鍜peek()銆傚彟澶栵紝 contains()鍙互鐢ㄦ潵妫鏌ラ」鐩槸鍚﹀瓨鍦 浜庢爤涓傞氳繃Count灞炴э紝鍙互鍙栧緱 鍒楄〃涓殑椤圭洰鏁般
鏍堜腑鐨勯」鐩彲浠ュ儚涓嬮潰閭f牱浣跨敤foreach閬嶅巻锛
foreach($stack as $item) ...
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
count | integer | 杩斿洖鏍堜腑鐨勯」鐩暟銆 | CStack |
iterator | Iterator | 杩斿洖閬嶅巻杩欎釜鏍堢殑椤圭洰鐨勮凯浠e櫒銆 | CStack |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__call() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | CComponent |
__construct() | 鏋勯犳柟娉曘 | CStack |
__get() | 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 | CComponent |
__isset() | 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 | CComponent |
__set() | 璁剧疆涓涓粍浠剁殑灞炴у笺 | CComponent |
__unset() | 璁剧疆涓涓粍浠剁殑灞炴т负null銆 | CComponent |
asa() | 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° | CComponent |
attachBehavior() | 闄勫姞涓涓涓哄埌缁勪欢銆 | CComponent |
attachBehaviors() | 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 | CComponent |
attachEventHandler() | 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 | CComponent |
canGetProperty() | 纭畾灞炴ф槸鍚﹀彲璇汇 | CComponent |
canSetProperty() | 纭畾灞炴ф槸鍚﹀彲鍐欍 | CComponent |
clear() | 鍒犻櫎鏍堜腑鎵鏈夐」鐩 | CStack |
contains() | CStack | |
copyFrom() | 灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒版爤銆 | CStack |
count() | 杩斿洖鏍堜腑鐨勯」鐩暟銆 | CStack |
detachBehavior() | 浠庣粍浠朵腑鍒嗙涓涓涓恒 | CComponent |
detachBehaviors() | 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 | CComponent |
detachEventHandler() | 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 | CComponent |
disableBehavior() | 绂佺敤涓涓檮鍔犺涓恒 | CComponent |
disableBehaviors() | 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enableBehavior() | 鍚敤涓涓檮鍔犺涓恒 | CComponent |
enableBehaviors() | 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
evaluateExpression() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | CComponent |
getCount() | 杩斿洖鏍堜腑鐨勯」鐩暟銆 | CStack |
getEventHandlers() | 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 | CComponent |
getIterator() | 杩斿洖閬嶅巻杩欎釜鏍堢殑椤圭洰鐨勮凯浠e櫒銆 | CStack |
hasEvent() | 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 | CComponent |
hasEventHandler() | 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 | CComponent |
hasProperty() | 纭畾灞炴ф槸鍚﹁瀹氫箟銆 | CComponent |
peek() | 杩斿洖澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆 | CStack |
pop() | 鍙栧嚭澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆 | CStack |
push() | 娣诲姞涓涓璞″埌鏍堥噷闈€ | CStack |
raiseEvent() | 鍙戣捣涓涓簨浠躲 | CComponent |
toArray() | CStack |
灞炴ц缁
count
灞炴
鍙
public integer getCount()
杩斿洖鏍堜腑鐨勯」鐩暟銆
iterator
灞炴
鍙
public Iterator getIterator()
杩斿洖閬嶅巻杩欎釜鏍堢殑椤圭洰鐨勮凯浠e櫒銆 姝ゆ柟娉曚负鎺ュ彛IteratorAggregate寮哄埗瑕佹眰瀹炵幇銆
鏂规硶璇︾粏
__construct()
鏂规硶
public void __construct(array $data=NULL)
| ||
$data | array | 鍒濆鍖栫殑鏁版嵁銆傞粯璁や负null锛屾剰鍛崇潃涓嶄細鍒濆鍖栥 |
婧愮爜锛 framework/collections/CStack.php#52 (鏄剧ず)
public function __construct($data=null)
{
if($data!==null)
$this->copyFrom($data);
}
鏋勯犳柟娉曘 鏍规嵁鏁扮粍鎴栬呰凯浠e璞″垵濮嬪寲杩欎釜鏍堛
clear()
鏂规硶
public void clear()
|
婧愮爜锛 framework/collections/CStack.php#90 (鏄剧ず)
public function clear()
{
$this->_c=0;
$this->_d=array();
}
鍒犻櫎鏍堜腑鎵鏈夐」鐩
contains()
鏂规硶
public boolean contains(mixed $item)
| ||
$item | mixed | 椤圭洰瀵硅薄 |
{return} | boolean | 杩斿洖鍊艰鏄庢爤涓槸鍚﹀寘鍚椤圭洰 |
婧愮爜锛 framework/collections/CStack.php#100 (鏄剧ず)
public function contains($item)
{
return array_search($item,$this->_d,true)!==false;
}
copyFrom()
鏂规硶
public void copyFrom(mixed $data)
| ||
$data | mixed | 瑕佸鍒剁殑鏁版嵁, 鍙兘鏄暟缁勬垨鑰呯户鎵夸簬Traversable鐨勫璞° |
婧愮爜锛 framework/collections/CStack.php#72 (鏄剧ず)
public function copyFrom($data)
{
if(is_array($data) || ($data instanceof Traversable))
{
$this->clear();
foreach($data as $item)
{
$this->_d[]=$item;
++$this->_c;
}
}
else if($data!==null)
throw new CException(Yii::t('yii','Stack data must be an array or an object implementing Traversable.'));
}
灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒版爤銆 娉ㄦ剰锛屾爤涓凡缁忓瓨鍦ㄧ殑鏁版嵁浼氳棣栧厛鍒犻櫎銆
count()
鏂规硶
public integer count()
| ||
{return} | integer | 杩斿洖鏍堜腑鐨勯」鐩暟銆 |
杩斿洖鏍堜腑鐨勯」鐩暟銆 姝ゆ柟娉曚负鎺ュ彛Countable寮哄埗瑕佹眰瀹炵幇銆
getCount()
鏂规硶
public integer getCount()
| ||
{return} | integer | 杩斿洖鏍堜腑鐨勯」鐩暟銆 |
杩斿洖鏍堜腑鐨勯」鐩暟銆
getIterator()
鏂规硶
public Iterator getIterator()
| ||
{return} | Iterator | 杩斿洖閬嶅巻杩欎釜鏍堢殑椤圭洰鐨勮凯浠e櫒銆 |
婧愮爜锛 framework/collections/CStack.php#150 (鏄剧ず)
public function getIterator()
{
return new CStackIterator($this->_d);
}
杩斿洖閬嶅巻杩欎釜鏍堢殑椤圭洰鐨勮凯浠e櫒銆 姝ゆ柟娉曚负鎺ュ彛IteratorAggregate寮哄埗瑕佹眰瀹炵幇銆
peek()
鏂规硶
public mixed peek()
| ||
{return} | mixed | 杩斿洖澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆 |
婧愮爜锛 framework/collections/CStack.php#111 (鏄剧ず)
public function peek()
{
if($this->_c)
return $this->_d[$this->_c-1];
else
throw new CException(Yii::t('yii','The stack is empty.'));
}
杩斿洖澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆 璺pop()涓嶅悓锛岃繖涓柟娉曚笉浼氬垹闄ゆ爤鐨勯」鐩
pop()
鏂规硶
public mixed pop()
| ||
{return} | mixed | 杩斿洖澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆 |
婧愮爜锛 framework/collections/CStack.php#124 (鏄剧ず)
public function pop()
{
if($this->_c)
{
--$this->_c;
return array_pop($this->_d);
}
else
throw new CException(Yii::t('yii','The stack is empty.'));
}
鍙栧嚭澶勪簬鏍堝ご閮ㄧ殑椤圭洰銆
push()
鏂规硶
public void push(mixed $item)
| ||
$item | mixed | 瑕佹坊鍔犲埌鏍堥噷闈㈢殑瀵硅薄銆 |
婧愮爜锛 framework/collections/CStack.php#139 (鏄剧ず)
public function push($item)
{
++$this->_c;
array_push($this->_d,$item);
}
娣诲姞涓涓璞″埌鏍堥噷闈€
toArray()
鏂规硶
public 鏍堜腑鐨勯」鐩垪琛ㄣ toArray()
| ||
{return} | 鏍堜腑鐨勯」鐩垪琛ㄣ |