Yii Framework v1.1.10 绫诲弬鑰

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閬嶅巻锛
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 杩斿洖闃熷垪涓殑椤圭洰鏁般
婧愮爜锛 framework/collections/CQueue.php#168 (鏄剧ず)
public function count()
{
    return 
$this->getCount();
}

杩斿洖闃熷垪涓殑椤圭洰鏁般 姝ゆ柟娉曚负鎺ュ彛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 杩斿洖闃熷垪涓殑椤圭洰鏁般
婧愮爜锛 framework/collections/CQueue.php#158 (鏄剧ず)
public function getCount()
{
    return 
$this->_c;
}

杩斿洖闃熷垪涓殑椤圭洰鏁般

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 闃熷垪涓殑椤圭洰鍒楄〃銆
婧愮爜锛 framework/collections/CQueue.php#61 (鏄剧ず)
public function toArray()
{
    return 
$this->_d;
}

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