CQueue
鍖 | system.collections |
---|---|
缁ф壙 | class CQueue » CComponent |
瀹炵幇 | IteratorAggregate, Traversable, Countable |
婧愯嚜 | 1.0 |
鐗堟湰 | $Id: CQueue.php 3427 2011-10-25 00:03:52Z alexander.makarow $ |
婧愮爜 | framework/collections/CQueue.php |
CQueue瀹炵幇浜嗕竴涓槦鍒椼
杩欎釜瀹炵幇鐨勫吀鍨嬬殑闃熷垪鎿嶄綔锛屽寘鎷 enqueue()锛dequeue()鍜peek()銆傚彟澶栵紝 contains()鍙互鐢ㄦ潵妫鏌ヤ竴涓」鐩槸鍚﹀寘鍚湪 闃熷垪銆傞氳繃Count灞炴э紝鍙互鍙栧緱 鍒楄〃涓殑椤圭洰鏁般
闃熷垪涓殑椤圭洰鍙互鍍忎笅闈㈤偅鏍蜂娇鐢╢oreach閬嶅巻锛
杩欎釜瀹炵幇鐨勫吀鍨嬬殑闃熷垪鎿嶄綔锛屽寘鎷 enqueue()锛dequeue()鍜peek()銆傚彟澶栵紝 contains()鍙互鐢ㄦ潵妫鏌ヤ竴涓」鐩槸鍚﹀寘鍚湪 闃熷垪銆傞氳繃Count灞炴э紝鍙互鍙栧緱 鍒楄〃涓殑椤圭洰鏁般
闃熷垪涓殑椤圭洰鍙互鍍忎笅闈㈤偅鏍蜂娇鐢╢oreach閬嶅巻锛
foreach($queue as $item) ...
鍏叡灞炴
灞炴 | 绫诲瀷 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|---|
count | integer | 杩斿洖闃熷垪涓殑椤圭洰鏁般 | CQueue |
iterator | Iterator | 杩斿洖閬嶅巻杩欎釜椤圭洰闃熷垪鐨勮凯浠e櫒銆 | CQueue |
鍏叡鏂规硶
鏂规硶 | 鎻忚堪 | 瀹氫箟鍦 |
---|---|---|
__call() | 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 | CComponent |
__construct() | 鏋勯犳柟娉曘 | CQueue |
__get() | 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 | CComponent |
__isset() | 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 | CComponent |
__set() | 璁剧疆涓涓粍浠剁殑灞炴у笺 | CComponent |
__unset() | 璁剧疆涓涓粍浠剁殑灞炴т负null銆 | CComponent |
asa() | 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° | CComponent |
attachBehavior() | 闄勫姞涓涓涓哄埌缁勪欢銆 | CComponent |
attachBehaviors() | 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 | CComponent |
attachEventHandler() | 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 | CComponent |
canGetProperty() | 纭畾灞炴ф槸鍚﹀彲璇汇 | CComponent |
canSetProperty() | 纭畾灞炴ф槸鍚﹀彲鍐欍 | CComponent |
clear() | 鍒犻櫎闃熷垪涓墍鏈夐」鐩 | CQueue |
contains() | CQueue | |
copyFrom() | 灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒伴槦鍒椼 | CQueue |
count() | 杩斿洖闃熷垪涓殑椤圭洰鏁般 | CQueue |
dequeue() | 鍒犻櫎骞惰繑鍥炲浜庡垪琛ㄥ紑濮嬪鐨勫璞° | CQueue |
detachBehavior() | 浠庣粍浠朵腑鍒嗙涓涓涓恒 | CComponent |
detachBehaviors() | 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 | CComponent |
detachEventHandler() | 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 | CComponent |
disableBehavior() | 绂佺敤涓涓檮鍔犺涓恒 | CComponent |
disableBehaviors() | 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enableBehavior() | 鍚敤涓涓檮鍔犺涓恒 | CComponent |
enableBehaviors() | 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 | CComponent |
enqueue() | 娣诲姞涓涓璞″埌闃熷垪灏鹃儴銆 | CQueue |
evaluateExpression() | 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 | CComponent |
getCount() | 杩斿洖闃熷垪涓殑椤圭洰鏁般 | CQueue |
getEventHandlers() | 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 | CComponent |
getIterator() | 杩斿洖閬嶅巻杩欎釜椤圭洰闃熷垪鐨勮凯浠e櫒銆 | CQueue |
hasEvent() | 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 | CComponent |
hasEventHandler() | 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 | CComponent |
hasProperty() | 纭畾灞炴ф槸鍚﹁瀹氫箟銆 | CComponent |
peek() | 杩斿洖澶勪簬闃熷垪澶撮儴鐨勯」鐩 | CQueue |
raiseEvent() | 鍙戣捣涓涓簨浠躲 | CComponent |
toArray() | CQueue |
灞炴ц缁
count
灞炴
鍙
public integer getCount()
杩斿洖闃熷垪涓殑椤圭洰鏁般
iterator
灞炴
鍙
public Iterator getIterator()
杩斿洖閬嶅巻杩欎釜椤圭洰闃熷垪鐨勮凯浠e櫒銆 姝ゆ柟娉曚负鎺ュ彛IteratorAggregate寮哄埗瑕佹眰瀹炵幇銆
鏂规硶璇︾粏
__construct()
鏂规硶
public void __construct(array $data=NULL)
| ||
$data | array | 鍒濆鍖栫殑鏁版嵁銆傞粯璁や负null锛屾剰鍛崇潃涓嶄細鍒濆鍖栥 |
婧愮爜锛 framework/collections/CQueue.php#52 (鏄剧ず)
public function __construct($data=null)
{
if($data!==null)
$this->copyFrom($data);
}
鏋勯犳柟娉曘 鏍规嵁鏁扮粍鎴栬呰凯浠e璞″垵濮嬪寲杩欎釜闃熷垪銆
clear()
鏂规硶
public void clear()
|
婧愮爜锛 framework/collections/CQueue.php#90 (鏄剧ず)
public function clear()
{
$this->_c=0;
$this->_d=array();
}
鍒犻櫎闃熷垪涓墍鏈夐」鐩
contains()
鏂规硶
public boolean contains(mixed $item)
| ||
$item | mixed | 椤圭洰瀵硅薄 |
{return} | boolean | 杩斿洖鍊艰鏄庨槦鍒椾腑鏄惁鍖呭惈璇ラ」鐩 |
婧愮爜锛 framework/collections/CQueue.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/CQueue.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','Queue data must be an array or an object implementing Traversable.'));
}
灏嗚凯浠e櫒涓殑鏁版嵁澶嶅埗鍒伴槦鍒椼 娉ㄦ剰锛岄槦鍒椾腑宸茬粡瀛樺湪鐨勬暟鎹細琚鍏堝垹闄ゃ
count()
鏂规硶
public integer count()
| ||
{return} | integer | 杩斿洖闃熷垪涓殑椤圭洰鏁般 |
杩斿洖闃熷垪涓殑椤圭洰鏁般 姝ゆ柟娉曚负鎺ュ彛Countable寮哄埗瑕佹眰瀹炵幇銆
dequeue()
鏂规硶
public mixed dequeue()
| ||
{return} | mixed | 杩斿洖澶勪簬鍒楄〃寮濮嬪鐨勫璞 |
婧愮爜锛 framework/collections/CQueue.php#123 (鏄剧ず)
public function dequeue()
{
if($this->_c===0)
throw new CException(Yii::t('yii','The queue is empty.'));
else
{
--$this->_c;
return array_shift($this->_d);
}
}
鍒犻櫎骞惰繑鍥炲浜庡垪琛ㄥ紑濮嬪鐨勫璞°
enqueue()
鏂规硶
public void enqueue(mixed $item)
| ||
$item | mixed | 瑕佹坊鍔犲埌闃熷垪灏鹃儴鐨勯」鐩 |
婧愮爜锛 framework/collections/CQueue.php#138 (鏄剧ず)
public function enqueue($item)
{
++$this->_c;
array_push($this->_d,$item);
}
娣诲姞涓涓璞″埌闃熷垪灏鹃儴銆
getCount()
鏂规硶
public integer getCount()
| ||
{return} | integer | 杩斿洖闃熷垪涓殑椤圭洰鏁般 |
杩斿洖闃熷垪涓殑椤圭洰鏁般
getIterator()
鏂规硶
public Iterator getIterator()
| ||
{return} | Iterator | 杩斿洖閬嶅巻杩欎釜椤圭洰闃熷垪鐨勮凯浠e櫒銆 |
婧愮爜锛 framework/collections/CQueue.php#149 (鏄剧ず)
public function getIterator()
{
return new CQueueIterator($this->_d);
}
杩斿洖閬嶅巻杩欎釜椤圭洰闃熷垪鐨勮凯浠e櫒銆 姝ゆ柟娉曚负鎺ュ彛IteratorAggregate寮哄埗瑕佹眰瀹炵幇銆
peek()
鏂规硶
public mixed peek()
| ||
{return} | mixed | 杩斿洖澶勪簬闃熷垪澶撮儴鐨勯」鐩 |
婧愮爜锛 framework/collections/CQueue.php#110 (鏄剧ず)
public function peek()
{
if($this->_c===0)
throw new CException(Yii::t('yii','The queue is empty.'));
else
return $this->_d[0];
}
杩斿洖澶勪簬闃熷垪澶撮儴鐨勯」鐩
toArray()
鏂规硶
public array toArray()
| ||
{return} | array | 闃熷垪涓殑椤圭洰鍒楄〃銆 |