Yii Framework v1.1.10 绫诲弬鑰

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閬嶅巻锛
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 杩斿洖鏍堜腑鐨勯」鐩暟銆
婧愮爜锛 framework/collections/CStack.php#169 (鏄剧ず)
public function count()
{
    return 
$this->getCount();
}

杩斿洖鏍堜腑鐨勯」鐩暟銆 姝ゆ柟娉曚负鎺ュ彛Countable寮哄埗瑕佹眰瀹炵幇銆

getCount() 鏂规硶
public integer getCount()
{return} integer 杩斿洖鏍堜腑鐨勯」鐩暟銆
婧愮爜锛 framework/collections/CStack.php#159 (鏄剧ず)
public function getCount()
{
    return 
$this->_c;
}

杩斿洖鏍堜腑鐨勯」鐩暟銆

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} 鏍堜腑鐨勯」鐩垪琛ㄣ
婧愮爜锛 framework/collections/CStack.php#61 (鏄剧ず)
public function toArray()
{
    return 
$this->_d;
}

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.